Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save constructyourself/45f97510aeb9a0dcf66c to your computer and use it in GitHub Desktop.
Save constructyourself/45f97510aeb9a0dcf66c to your computer and use it in GitHub Desktop.
WooCommerce - add product and show checkout
<?
/*
Wordpress + WooCommerce
Add product directly to cart and take user to Checkout page
Instructions:
- add all php code within comment block below to active Wordpress theme file: functions.php
- use URL structure: http://your-site.com/?add-to-cart=37 WHERE 37 is the ID of your WooCommerce Product
*/
/*
add everything within this comment to your Wordpress theme functions.php
*/
add_filter ('woocommerce_add_to_cart_redirect', 'woo_redirect_to_checkout');
function woo_redirect_to_checkout() {
$checkout_url = WC()->cart->get_checkout_url();
return $checkout_url;
}
/*
END - direct checkout of product in cart
*/
/*
original source: http://www.remicorson.com/woocommerce-skip-product-cart-pages/
THANKS!
*/
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment