Last active
June 7, 2016 15:23
-
-
Save pablo-sg-pacheco/9d45b3cbbb45927a78b366385ba91b9a to your computer and use it in GitHub Desktop.
Woocommerce - Reduz o estoque quando o pedido eh criado. Tem q ser usado com o plugin (https://wordpress.org/plugins/woocommerce-auto-restore-stock/).OBS: Só funciona corretamente com o Pagseguro. Outras formas de pagamento vão baixar o estoque 2 vezes
This file contains hidden or 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 | |
//Reduz o estoque quando o pedido eh criado | |
//Tem q ser usado com o plugin (https://wordpress.org/plugins/woocommerce-auto-restore-stock/) | |
//Lembrando que so vai funcionar corretamente com o pagseguro | |
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' ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment