How to Change Default Quantity from unlimited to 1

  • Posts: 4
  • Thank you received: 1
3 years 3 days ago #338006

-- HikaShop version -- : 4.4.4
-- Joomla version -- : 3.10.4
-- PHP version -- : 7.4.26

I have seen various forum posts along similar lines, but have been unable to establish how to set the default quantity number when adding new products.

The site is for antiques, and typically all products are in limited quantities, almost exclusively 1 of each.

How can we set the default quantity to 1?

Thanks

Please Log in or Create an account to join the conversation.

  • Posts: 4760
  • Thank you received: 647
  • MODERATOR
3 years 2 days ago #338018

Hello,

We aren't sure to understand your needs well, and so 2 answers :
1. You want define a limited quantities per product :
=> From Main HikaShop Configuration => Products dropdown, select Products, then click the product name to edit.


OR
2. You want to limit the quantity added per cart/order for all (or specific product) :
=> From Main HikaShop Configuration => Products dropdown, select Limit, then click the product name to edit.
See this tutorial to learn more about the limit feature


Hope this will help you to achieved what you need.
Regards

Last edit: 3 years 2 days ago by Philip.

Please Log in or Create an account to join the conversation.

  • Posts: 4
  • Thank you received: 1
3 years 1 day ago #338043

We would like the default value for quantity to = 1 when creating a New Product.

Currently the default value is Unlimited, which if the user fails to change when creating a new product will cause a problem as there will always only be one item for sale.

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 83007
  • Thank you received: 13398
  • MODERATOR
3 years 1 day ago #338044

Hi,

You can edit the file product / form.php via the menu Display>Views.
There, at the beginning, you can add that code:

<?php if(empty($this->product->product_id)) $this->product->product_quantity = 1; ?>

Please Log in or Create an account to join the conversation.

  • Posts: 4
  • Thank you received: 1
3 years 1 day ago #338056

Perfect, thankyou.

The following user(s) said Thank You: Philip

Please Log in or Create an account to join the conversation.

  • Posts: 17
  • Thank you received: 0
5 months 6 days ago #362027

very nice,
also can you tell me same code for new variants quantity?

Please Log in or Create an account to join the conversation.

  • Posts: 83007
  • Thank you received: 13398
  • MODERATOR
5 months 6 days ago #362034

Hi,

For the variants, first, please note that if you leave their stock to "unlimited", the variants will automatically share the stock of the main product. So you might actually not need to do anything.

Also, the variants are generated automatically when you use the "add variants" button of the product edit interface.
And HikaShop will let MySQL set the default product_quantity based on the default value of that column in the database.
So if you want to change the default from unlimited to another value for variants, you can go in your PHPMyAdmin (access provided by your hosting), open the structure of the hikashop_product table, and edit the column product_quantity. There, change the default from -1 to the value you want and save.

The following user(s) said Thank You: HadiTak

Please Log in or Create an account to join the conversation.

Time to create page: 0.091 seconds
Powered by Kunena Forum