Multi Vendor Marketplace Plugin | WCFM Marketplace › Forums › WCFM – Marketplace (WooCommerce Multivendor Marketplace) › I need manage stock enabled with 1 quantity by default.
- This topic has 6 replies, 3 voices, and was last updated 5 years, 4 months ago by WCFM Forum.
- AuthorPosts
- June 21, 2019 at 7:39 am #68846ing.rappariniParticipant
When a vendor put on sale a new product, I need manage stock enabled with 1 quantity by default.
Line to add???
Thanks
Attachments:
You must be logged in to view attached files. - June 22, 2019 at 5:46 am #69018WCFM ForumMember
Hi,
Please add this code to your child theme’s functions.php –
add_filter( 'wcfm_product_fields_stock', function( $stock_fields, $product_id, $product_type ) { if( !$product_id ) { if( isset( $stock_fields['stock_qty'] ) ) { $stock_fields['stock_qty']['value'] = 1; } } return $stock_fields; }, 50, 3 );
Thank You
- June 25, 2019 at 9:29 am #69485ing.rappariniParticipant
DOES NOT WORK
- June 25, 2019 at 9:32 pm #69659kaloomeeParticipant
Worked for me, Thank you
When vendor creates new product then the default qty is now 1 instead of 0 - June 26, 2019 at 4:37 pm #69825WCFM ForumMember
Great … you are welcome 🙂
- June 28, 2019 at 8:07 am #70095ing.rappariniParticipant
ok…I just add also this to enable stock by default…
add_filter( ‘wcfm_product_fields_stock’, function( $stock_fields, $product_id, $product_type ) {
if( isset( $stock_fields[‘manage_stock’] ) ) {
$stock_fields[‘manage_stock’][‘dfvalue’] = ‘enable’;
}
return $stock_fields;
}, 50, 3 ); - June 29, 2019 at 5:14 pm #70268WCFM ForumMember
This code is fine.
- AuthorPosts
- You must be logged in to reply to this topic.