Created
July 7, 2016 20:09
-
-
Save renancmfreitas/26bc49cacb00ba03288b10dba81b0a06 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
/** | |
* Auto reduce WooCommerce order stock at checkout. | |
* Add to theme functions.php file | |
*/ | |
add_action( 'woocommerce_thankyou', 'woocommerce_reduce_order_stock' ); | |
function woocommerce_reduce_order_stock( $order_id ) { | |
global $woocommerce; | |
if ( !$order_id ) | |
return; | |
$order = new WC_Order( $order_id ); | |
$order->reduce_order_stock(); | |
} | |
add_filter( 'woocommerce_payment_complete_reduce_order_stock', '__return_false' ); /** reduce stock just once */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment