Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1373303
    194roc
    Participant

    Home


    WP 4.7.2
    renew child xtheme 4.6.4

    Hello there,

    how could I add a “back to shop” link when a product has been added to the cart ?
    Here following a screenshot where, I believe the link should be inserted.

    http://prntscr.com/e9eo3c

    Thank you very much for your help.

    Best regards,

    Roberto

    #1373306
    194roc
    Participant
    This reply has been marked as private.
    #1373599
    Lely
    Moderator

    Hello Roberto,

    Thank you for your credentials. Please add the following code on your child theme functions.php file:

    add_filter( 'wc_add_to_cart_message', 'custom_add_to_cart_message' );
    function custom_add_to_cart_message($products, $show_qty = false) {
        global $woocommerce;
        // Output success messages
        if (get_option('woocommerce_cart_redirect_after_add')=='yes') :
            $return_to  = get_permalink(woocommerce_get_page_id('shop'));
            $message    = sprintf('<a href="%s" class="button">%s</a> %s', $return_to, __('Continue Shopping &rarr;', 'woocommerce'), __('Product successfully added to your cart.', 'woocommerce') );
    
        else :
            $message    = sprintf('<a href="%s" class="button">%s</a> %s', get_permalink(woocommerce_get_page_id('cart')), __('View Cart', 'woocommerce'), __('Product successfully added to your cart.', 'woocommerce') );
            $message    .= '<a href="'.$return_to.'" class="button">Torna al negozio</a>';
    
        endif;
            return $message;
    }

    Feel free to adjust the messages.
    Further customizations from here would be getting into custom development, which is outside the scope of support we can offer. If you need more in depth changes, you may wish to consult with a developer. X is quite extensible with child themes, so there are plenty of possibilities. Thanks for understanding.

    #1374717
    194roc
    Participant

    It works just great.

    Excellent support, thank you very much.

    Best regards,

    Roberto

    #1374846
    Paul R
    Moderator

    You’re welcome! 🙂

    #1398146
    194roc
    Participant

    Hello there,

    sorry to bother you again, but it could be possible that after adding the given code I lost some translation ?

    In the following images I am pointing to the text that I believe was in Italian before and was some thing like:
    “Articolo aggiunto al carrello.”

    http://prntscr.com/eh7poo

    Thanks for the help,

    Roberto

    #1398659
    Rupok
    Member

    Hi Roberto,

    You can write the text in your language within the code.

    Cheers!

    #1398747
    194roc
    Participant

    Sorry about the last.

    I didn’t realize that the that text was inside the given code.

    Forgive me,

    Best regards,

    Roberto

    #1398952
    Thai
    Moderator

    If you need anything else please let us know.

  • <script> jQuery(function($){ $("#no-reply-1373303 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>