Quantity Dropdown to Match Quantity of Product

  • Posts: 964
  • Thank you received: 11
  • Hikashop Business
7 years 2 months ago #277901

-- HikaShop version -- : 3.1.1
-- Joomla version -- : 3.7.5

Is it possible to have the quantity dropdown display the amount of quantity available for that item?

Currently the dropdown is always showing 15. Example, if I have 3 bags, then it should only go up to 3, if I have 5 earrings then it only goes up to 5, etc...

Thanks!!

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

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
7 years 2 months ago #277902

Hello,

We would need more details about the context, the quantity layout you're using, your HikaShop configuration (legacy or not), the product you're talking about and it's settings.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

  • Posts: 964
  • Thank you received: 11
  • Hikashop Business
7 years 2 months ago #277988

your HikaShop configuration (legacy or not)

What is legacy? I assume mine is not legacy unless it was set as the default.

The product you're talking about and it's settings.

I am talking about all products that will have a dropdown. I would like the dropdown to show the quantity of that product or product option. For example, say the item below has 2 small, 3 medium, and 5 large, when the user clicks on a size the quantity of that size will show in the dropdown.

So if they click on small, it will show:
1
2

If they click on large, it will show:
1
2
3
4
5

Etc....

Attachments:

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

  • Posts: 82868
  • Thank you received: 13378
  • MODERATOR
7 years 2 months ago #277993

Hi,

Try adding the code:

if($this->row->product_quantity > 0)
		$max_quantity = min($max_quantity, $this->row->product_quantity);
before the code:
$min_quantity = max((int)$min_quantity, 1);
	$max_quantity = max((int)$max_quantity, 0);
in the file "show_quantity" via the menu Display>Views.

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

  • Posts: 964
  • Thank you received: 11
  • Hikashop Business
7 years 2 months ago #278743

Did I do something wrong because it's not working. This is what I have.

<?php
$quantity_counter = $this->getQuantityCounter();
$id = 'hikashop_product_quantity_field_'.$quantity_counter;
if($this->params->get('show_quantity_legacy', false)) {
	$i = (int)$this->params->get('i', 0);
	if($i > 0) $id = 'hikashop_product_quantity_field_'.$i;
}
$name = 'quantity';
if(!empty($this->row->quantityFieldName)){
	$name = $this->row->quantityFieldName;
}

if(isset($this->row) && isset($this->row->product_min_per_order)) {
	$min_quantity = ($this->row->product_min_per_order || empty($this->element->main)) ? $this->row->product_min_per_order : $this->element->main->product_min_per_order;
	$max_quantity = ($this->row->product_max_per_order || empty($this->element->main)) ? $this->row->product_max_per_order : $this->element->main->product_max_per_order;
if($this->row->product_quantity > 0)
	$max_quantity = min($max_quantity, $this->row->product_quantity);
	$min_quantity = max((int)$min_quantity, 1);
	$max_quantity = max((int)$max_quantity, 0);
} else {
	$min_quantity = max((int)$this->params->get('min_quantity', 0), 1);
	$max_quantity = max((int)$this->params->get('max_quantity', 0), 0);
}
Etc....

Thanks!

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

  • Posts: 82868
  • Thank you received: 13378
  • MODERATOR
7 years 2 months ago #278801

Hi,

This works fine on our end. Please provide a link to a product page with the issue and a backend access so that we can check your settings.
www.hikashop.com/support/contact-us.html

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

  • Posts: 82868
  • Thank you received: 13378
  • MODERATOR
7 years 2 months ago #278875

Hi,

Thanks for the access. I was able to find the issue. The code to use has to be a bit more complex:

if($this->row->product_quantity > 0) {
		if($max_quantity > 0)
			$max_quantity = min($max_quantity, $this->row->product_quantity);
		else
			$max_quantity = $this->row->product_quantity;
	}
I've made the change for you and it seems to be working now. It will be integrated in the next version.

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

  • Posts: 964
  • Thank you received: 11
  • Hikashop Business
7 years 2 months ago #279167

Thank you for this. Really appreciate it!!

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

Time to create page: 0.080 seconds
Powered by Kunena Forum