Plugin Author
nmerii
(@nmerii)
After the add to cart action, this fires:
$(document.body).trigger('nmgr_add_to_cart_response', response);
So you can use the nmgr_add_to_cart_response event which is triggered on the document.body.
Thank you nmerii for your response. The event is triggering and works good!
One last querstion. During “Add to cart” i am using “woocommerce_add_to_cart_validation” filter and on my case i don’t allow wishlist item to be added to cart, so i return wc_add_notice(‘Custom Error.’).
add_filter( ‘woocommerce_add_to_cart_validation’, function($passed, $product_id, $quantity){
$custom_logic = true;
if($custom_logic) {
wc_add_notice( __(‘Custom Error.’, ‘woo’ ), ‘error’ );
return false;
}
return $passed;
}, 10, 3 );
On “nmgr_add_to_cart_response” response object, i don’t see that error message to display it on my custom header info. The response.fragments.notice is undefined.
Plugin Author
nmerii
(@nmerii)
I tried your custom validation code and it worked. You can access the notice property from the response object as response.notice.
The plugin however displays all notices automatically within the div.woocommerce on the page so it should display your custom error notice for you. So you should take this into account if you want to display the error notice by yourself, perhaps in a different way.
Thank you. It works fine!
-
This reply was modified 4 years, 4 months ago by
stefan0s.
-
This reply was modified 4 years, 4 months ago by
stefan0s.