-
AuthorPosts
-
June 5, 2020 at 12:54 am #1219644
Hello,
I want to use the WooCommerce
[add_to_cart id="18426"]
short code on one of my pages.The product adds to the cart correctly, however the notice next to the cart icon is appearing with a blank product title. It should say “Product XXX” has been added to the cart. Instead it says “” has been added to the cart.
When you view the /shop page all the add to cart notices work fine. I want the button to use AJAX and not redirect to the cart.
Is there any way to fix this? Or can you shed any light as to how I can correctly get an add to cart button for a product without this issue?
I’ve attached in the private content field a link to a staging site with the link to page with the add to cart shortcode so you can have a look and see the issue.
Any help would be greatly appreciated!
Thanks! :)June 8, 2020 at 6:51 pm #1220562Hey 110percent,
Please check WooCommerce docs here:
The cart behavior can be set here in the WooCommerce settings:
If you need further assistance please let us know.
Best regards,
VictoriaJune 9, 2020 at 3:34 pm #1220888Hi Victoria,
Thanks for getting back to me.
Currently I know how to use those shortcodes and change the cart behaviour. The issue I’m having is with the Enfold Product added to cart notice appearing blank where the product name should be when I use the [add-to-cart] shortcode. I want to use this shortcode as it brings through a simple add to cart button that uses Ajax.
Can you advise on how to correct the Enfold added to cart notice?
Thanks,
Jack- This reply was modified 4 years, 6 months ago by 110percent.
June 10, 2020 at 8:24 pm #1221386Hi Jack,
The shortcode does not render the product title and so JavaScript does not have the info to show in the product notice. The notice is also from WooCommerce.
YOu can check the html rendered by that shortcode to see where the issue lies.
Best regards,
VictoriaJune 11, 2020 at 11:56 pm #1221910Hi Victoria,
I found the solution here: https://kriesi.at/support/topic/woocommerce-product-added-to-cart-not-displaying-product-name
The changes in the other forum indicate making changes to the woocommerce-mod.js file, how can I make changes to this file in my child theme to ensure when I update Enfold that the code is not overwritten?
Thanks,
JackJune 18, 2020 at 3:55 pm #1223762Hi,
You might have to deregister the default config-woocommerce/woocommerce-mod.js file from the parent theme, create a copy of it in the child theme, add the modification and register it back using the same wp_enqueue_script function. This is how the scripts and stylesheets are registered.
function avia_woocommerce_register_assets() { wp_enqueue_style( 'avia-woocommerce-css', AVIA_BASE_URL.'config-woocommerce/woocommerce-mod.css'); if( version_compare( WC()->version, '2.7.0', '<' ) ) { wp_enqueue_script( 'avia-woocommerce-js', AVIA_BASE_URL.'config-woocommerce/woocommerce-mod-v26.js', array('jquery'), 1, true); } else { wp_enqueue_script( 'avia-woocommerce-js', AVIA_BASE_URL.'config-woocommerce/woocommerce-mod.js', array('jquery'), 1, true); } }
Best regards,
Ismael -
AuthorPosts
- You must be logged in to reply to this topic.