Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #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! :)

    #1220562

    Hey 110percent,

    Please check WooCommerce docs here:

    Shortcodes included with WooCommerce

    The cart behavior can be set here in the WooCommerce settings:
    Image 2020-06-08 at 19.51.33.png

    If you need further assistance please let us know.
    Best regards,
    Victoria

    #1220888

    Hi 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, 5 months ago by 110percent.
    #1221386

    Hi 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,
    Victoria

    #1221910

    Hi 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,
    Jack

    #1223762

    Hi,

    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

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.