Created
June 6, 2014 05:32
-
-
Save rayflores/c1d03823e4f4f8860f9e to your computer and use it in GitHub Desktop.
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 | |
/** | |
* Redirect directly to checkout page only for ONE product | |
* if cart contains $product_id then go directly to checkout. | |
**/ | |
add_filter ('add_to_cart_redirect', 'redirect_to_checkout'); | |
function redirect_to_checkout() { | |
global $woocommerce; | |
//Get product ID | |
$product_id = apply_filters( 'woocommerce_add_to_cart_product_id', absint( $_REQUEST['add-to-cart'] ) ); | |
//Check if product ID is in a certain taxonomy | |
if( $product_id = 6319){ | |
//Get cart URL | |
$checkout_url = get_permalink(get_option('woocommerce_checkout_page_id')); | |
//Return the new URL | |
return $checkout_url; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment