/** * AJAX: reload wishlist and adding elem action * * @return void * @since 1.0.0 */ public function reload_wishlist_and_adding_elem_ajax() { $return = $this->add(); $message = ''; $type_msg = 'success'; if ($return == 'true') { $message = apply_filters('yith_wcwl_product_added_to_wishlist_message', get_option('yith_wcwl_product_added_text')); } elseif ($return == 'exists') { $message = apply_filters('yith_wcwl_product_already_in_wishlist_message', get_option('yith_wcwl_already_in_wishlist_text')); $type_msg = 'error'; } else { $message = apply_filters('yith_wcwl_product_removed_text', __('An error as occurred.', 'yit')); $type_msg = 'error'; } $wishlist_token = isset($this->details['wishlist_token']) ? $this->details['wishlist_token'] : false; $atts = array('wishlist_id' => $wishlist_token); if (isset($this->details['pagination'])) { $atts['pagination'] = $this->details['pagination']; } if (isset($this->details['per_page'])) { $atts['per_page'] = $this->details['per_page']; } ob_start(); wc_add_notice($message, $type_msg); echo '<div>' . YITH_WCWL_Shortcode::wishlist($atts) . '</div>'; echo ob_get_clean(); die; }
function et_wishlist_btn($label = '') { global $yith_wcwl, $product; if (!class_exists('YITH_WCWL')) { return; } return YITH_WCWL_Shortcode::add_to_wishlist(array()); $html = ''; if ($label == '') { $label = __('Add to Wishlist', ETHEME_DOMAIN); } $exists = $yith_wcwl->is_product_in_wishlist($product->id); $url = $yith_wcwl->get_wishlist_url(); $classes = 'class="add_to_wishlist"'; $html = '<div class="yith-wcwl-add-to-wishlist">'; $html .= '<div class="yith-wcwl-add-button'; // the class attribute is closed in the next row $html .= $exists ? ' hide" style="display:none;"' : ' show"'; $html .= '><a href="' . esc_url($yith_wcwl->get_addtowishlist_url()) . '" data-product-id="' . $product->id . '" ' . $classes . ' >' . $label . '</a>'; $html .= '<img src="' . esc_url(admin_url('images/wpspin_light.gif')) . '" class="ajax-loading" id="add-items-ajax-loading" alt="" width="16" height="16" style="visibility:hidden" />'; $html .= '</div>'; $html .= '<div class="yith-wcwl-wishlistaddedbrowse hide" style="display:none;"><a href="' . esc_url($url) . '">' . apply_filters('yith-wcwl-browse-wishlist-label', __('Browse Wishlist', 'yit')) . '</a></div>'; $html .= '<div class="yith-wcwl-wishlistexistsbrowse ' . ($exists ? 'show' : 'hide') . '" style="display:' . ($exists ? 'block' : 'none') . '"><a href="' . esc_url($url) . '">' . apply_filters('yith-wcwl-browse-wishlist-label', __('Browse Wishlist', 'yit')) . '</a></div>'; $html .= '<div style="clear:both"></div><div class="yith-wcwl-wishlistaddresponse"></div>'; $html .= '</div>'; return $html; }
/** * AJAX: remove from wishlist action * * @return void * @since 1.0.0 */ public function remove_from_wishlist_ajax() { $count = yith_wcwl_count_products(); $message = ''; if ($count != 0) { if ($this->remove()) { $message = apply_filters('yith_wcwl_product_removed_text', __('Product successfully removed.', 'yit')); $count--; } else { $message = apply_filters('yith_wcwl_unable_to_remove_product_message', __('Error. Unable to remove the product from the wishlist.', 'yit')); } } else { $message = apply_filters('yith_wcwl_no_product_to_remove_message', __('No products were added to the wishlist', 'yit')); } wc_add_notice($message); $atts = array(); if (isset($this->details['pagination'])) { $atts['pagination'] = $this->details['pagination']; } if (isset($this->details['per_page'])) { $atts['per_page'] = $this->details['per_page']; } echo YITH_WCWL_Shortcode::wishlist($atts); die; }
?> <div class="product-controls-wrapper" data-product-link="<?php the_permalink(); ?> "> <div class="buttons-wrapper"> <?php // woocommerce_before_shop_loop_item_title hook do_action('woocommerce_before_shop_loop_item_title'); // add to wishlist button if (class_exists('YITH_WCWL_Shortcode') && get_option('yith_wcwl_enabled') == true) { $atts = array('per_page' => 10, 'pagination' => 'no'); echo YITH_WCWL_Shortcode::add_to_wishlist($atts); } ?> <span class="product-tooltip"></span> </div> <div class="vertical-helper"></div> </div> </div><!-- .animation-section ends --> <div class="product-description-wrapper">