0

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

2 Answers 2

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!!!

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/

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.