Enable Manage Stock by default
Author | Posts |
---|---|
June 4, 2014 at 9:38 pm 21426 | |
Jesus | I want the stock to be equal to 1 and I was able to achieve that by replacing line 19 in inventory.php (location:dokan/templates/edit) with this line
<?php dokan_post_input_box( $post->ID, '_stock', array( 'value' => '1' ) ); ?>
The problem is that if the "Manage Stock" option is not enabled the stock quantity is ignored and you can still add more than 1 to your cart. When the stock management is enabled, and the quantity is 1, the number box, and the plus and minus sign disappear in the product page. That's how I know that the quantity is working.
So, how can I enable "Manage Stock" by default?
Thanks for all your help!
|
June 5, 2014 at 2:38 pm 21464 | |
Sk | hello Jesus, please navigate to
Thank you |
June 5, 2014 at 8:58 pm 21475 | |
Jesus | I replaced line 12, and now, after submitting a new product, the stock management box is checked and the stock quantity is equal to 1. Unfortunately, I can still select more than 1 when adding the item to the cart. There must be something that sets the stock quantity value and the stock management value by default when creating the product. The solution above only makes it appear as if there is 1 in stock and stock management option enabled, but the actual values are set differently for the product when it’s created. Where can we find and edit those default values? Thanks! |
June 6, 2014 at 10:04 pm 21530 | |
Jesus | I was able to resolve this. I don’t know if this is the correct way of doing it or if there’s an easier way, but here’s what I did: After this line (line 12 in my file) then after this line (line 61 in my file) After setting the variables and the update functions I just added hidden fields for both inside the new product form. And that’s it. Doing this does the trick of setting the stock to 1 and enabling the stock management when you post a new product. |
June 7, 2014 at 2:57 pm 21570 | |
Nizam Uddin | Hello Jusus |
June 13, 2014 at 10:25 pm 21896 | |
Will | Question on this. How did you get your child theme inventory.php file to overwrite the parent file? I can’t seem to get any of the functions in my child theme to actually overwrite! |
June 14, 2014 at 10:41 pm 21926 | |
Jesus | Hi Will, Here’s your possible solution: So, open inventory.php and let’s do first the manage stock checkbox. Where it says
(this is around line 12) replace it with this:
and for the stock quantity look for a line that is similar to this: replace with this:
This should reflect the stock quantity and the manage stock option in your inventory once you edit a product or create a new one. Thanks! |
June 16, 2014 at 5:21 am 21977 | |
zayra | Its there a easy way to change it. Also to give the seller the option to put how many of their products has in stock???? 2.Also, why the link for the seller to edit the product doesnt show up? |
June 16, 2014 at 9:51 pm 22020 | |
Will | Thanks Jesus. What I realized afterwards was that I wasn’t putting the inventory.php file in the right place. I had forgotten to put it in a templates folder so it wasn’t overwritting the parent file properly. Thanks for the detailed explanation! |
June 17, 2014 at 1:30 am 22029 | |
Sk | Thanks Jesus, You are awesome. |
June 17, 2014 at 3:08 am 22031 | |
Jesus | Hi Zayra, If you want to add a stock quantity to your new product before posting it just add these input fields to the for in new-product.php (Location:
And make sure you have manage stock field too.
|