Created
February 28, 2013 08:37
-
-
Save kloon/5055229 to your computer and use it in GitHub Desktop.
WooCommerce redirect subscription add to cart to checkout page
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
<?php | |
add_filter('add_to_cart_redirect', 'custom_add_to_cart_redirect'); | |
function custom_add_to_cart_redirect( $url ) { | |
$product_id = (int) $_REQUEST['add-to-cart']; | |
if ( class_exists( 'WC_Subscriptions_Product' ) ) { | |
if ( WC_Subscriptions_Product::is_subscription( $product_id ) ) { | |
return get_permalink(get_option( 'woocommerce_checkout_page_id' ) ); | |
} else return $url; | |
} else return $url; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment