Last active
September 11, 2020 05:48
-
-
Save MarkKevin08/dfef21f6ac4db48be68e85795d42ddce to your computer and use it in GitHub Desktop.
//inventory management default to managed and only 1 stock
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
add_filter( 'wcv_product_sold_individually', 'change_default_sold_individually' ); | |
function change_default_sold_individually() { | |
$field['post_id'] = $post_id; | |
$field['id'] = '_sold_individually'; | |
$field['wrapper_class'] = 'show_if_simple show_if_variable'; | |
$field['label'] = __( 'Sold Individually', 'wcvendors-pro' ); | |
$field['desc_tip'] = 'true'; | |
$field['description'] = __( 'Enable this to only allow one of this item to be bought in a single order', 'wcvendors-pro' ); | |
$field['type'] = 'checkbox'; | |
$field['value'] = 'yes'; // This checks the checkbox | |
return $field; | |
} | |
// Changes the default value for stock qty to 1 | |
add_filter( 'wcv_product_stock_qty', 'change_default_stock_qty' ); | |
function change_default_stock_qty() { | |
$field['post_id'] = $post_id; | |
$field['id'] = '_stock'; | |
$field['label'] = __( 'Stock Qty', 'wcvendors-pro' ); | |
$field['wrapper_start'] = '<div class="all-100">'; | |
$field['wrapper_end'] = '</div>'; | |
$field['desc_tip'] = 'true'; | |
$field['description'] = __( 'Stock quantity.', 'wcvendors-pro' ); | |
$field['type'] = 'number'; | |
$field['data_type'] = 'stock'; | |
$field['custom_attributes']['step'] = 'any'; | |
$field['value'] = '1'; // This sets the quantity | |
return $field; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment