本文整理汇总了PHP中yith_usecookies函数的典型用法代码示例。如果您正苦于以下问题:PHP yith_usecookies函数的具体用法?PHP yith_usecookies怎么用?PHP yith_usecookies使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了yith_usecookies函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: array
$limit_sql = '';
$pagination = 'no';
if ($pagination == 'yes') {
$count = array();
if (is_user_logged_in() || isset($user_id) && !empty($user_id)) {
$count = $wpdb->get_results($wpdb->prepare('SELECT COUNT(*) as `cnt` FROM `' . YITH_WCWL_TABLE . '` WHERE `user_id` = %d', $user_id), ARRAY_A);
$count = $count[0]['cnt'];
} elseif (yith_usecookies()) {
$count[0]['cnt'] = count(yith_getcookie('yith_wcwl_products'));
} else {
$count[0]['cnt'] = count($_SESSION['yith_wcwl_products']);
}
$total_pages = $count / $per_page;
if ($total_pages > 1) {
$current_page = max(1, get_query_var('page'));
$page_links = paginate_links(array('base' => get_pagenum_link(1) . '%_%', 'format' => '&page=%#%', 'current' => $current_page, 'total' => $total_pages, 'show_all' => true));
}
$limit_sql = "LIMIT " . ($current_page - 1) * 1 . ',' . $per_page;
}
if (is_user_logged_in() || isset($user_id) && !empty($user_id)) {
$wishlist = $wpdb->get_results($wpdb->prepare("SELECT * FROM `" . YITH_WCWL_TABLE . "` WHERE `user_id` = %s" . $limit_sql, $user_id), ARRAY_A);
} elseif (yith_usecookies()) {
$wishlist = yith_getcookie('yith_wcwl_products');
} else {
$wishlist = isset($_SESSION['yith_wcwl_products']) ? $_SESSION['yith_wcwl_products'] : array();
}
if (count($wishlist) > 0) {
echo '<li class="mini-tools-wishlist"><a href="' . $yith_wcwl->get_wishlist_url() . '"><i class="fa fa-heart"></i><span class="amount">' . count($wishlist) . '</span></a></li>';
} else {
echo '<li class="mini-tools-wishlist"><a href="' . $yith_wcwl->get_wishlist_url() . '"><i class="fa fa-heart"></i></a></li>';
}
开发者ID:VLabsInc,项目名称:WordPressPlatforms,代码行数:31,代码来源:mini-tools-wishlist.php
示例2: init
/**
* Initiator method. Initiate properties.
*
* @return void
* @access private
* @since 1.0.0
*/
public function init()
{
global $yith_wcwl;
$db_colors = get_option('yith_wcwl_frontend_css_colors');
$this->colors_options = !empty($db_colors) ? maybe_unserialize($db_colors) : apply_filters('yith_wcwl_colors_options', array('add_to_wishlist' => array('background' => '#4F4F4F', 'color' => '#FFFFFF', 'border_color' => '#4F4F4F'), 'add_to_wishlist_hover' => array('background' => '#2F2F2F', 'color' => '#FFFFFF', 'border_color' => '#2F2F2F'), 'add_to_cart' => array('background' => '#4F4F4F', 'color' => '#FFFFFF', 'border_color' => '#4F4F4F'), 'add_to_cart_hover' => array('background' => '#2F2F2F', 'color' => '#FFFFFF', 'border_color' => '#2F2F2F'), 'wishlist_table' => array('background' => '#FFFFFF', 'color' => '#676868', 'border_color' => '#676868')));
if (empty($db_colors)) {
update_option('yith_wcwl_frontend_css_colors', maybe_serialize($this->colors_options));
}
$this->rules = apply_filters('yith_wcwl_colors_rules', array('add_to_wishlist' => '.woocommerce .yith-wcwl-add-button > a.button.alt', 'add_to_wishlist_hover' => '.woocommerce .yith-wcwl-add-button > a.button.alt:hover', 'add_to_cart' => '.woocommerce .wishlist_table a.add_to_cart.button.alt', 'add_to_cart_hover' => '.woocommerce .wishlist_table a.add_to_cart.button.alt:hover', 'wishlist_table' => '.wishlist_table'));
if (is_user_logged_in()) {
$yith_wcwl->details['user_id'] = get_current_user_id();
//check whether any products are added to wishlist, then after login add to the wishlist if not added
if (yith_usecookies()) {
$cookie = yith_getcookie('yith_wcwl_products');
foreach ($cookie as $details) {
$yith_wcwl->details = $details;
$yith_wcwl->details['user_id'] = get_current_user_id();
$ret_val = $yith_wcwl->add();
}
yith_destroycookie('yith_wcwl_products');
} else {
if (isset($_SESSION['yith_wcwl_products'])) {
foreach ($_SESSION['yith_wcwl_products'] as $details) {
$yith_wcwl->details = $details;
$yith_wcwl->details['user_id'] = get_current_user_id();
$ret_val = $yith_wcwl->add();
}
unset($_SESSION['yith_wcwl_products']);
}
}
}
wp_register_style('yith-wcwl-admin', YITH_WCWL_URL . 'assets/css/admin.css');
}
开发者ID:shahadat014,项目名称:geleyi,代码行数:40,代码来源:class.yith-wcwl-init.php
示例3: thb_wishlist_count
function thb_wishlist_count()
{
if (is_user_logged_in()) {
$user_id = get_current_user_id();
}
$count = array();
if (class_exists('YITH_WCWL_UI')) {
if (is_user_logged_in()) {
$count = $wpdb->get_results($wpdb->prepare('SELECT COUNT(*) as `cnt` FROM `' . YITH_WCWL_TABLE . '` WHERE `user_id` = %d', $user_id), ARRAY_A);
$count = $count[0]['cnt'];
} elseif (yith_usecookies()) {
$count[0]['cnt'] = count(yith_getcookie('yith_wcwl_products'));
} else {
$count[0]['cnt'] = count($_SESSION['yith_wcwl_products']);
}
if (is_array($count)) {
$count = 0;
}
}
return $count;
}
开发者ID:primarydesign,项目名称:the-color-mint,代码行数:21,代码来源:misc.php
示例4: ktz_get_wishlist
function ktz_get_wishlist()
{
global $wpdb, $yith_wcwl, $woocommerce;
$wishlist_output = "";
if (is_user_logged_in()) {
$user_id = get_current_user_id();
}
$count = array();
if (is_user_logged_in()) {
$count = $wpdb->get_results($wpdb->prepare('SELECT COUNT(*) as `cnt` FROM `' . YITH_WCWL_TABLE . '` WHERE `user_id` = %d', $user_id), ARRAY_A);
$count = $count[0]['cnt'];
} elseif (yith_usecookies()) {
$count[0]['cnt'] = count(yith_getcookie('yith_wcwl_products'));
$count = $count[0]['cnt'];
} else {
$count[0]['cnt'] = count($_SESSION['yith_wcwl_products']);
$count = $count[0]['cnt'];
}
if (is_array($count)) {
$count = 0;
}
$wishlist_output .= '<div class="ktz-cart-wrap login-block"><span class="ktz-wishlist-head"><a class="wishlist-link" href="' . $yith_wcwl->get_wishlist_url() . '" title="' . __("View your wishlist", ktz_theme_textdomain) . '"><span class="ktz-cart-button"> </span><span class="glyphicon glyphicon-star-empty"></span> <span id="wishlist_item_count">' . $count . '</span></a></span>';
$wishlist_output .= '<div class="ktz-wishlist-wrapper">';
$current_page = 1;
$limit_sql = '';
$count_limit = 0;
if (is_user_logged_in()) {
$wishlist = $wpdb->get_results($wpdb->prepare("SELECT * FROM `" . YITH_WCWL_TABLE . "` WHERE `user_id` = %s" . $limit_sql, $user_id), ARRAY_A);
} elseif (yith_usecookies()) {
$wishlist = yith_getcookie('yith_wcwl_products');
} else {
$wishlist = isset($_SESSION['yith_wcwl_products']) ? $_SESSION['yith_wcwl_products'] : array();
}
do_action('yith_wcwl_before_wishlist_title');
$wishlist_title = get_option('yith_wcwl_wishlist_title');
if (!empty($wishlist_title)) {
$wishlist_output .= '<div class="ktz-wishlist-titlehead">' . $wishlist_title . '</div>';
}
$wishlist_output .= do_action('yith_wcwl_before_wishlist');
if (count($wishlist) > 0) {
foreach ($wishlist as $values) {
if ($count_limit < 4) {
if (!is_user_logged_in()) {
if (isset($values['add-to-wishlist']) && is_numeric($values['add-to-wishlist'])) {
$values['prod_id'] = $values['add-to-wishlist'];
$values['ID'] = $values['add-to-wishlist'];
} else {
$values['prod_id'] = $values['product_id'];
$values['ID'] = $values['product_id'];
}
}
$product_obj = get_product($values['prod_id']);
if ($product_obj !== false && $product_obj->exists()) {
$wishlist_output .= '<div id="wishlist-' . $values['ID'] . '" class="ktz_cart_box clearfix">';
$params = array('width' => 40, 'height' => 40, 'crop' => true);
if (has_post_thumbnail($product_obj->id)) {
$image_link = wp_get_attachment_url(get_post_thumbnail_id($product_obj->id));
$image = bfi_thumb($image_link, $params);
if ($image) {
$wishlist_output .= '<a href="' . esc_url(get_permalink(apply_filters('woocommerce_in_cart_product', $values['prod_id']))) . '"><img itemprop="image" src="' . $image . '" width="40" height="40" /></a>';
}
}
$wishlist_output .= '<div class="ktz_cart_boxcontent">';
$wishlist_output .= '<a href="' . esc_url(get_permalink(apply_filters('woocommerce_in_cart_product', $values['prod_id']))) . '">' . apply_filters('woocommerce_in_cartproduct_obj_title', $product_obj->get_title(), $product_obj) . '</a>';
if (get_option('woocommerce_display_cart_prices_excluding_tax') == 'yes') {
$wishlist_output .= '<span class="quantity">' . apply_filters('woocommerce_cart_item_price_html', woocommerce_price($product_obj->get_price_excluding_tax()), $values, '') . '</span>';
} else {
$wishlist_output .= '<span class="quantity">' . apply_filters('woocommerce_cart_item_price_html', woocommerce_price($product_obj->get_price()), $values, '') . '</span>';
}
$wishlist_output .= '</div>';
$wishlist_output .= '</div>';
}
$count_limit++;
}
}
} else {
$wishlist_output .= '<div class="empty">' . __('Your wishlist is currently empty.', ktz_theme_textdomain) . '</div>';
}
$wishlist_output .= '<div class="cart-buttons">';
$wishlist_output .= '<a href="' . $yith_wcwl->get_wishlist_url() . '" class="cart-button"><i class="glyphicon glyphicon-star-empty"></i> <span class="text">' . __('Go to your wishlist', ktz_theme_textdomain) . '</span></a>';
$wishlist_output .= '</div>';
do_action('yith_wcwl_after_wishlist');
$wishlist_output .= '</div>';
$wishlist_output .= '</div>';
return $wishlist_output;
}
开发者ID:gigikir,项目名称:adebe,代码行数:86,代码来源:_woocommerce_ktz.php
示例5: sf_get_wishlist
function sf_get_wishlist()
{
global $wpdb, $yith_wcwl, $woocommerce;
$wishlist_output = "";
if (is_user_logged_in()) {
$user_id = get_current_user_id();
}
$count = array();
if (is_user_logged_in()) {
$count = $wpdb->get_results($wpdb->prepare('SELECT COUNT(*) as `cnt` FROM `' . YITH_WCWL_TABLE . '` WHERE `user_id` = %d', $user_id), ARRAY_A);
$count = $count[0]['cnt'];
} elseif (yith_usecookies()) {
$count[0]['cnt'] = count(yith_getcookie('yith_wcwl_products'));
$count = $count[0]['cnt'];
} else {
$count[0]['cnt'] = count($_SESSION['yith_wcwl_products']);
$count = $count[0]['cnt'];
}
if (is_array($count)) {
$count = 0;
}
$wishlist_output .= '<li class="parent wishlist-item"><a class="wishlist-link" href="' . $yith_wcwl->get_wishlist_url() . '" title="' . __("View your wishlist", "swiftframework") . '"><i class="ss-star"></i><span>' . $count . '</span></a>';
$wishlist_output .= '<ul class="sub-menu">';
$wishlist_output .= '<li>';
$wishlist_output .= '<div class="wishlist-bag">';
$current_page = 1;
$limit_sql = '';
$count_limit = 0;
if (is_user_logged_in()) {
$wishlist = $wpdb->get_results($wpdb->prepare("SELECT * FROM `" . YITH_WCWL_TABLE . "` WHERE `user_id` = %s" . $limit_sql, $user_id), ARRAY_A);
} elseif (yith_usecookies()) {
$wishlist = yith_getcookie('yith_wcwl_products');
} else {
$wishlist = isset($_SESSION['yith_wcwl_products']) ? $_SESSION['yith_wcwl_products'] : array();
}
do_action('yith_wcwl_before_wishlist_title');
$wishlist_title = get_option('yith_wcwl_wishlist_title');
if (!empty($wishlist_title)) {
$wishlist_output .= '<div class="bag-header">' . $wishlist_title . '</div>';
}
$wishlist_output .= '<div class="bag-contents">';
$wishlist_output .= do_action('yith_wcwl_before_wishlist');
if (count($wishlist) > 0) {
foreach ($wishlist as $values) {
if ($count_limit < 4) {
if (!is_user_logged_in()) {
if (isset($values['add-to-wishlist']) && is_numeric($values['add-to-wishlist'])) {
$values['prod_id'] = $values['add-to-wishlist'];
$values['ID'] = $values['add-to-wishlist'];
} else {
$values['prod_id'] = $values['product_id'];
$values['ID'] = $values['product_id'];
}
}
$product_obj = get_product($values['prod_id']);
if ($product_obj !== false && $product_obj->exists()) {
$wishlist_output .= '<div id="wishlist-' . $values['ID'] . '" class="bag-product clearfix">';
if (has_post_thumbnail($product_obj->id)) {
$image_link = wp_get_attachment_url(get_post_thumbnail_id($product_obj->id));
$image = sf_aq_resize($image_link, 70, 70, true, false);
if ($image) {
$wishlist_output .= '<figure><a class="bag-product-img" href="' . esc_url(get_permalink(apply_filters('woocommerce_in_cart_product', $values['prod_id']))) . '"><img itemprop="image" src="' . $image[0] . '" width="' . $image[1] . '" height="' . $image[2] . '" /></a></figure>';
}
}
$wishlist_output .= '<div class="bag-product-details">';
$wishlist_output .= '<div class="bag-product-title"><a href="' . esc_url(get_permalink(apply_filters('woocommerce_in_cart_product', $values['prod_id']))) . '">' . apply_filters('woocommerce_in_cartproduct_obj_title', $product_obj->get_title(), $product_obj) . '</a></div>';
if (get_option('woocommerce_display_cart_prices_excluding_tax') == 'yes') {
$wishlist_output .= '<div class="bag-product-price">' . apply_filters('woocommerce_cart_item_price_html', woocommerce_price($product_obj->get_price_excluding_tax()), $values, '') . '</div>';
} else {
$wishlist_output .= '<div class="bag-product-price">' . apply_filters('woocommerce_cart_item_price_html', woocommerce_price($product_obj->get_price()), $values, '') . '</div>';
}
$wishlist_output .= '</div>';
$wishlist_output .= '</div>';
}
$count_limit++;
}
}
} else {
$wishlist_output .= '<div class="wishlist-empty">' . __('Your wishlist is currently empty.', 'swiftframework') . '</div>';
}
$wishlist_output .= '</div>';
$wishlist_output .= '<div class="bag-buttons">';
$wishlist_output .= '<a class="sf-button standard sf-icon-reveal wishlist-button" href="' . $yith_wcwl->get_wishlist_url() . '"><i class="ss-star"></i><span class="text">' . __('Go to your wishlist', 'swiftframework') . '</span></a>';
$wishlist_output .= '</div>';
do_action('yith_wcwl_after_wishlist');
$wishlist_output .= '</div>';
$wishlist_output .= '</li>';
$wishlist_output .= '</ul>';
$wishlist_output .= '</li>';
return $wishlist_output;
}
开发者ID:roycocup,项目名称:enclothed,代码行数:91,代码来源:sf-header.php
示例6: get_product_details
/**
* Retrieve details of a product in the wishlist.
*
* @param int $id
* @param string $request_from
* @return array
* @since 1.0.0
*/
public function get_product_details($id)
{
global $wpdb;
if (is_user_logged_in()) {
return $wpdb->get_results($wpdb->prepare('SELECT * FROM `' . YITH_WCWL_TABLE . '` WHERE `prod_id` = %d', $id), ARRAY_A);
} elseif (yith_usecookies()) {
$cookie = yith_getcookie('yith_wcwl_products');
$temp_arr[0] = $cookie[$id];
$temp_arr[0]['prod_id'] = $id;
return $temp_arr;
} else {
$temp_arr[0] = $_SESSION['yith_wcwl_products'][$id];
$temp_arr[0]['prod_id'] = $id;
return $temp_arr;
}
return array();
}
开发者ID:apeachdev,项目名称:eyeboutique,代码行数:25,代码来源:class.yith-wcwl.php
注:本文中的yith_usecookies函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论