Created
March 20, 2016 10:07
-
-
Save digitalchild/269018a081c9b6bc6dca to your computer and use it in GitHub Desktop.
Force stock qty to 1 with no backorders
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 | |
add_action( 'wcv_save_product_meta', 'wcv_custom_stock_opts' ); | |
function wcv_custom_stock_opts( $post_id ) { | |
update_post_meta( $post_id, '_manage_stock', 'yes' ); | |
update_post_meta( $post_id, '_backorders', 'no' ); | |
wc_update_product_stock( $post_id, wc_stock_amount( 1 ) ); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment