UPDATE:
I made it, but now I have another problem.
My Problem:
The wishlist counter does not update as well as the hearts in the products loop.
1st thing I did was to create an ajax request on the remove button click
so insted of submitting the form it’s now removes the product from wishlist by getting the button’s value( $_POST[“button”] ) to fire this php function:
function wishlistAjaxRemove() {
$wl = new TInvWL_Wishlist();
$wishlist = $wl->get_by_share_key($wl->get_sharekey());
$wlp = new TInvWL_Product($wishlist);
$products = $wlp->get_wishlist(array(
'ID' => $_POST["button"],
'count' => 100,
));
$titles = array();
foreach ($products as $product) {
if ($wlp->remove_product_from_wl($product['wishlist_id'], $product['product_id'], $product['variation_id'], $product['meta'])) {
$titles[] = sprintf(__('“%s”', 'ti-woocommerce-wishlist'), is_callable(array(
$product['data'],
'get_name'
)) ? $product['data']->get_name() : $product['data']->get_title());
}
}
return true;
wp_reset_postdata();
die();
}
then on success I made another ajax function within the main ajax function to refresh the wishlist shortcode.
function refreshWlShortcode() {
echo do_shortcode('[ti_wishlistsview]');
wp_reset_postdata();
die();
}
I guess I need to insert somthing inside refreshWlShortcode() function, I just don’t know what :/
Any help?
-
This reply was modified 2 years, 11 months ago by
meidanm95.