Skip to content

Instantly share code, notes, and snippets.

@jrick1229
Last active November 29, 2018 16:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrick1229/c766b1d8f8f5829722dd5413a53f2476 to your computer and use it in GitHub Desktop.
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
<?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