Reputation: 619
i am using following code for Woocommerce Product publish, update hook and it's work perfect for me :
add_filter( 'wp_insert_post_data' , 'filter_post_data' , '99', 2 );
function filter_post_data( $data , $postarr ) {
$sum = $_POST['wpcf']['ptchq'] + $_POST['wpcf']['monivong'];
$_POST['_stock'] = $sum;
return $data;
}
i am add two custom text field and add that field sum in product stock quantity in admin side.
Now my question is that how can i get after order complete reduce stock quantity action hook. so using that hook i can reduce stock in my custom field in admin side product.
Thanks, Ketan.
Upvotes: 1
Views: 4938
Reputation: 26319
The hook that runs when stock is changed is
do_action( 'woocommerce_product_set_stock', $this );
You can see it in the Product Abstract
Upvotes: 1