Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Giannisduke/d2189f5a67efd13c7bc1b750562aba32 to your computer and use it in GitHub Desktop.
Save Giannisduke/d2189f5a67efd13c7bc1b750562aba32 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