We're building a webshop with a lot of custom code added and hooked on WooCommerce.
On the single product page, we have ofcourse the add-to-cart button, which automatically redirects to the cart page.
Underneath the add-to-cart button, we've added a button to add the product to a 'quotation'. I general, this button has to exactly copy the Add-to-cart button functions, but in stead of redirecting to the Cart page, it has to redirect to a custom page.
There is this code to change the redirect url when adding a product in your cart, but that's not enough.
function my_custom_add_to_cart_redirect( $url ) {
$url = get_permalink( 1 ); // URL to redirect to (1 is the page ID here)
return $url;
}
add_filter( 'woocommerce_add_to_cart_redirect', 'my_custom_add_to_cart_redirect' );
When clicking on the add to cart button -> Cart page
When clicking on the add to quote button -> Custom page
Is there any possibility to 'copy' the functionalities from the Add-to-cart button, but change the redirect that's happening afterwards?
NOTE: We hooked on a few WooCommerce functions like adding Cart Item Data, so all of these have to be 'copied' as well.