Created
September 19, 2018 02:24
-
-
Save fervous/573cfedfa88334f5f4a8353050dd9ff4 to your computer and use it in GitHub Desktop.
WC Vendors default manage stock, one-of-a-kind / only one in stock, sold out on purchase
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
// Default value for manage stock? = yes | |
add_filter( 'wcv_product_manage_stock', 'change_default_manage_stock' ); | |
function change_default_manage_stock() { | |
$field['post_id'] = $post_id; | |
$field['id'] = '_manage_stock'; | |
$field['wrapper_class'] = 'show_if_simple show_if_variable'; | |
$field['label'] = __( 'Manage stock?', 'wcvendors-pro' ); | |
$field['description'] = __( 'Enable stock management at product level', 'wcvendors-pro' ); | |
$field['type'] = 'checkbox'; | |
$field['value'] = 'yes'; // This checks the checkbox | |
return $field; | |
} | |
// Default value for sold individually = checked | |
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; | |
} | |
// 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 to one | |
return $field; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment