wcfm-santa

Celebrate Poila Baisakh with upto 25% off - A Fresh Start, A Great Deal!

Claim Offer
00Day 01Hrs 07Min 39Sec
wcfm-santa

I need manage stock enabled with 1 quantity by default.

We're shifting our Forum based support to a more dedicated support system!

We'll be closing our Forum support from 10th June, 2020 and move to Email Support assistance.

  • If you are a WCFM premium add-ons user, contact us- here
  • Want to know more before buying our add-ons? Send Pre sale queries- here
  • If you are a WCFM free user, please open a support ticket at WordPress.org
  • For WCFM App related queries, reach us- here
From now the forum will be read-only!

Viewing 6 reply threads
  • Author
    Posts
    • #68846
      ing.rapparini
      Participant

      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.
    • #69018
      WCFM Forum
      Keymaster

      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

    • #69485
      ing.rapparini
      Participant

      DOES NOT WORK

    • #69659
      kaloomee
      Participant

      Worked for me, Thank you
      When vendor creates new product then the default qty is now 1 instead of 0

    • #69825
      WCFM Forum
      Keymaster

      Great … you are welcome 🙂

    • #70095
      ing.rapparini
      Participant

      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 );

    • #70268
      WCFM Forum
      Keymaster

      This code is fine.

Viewing 6 reply threads
  • You must be logged in to reply to this topic.