/** * 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; }
/** * 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; }