• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP yith_setcookie函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中yith_setcookie函数的典型用法代码示例。如果您正苦于以下问题:PHP yith_setcookie函数的具体用法?PHP yith_setcookie怎么用?PHP yith_setcookie使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了yith_setcookie函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: remove

 /**
  * Remove an entry from the wishlist.
  *
  * @return bool
  * @since 1.0.0
  */
 public function remove($id = false)
 {
     global $wpdb;
     if (!empty($id)) {
         _deprecated_argument('YITH_WCWL->remove()', '2.0.0', __('The "Remove" option now does not require any parameter'));
     }
     $prod_id = isset($this->details['remove_from_wishlist']) && is_numeric($this->details['remove_from_wishlist']) ? $this->details['remove_from_wishlist'] : false;
     $wishlist_id = isset($this->details['wishlist_id']) && is_numeric($this->details['wishlist_id']) ? $this->details['wishlist_id'] : false;
     $user_id = !empty($this->details['user_id']) ? $this->details['user_id'] : false;
     if ($prod_id == false) {
         return false;
     }
     if (is_user_logged_in()) {
         $sql = " REPLACE INTO {$wpdb->yith_wcwl_items} WHERE user_id = %d AND prod_id = %d";
         $sql_args = array(0, $prod_id);
         if (empty($wishlist_id)) {
             $wishlist_id = $this->generate_default_wishlist(get_current_user_id());
         }
         $wishlist = $this->get_wishlist_detail($wishlist_id);
         $this->last_operation_token = $wishlist['wishlist_token'];
         $sql .= " AND wishlist_id = %d";
         $sql_args[] = $wishlist_id;
         $result = $wpdb->query($wpdb->prepare($sql, $sql_args));
         if ($result) {
             return true;
         } else {
             $this->errors[] = __('An error occurred while removing products from the wishlist', 'yit');
             return false;
         }
     } else {
         $wishlist = yith_getcookie('yith_wcwl_products');
         foreach ($wishlist as $key => $item) {
             if ($item['wishlist_id'] == $wishlist_id && $item['prod_id'] == $prod_id) {
                 unset($wishlist[$key]);
             }
         }
         yith_setcookie('yith_wcwl_products', $wishlist);
         return true;
     }
 }
开发者ID:bigmarina,项目名称:yith-woocommerce-wishlist,代码行数:46,代码来源:class.yith-wcwl.php


示例2: _update_cookies

 /**
  * Update old wishlist cookies
  *
  * @return void
  * @since 2.0.0
  */
 private function _update_cookies()
 {
     $cookie = yith_getcookie('yith_wcwl_products');
     $new_cookie = array();
     if (!empty($cookie)) {
         foreach ($cookie as $item) {
             if (!isset($item['add-to-wishlist'])) {
                 return;
             }
             $new_cookie[] = array('prod_id' => $item['add-to-wishlist'], 'quantity' => isset($item['quantity']) ? $item['quantity'] : 1, 'wishlist_id' => false);
         }
         yith_setcookie('yith_wcwl_products', $new_cookie);
     }
 }
开发者ID:rinodung,项目名称:live-theme,代码行数:20,代码来源:class.yith-wcwl-init.php


示例3: yith_destroycookie

 /**
  * Destroy a cookie.
  * 
  * @param string $name
  * @return void
  * @since 1.0.0
  */
 function yith_destroycookie($name)
 {
     yith_setcookie($name, array(), time() - 3600);
 }
开发者ID:shubham79,项目名称:Jhintaak,代码行数:11,代码来源:functions.yith-wcwl.php


示例4: remove

 /**
  * Remove an entry from the wishlist.
  * 
  * @param int $id Record ID
  * @return bool
  * @since 1.0.0
  */
 public function remove($id)
 {
     global $wpdb;
     if (is_user_logged_in()) {
         $sql = "DELETE FROM `" . YITH_WCWL_TABLE . "` WHERE `ID` = " . $id . " AND `user_id` = " . $this->details['user_id'];
         if ($wpdb->query($sql)) {
             return true;
         } else {
             $this->errors[] = __('Error occurred while removing product from wishlist', 'yit');
             return false;
         }
     } elseif (yith_usecookies()) {
         $cookie = yith_getcookie('yith_wcwl_products');
         unset($cookie[$id]);
         yith_destroycookie('yith_wcwl_products');
         yith_setcookie('yith_wcwl_products', $cookie);
         return true;
     } else {
         unset($_SESSION['yith_wcwl_products'][$id]);
         return true;
     }
 }
开发者ID:apeachdev,项目名称:eyeboutique,代码行数:29,代码来源:class.yith-wcwl.php



注:本文中的yith_setcookie函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP yith_usecookies函数代码示例发布时间:2022-05-23
下一篇:
PHP yith_getcookie函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap