Last active
November 29, 2018 16:51
-
-
Save jrick1229/c766b1d8f8f5829722dd5413a53f2476 to your computer and use it in GitHub Desktop.
Redirect customer to cart page when 'Mixed Checkout' is enabled and product is added to cart
This file contains hidden or 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
<?php | |
function wcs_redirect_to_cart( $url ) { | |
// If product is of the subscription type | |
if ( is_numeric( $_REQUEST['add-to-cart'] ) && WC_Subscriptions_Product::is_subscription( (int) $_REQUEST['add-to-cart'] ) ) { | |
// Redirect to cart instead | |
$url = WC()->cart->get_cart_url(); | |
} | |
return $url; | |
} | |
add_filter( 'woocommerce_add_to_cart_redirect', 'wcs_redirect_to_cart', 20 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment