Back to shop button on all products
-
I am searching for a way to add a button to all products , maybe near the cart or so if they want to go back to the shop then can easily click it
I found two pieces of code the 1st displays but does not work when clicked and is no space between the add to cart button and return to shop
// add the filter add_filter( 'wc_add_to_cart_message_html', 'filter_wc_add_to_cart_message_html', 10, 2 ); add_action( 'woocommerce_after_add_to_cart_button', 'my_function_sample', 10 ); function my_function_sample() { global $product; echo ' <button type="button" onclick="https://starpaint.de/shop-products/"> Zum allen Produkte </button> '; }
the second code did not work at all
// define the wc_add_to_cart_message_html callback function filter_wc_add_to_cart_message_html( $message, $products ) { $prev_url = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''; $message .= sprintf( '<a href="%s" class="button">%s</a>', $prev_url, esc_html__( 'Zurück zum Shop', 'woocommerce' ) ); return $message; };
can you please help me ? thanks
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Back to shop button on all products’ is closed to new replies.