Hi,
When a shop product is added to cart it displays automatically a button ‘view cart’.
I would like to have another button (to the left of the existing) with a link to shop – ‘back to shop’.elp
I appreciate your help
Kind Regards
Hey Elsa!
Thank you for using our theme.
In the file plugins\woocommerce\includes\wc-cart-functions.php line 66 – 88 you find the function wc_add_to_cart_message.
At the end you find a call to the filter ‘wc_add_to_cart_message’:
wc_add_notice( apply_filters( 'wc_add_to_cart_message', $message, $product_id ) );
Use this filter to add your button in $message.
Cheers!
Günter
Hi Günter,
Thanks for the reply.
I appreciate your tip, however with my basic knowledge of wordpress I limit myself only to look at the code without knowing what to do with it. :)
Hi!
Thank you for coming back.
Please add following code to Functions.php file of your child theme (or parent theme, if not using a child theme)- you can use Dashboard -> Appearance > Editor:
add_filter( 'wc_add_to_cart_message', 'my_wc_add_to_cart_message', 10, 2);
function my_wc_add_to_cart_message( $message, $product_id )
{
$message .= sprintf( '<a href="%s" class="button wc-forward my-button">%s</a>', esc_url( wc_get_page_permalink( 'shop' ) ), esc_html__( 'Back to shop', 'woocommerce' ) );
return $message;
}
In custom.css or Enfold -> General Styling -> Quick CSS field (or when using a child theme: in styles.css of the child theme or Enfold-Child -> General Styling -> Quick CSS field) put the following and adjust the values as needed:
a.my-button{
right: 250px !important;
}
Regards,
Günter
Hi Günter,
Stupendous!
Thanks for your help.
Have a great day.
Elsa Soares