Created
November 12, 2015 17:16
-
-
Save bentasm1/9167fc3f6433e02cddcf to your computer and use it in GitHub Desktop.
WC Vendors Pro -- Change defaults for Stock Management / Quantity / Sold Individually
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
/* Credit to @criticalachievement */ | |
// Changes the default value for manage stock checkbox to checked | |
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; | |
} | |
// Changes the default value for sold individually checkbox to 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; | |
} | |
// Changes the default value for stock qty to 99 | |
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'] = '99'; // This sets the quantity | |
return $field; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment