当前位置: 首页>>代码示例>>PHP>>正文


PHP yith_setcookie函数代码示例

本文整理汇总了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;未经允许,请勿转载。