I have made a "back" button on my product pages with the following code:
add_action( 'woocommerce_before_single_product', 'back_button', 10 );
function back_button() {
global $product;
echo ' <button class="product-back-button" type="button" onclick="history.back();"> << Vissza</button> ';
}
The only problem with it: when I make some action on the product page like "add to cart" and then hit the back button it just reloads the page and I need to push it again for the expected behavior.
Do you know any fix for that? Thanks!
I used
add_action( 'woocommerce_after_add_to_cart_button', 'back_button', 10 );
function back_button() {
global $product;
echo ' <a href="javascript:history.go(-1)">Go Back</a> ';
}
to place a back 1 link next to cart button. I hope this helps a bit.