This topic contains 2 reply and 2 voices, and was last updated by towhid 4 years, 11 months ago
Viewing 2 Posts - 1 through 2 (of 2 total)
Author Posts
December 25, 2014 at 4:04 am 32952
towhid Hi, I'm using dokan plugin. I want to make it so when a user adds a product, stock management is turned on by default and the stock is set to 1. Can you help me do that?
December 25, 2014 at 6:37 am 32954
Stephen Stephen

I have managed to do this myself. This is how I did it:

Inside the file classes/template-shortcodes.php around line 145 just after

$post_data = apply_filters( 'dokan_insert_product_post_data', array(
      'post_type'    => 'product',
      'post_status'  => $product_status,
      'post_title'   => $post_title,
      'post_content' => $post_content,
      'post_excerpt' => $post_excerpt,
) );

$product_id = wp_insert_post( $post_data );

I have added the following code

//Set default stock to 1
update_post_meta( $product_id, '_manage_stock', 'yes'  );
update_post_meta( $product_id, '_stock', '1'  );

I hope this helps the other people trying to do this.

December 27, 2014 at 12:11 pm 32975
towhid towhid

Hello Stephen,

Very well solution. I have tested and it works for me.

Hope it will help other people if they want to.

Thank You 🙂

Viewing 2 Posts - 1 through 2 (of 2 total)