• When I add an item to my cart on a single product page I was once able to see the standard “Added to cart/ View cart” message. After upgrading all those messages now appear on the cart page. So if I add 3 different items to my cart and I go to view my cart I’ll see 3 different success messages stacked on top of one another. (see attached images below)

    Is this a setting in the admin panel I’m missing? I’m the developer for this site and it’s a custom theme. If I remember correctly, I had this problem when I first built the site, but I can’t quite remember how it was resolved.

    Any insight or direction would be greatly appreciated! Thanks in advance!

    Website: https://shaydesigns.com/
    Expected result: https://imgur.com/5ide2lw
    Actual result: https://imgur.com/lsHWAOS

    https://www.ads-software.com/plugins/woocommerce/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor Mike Jolley

    (@mikejolley)

    On your single page, usually there would be a call to show notices. Your theme may be missing this call.

    woocommerce_before_single_product is the hook we use, wc_print_notices is the function.

    Hi Coreybruyere,
    Please let me know,How you solve this issue .I have same problem .
    Thanks,
    Taha

    @tahafarooqui
    For example, with the Avada theme you can use:

    <?php
      // show "product xyz has been added to your cart" woocommerce notices
      add_action( 'avada_before_main', 'wc_print_notices', 10 );
    

    For other themes you will need to see your theme documentation to find the hooks they use. Alternatively, you can install the free hookr plugin. Once activated, bring up a product page and hookr will show you which hooks are firing near the top of the page.

    Your snippet can go in functions.php for your child theme or you can use the “My Custom Functions” plugin.

    Hi @lorro ,

    I already found the solution.

    Added this code in Functions.php file :

    		add_filter( 'display_woo_cart_notice', 'woo_cart_notice' );
    function woo_cart_notice() {
    	
    		foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
    			$product_id = apply_filters( 'woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key );
    			
    			wc_add_to_cart_message( $product_id );
    			
    		}
    }

    Put this code ,Where you want to display notice.

    do_action( 'display_woo_cart_notice' );

    • This reply was modified 7 years, 11 months ago by tahafarooqui.
    • This reply was modified 7 years, 11 months ago by tahafarooqui.
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Added to cart success notice showing on cart page instead of single product page’ is closed to new replies.