Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #652422

    Hello I have the following problem:

    I have inserted a shortcode [add_to_cart id=”99″] on to a page and when clicked it adds the correct product to the cart BUT there is a little notification pop up that shows when this button is clicked that is supposed to say ” ‘Product Name’ has been added to cart ” and on all browsers except Chrome is shows ” ” has been added to cart”.

    If this is an easy fix then that would be great, if not, I would like to know how to hide this pop-up element preferably using css so that it’s not an issue.

    I have gone to Woocommerce support and they gave me some code to change the message to simply say “added to cart” and not show the name of the product which is a perfectly fine adjustment but it did not work.

    /**
     * Custom Add to cart message
     */
    
    add_filter( 'wc_add_to_cart_message', 'bbloomer_custom_add_to_cart_message' );
    
    function bbloomer_custom_add_to_cart_message() {
    
        global $woocommerce;
        $return_to  = get_permalink(woocommerce_get_page_id('shop'));
        $message    = sprintf('<a href="%s" class="button wc-forwards">%s</a> %s', $return_to, __('Continue Shopping', 'woocommerce'), __('Product successfully added to your cart.', 'woocommerce') );
        return $message;
    }

    They said since I am using a theme that is not Twenty Fifteen that they can’t help me as they said the code they gave worked for them and it must be a theme issue.

    Can you please help me either fix the blank pop up, change it to just say “add to cart” without mentioning the product name OR hide the pop up completely (if possible having it say ‘added to cart’ somewhere else maybe).

    I have added a screenshot of the problem:

    https://postimg.org/image/sg6h5f707/

    • This topic was modified 7 years, 9 months ago by Yigit.
    #653307

    Hey Bcunningham!

    Thank you for using Enfold.

    Where did you add the add to cart shortcode? Are there multiple buttons in one page? If not, try to wrap the shortcode inside a container like this:

    <div class="product">
    <div class="inner_product_header">
    <h3 style="display: none;">Product Name</h3>
    [add_to_cart id="64"]
    </div>
    </div>

    Edit the config-woocommerce > woocommerce-mod.js file, look for this code around line 108:

    		var productContainer = jQuery(this).parents('.product').eq(0), product = {};
    

    .. replace it with:

    		var productContainer = jQuery(this).parents('.product').not('.add_to_cart_inline').eq(0), product = {};
    

    The script will fetch the text inside the h3 tag:

    <h3 style="display: none;">Product Name</h3>
    

    Cheers!
    Ismael

    #654060

    You guys have the best support ever.
    That worked perfectly.

    Thank you :)
    You can close this thread.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Woocommerce " 'product' added to cart' not displaying product name’ is closed to new replies.