Hi I want to change the "add to cart" button url on my single product page so when we click it , the button will redirect to another website (amazon). Ps. im not a coder but simple code might work for me
Asked
Active
Viewed 1,291 times
2 Answers
2
As Mentioned the description, you want to redirect to different page after the add to cart action.
So, You can put the below code in functions.php file
function redirect_after_add_to_cart( $url ) {
return esc_url( get_permalink( get_page_by_title( 'Your Page Title' ) ) );
}
add_filter( 'woocommerce_add_to_cart_redirect', 'redirect_after_add_to_cart', 99 );
Thanks!!!

Priyanka Modi
- 1,594
- 1
- 8
- 14
0
Woocommerce works with a hook system, you can redirect the URL of your add to cart button with a php shortcode but, you can also use the plugin: Woocommerce Add to cart custom redirect. The best way for you if you don't know how to use php shortcode :)
link : https://fr.wordpress.org/plugins/woocommerce-add-to-cart-custom-redirect/

Titouan Thd
- 303
- 2
- 8