Skip to content

Instantly share code, notes, and snippets.

@kloon
Created February 28, 2013 08:37
Show Gist options
  • Save kloon/5055229 to your computer and use it in GitHub Desktop.
Save kloon/5055229 to your computer and use it in GitHub Desktop.
WooCommerce redirect subscription add to cart to checkout page
<?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