Last active
November 25, 2018 13:00
-
-
Save mikejolley/1622409 to your computer and use it in GitHub Desktop.
WooCommerce - Set a custom add to cart URL to redirect to
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'woocommerce_add_to_cart_redirect', 'custom_add_to_cart_redirect' ); | |
function custom_add_to_cart_redirect() { | |
/** | |
* Replace with the url of your choosing | |
* e.g. return 'http://www.yourshop.com/' | |
*/ | |
return get_permalink( get_option('woocommerce_checkout_page_id') ); | |
} |
Thank you for sharing this.
if I wanted to add a product ID at the end of the URL how would I do that this is what I have done
function custom_add_to_cart_redirect() {
global $post,$product;
$id = $product->id;
$URL= "https://yahyaprints.com/product/$id";
return $URL
;
}
add_filter( 'woocommerce_add_to_cart_redirect', 'custom_add_to_cart_redirect' );
but it does not work ? can you please help me
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We should change the filter from
add_to_cart_redirect
towoocommerce_add_to_cart_redirect