This topic has 6 replies, 3 voices, and was last updated 6 months, 4 weeks ago ago by Andrew Mitchell
Hello support,
I disabled “Ajax add to cart” for variable products in the theme options in order to use a third party plugin and it is working very well.
But I still would like to keep the ajax add to cart option only for variable products which have a specific category which in my case is “Collection voyage” (category with ID 64).
Can you help me on doing this please?
Thanks in advance,
Lucas
Hi @Lucas,
To remove the AJAX ADD TO CART scripts, please add the following code under functions.php file locates in your child theme:
add_action( 'wp_enqueue_scripts', 'n2t_theme_enqueue_styles', 1001 );
function n2t_theme_enqueue_styles() {
if( has_term( array( 'vases' ), 'product_cat' ) ) {
wp_dequeue_script('etheme_spv_ajax_add_to_cart');
}
}
Replace the vases slug, with your Collection voyage category slug, we guess it might be: collection-voyage.
Hope it helps!
Hello Luca,
Sorry it is not working, the page is still reloading when I add to cart the product in category collection-voyage from the product single page. I would like it to behave like this : (see screenshot attached) where I can see the popup open without the page reloading.
Thanks,
Lucas
Hi @Lucas,
I disabled “Ajax add to cart” for variable products in the theme options in order to use a third party plugin and it is working very well.
In this case, please enable this option again.
After that, update the code to this:
add_action( 'wp_enqueue_scripts', 'n2t_theme_enqueue_styles', 1001 );
function n2t_theme_enqueue_styles() {
if( !has_term( array( 'collection-voyage' ), 'product_cat' ) ) {
wp_dequeue_script('etheme_spv_ajax_add_to_cart');
}
}
Please note that the codes above will disable the AJAX add to cart on single product page only.
Hope it helps!
Hi @Luca Rossi,
Excellent, this works very well !
Thanks again,
Lucas
Dear Lucas,
We hope you’re reveling in the experience our theme brings! Your enthusiasm is what fuels our passion. Would you be so kind as to channel that energy into a 5-star rating on ThemeForest? Your feedback is the spark that lights our way!
Click here to spread the love: https://themeforest.net/downloads
Thank you for being an integral part of our journey!
Best Regards,
The 8Theme Team
The issue related to '‘Enable ajax add to cart for variable products with a specific category’' has been successfully resolved, and the topic is now closed for further responses