Multiple quantities not working

  • Posts: 5
  • Thank you received: 1
4 years 9 months ago #319750

-- HikaShop version -- : 4.3.0
-- Joomla version -- : 3.9.14
-- PHP version -- : 7.2.1
-- Browser(s) name and version -- : multiple
-- Error-message(debug-mod must be tuned on) -- : none

On our Wine shop, we want to have different options for the quantity input.

For most products, we want the quantity to default to 6 bottles, but customers can buy in smaller increments.
Some products are sold per piece. Others are sold per x pieces.

For the products sold per x, we use the min_quantity field combined with the show_select view
For the first case, we wrote a small customisation below in show_quantity.php using a custom field dflt_qty

This worked fine until recently, but since the latest updates:
- the system no longer seems to read our dflt_qty field (it defaults all products to 6 pieces even if dflt_qty > 0).
- when setting min_quantity the initial quantity is set, but the increment remains 1. For instance: if min_quantity is set to 4 and I hit the "+" button, the quantity will jump to 5 instead of 8.

When adding the field "dflt_qty" to the front end the value in the database displays correctly so nothing wrong there.

Any idea what is wrong?

Customisation in show_quantity.php:
$min_quantity =$this->params->get('min_quantity');
$max_quantity =$this->params->get('max_quantity');
$html =$this->params->get('html');
$salesqty ='';
if ($min_quantity > 1){
$salesqty = $min_quantity;
}else{
if ($this->element->dflt_qty > 0){
$salesqty = $this->element->dflt_qty;
}else{
$salesqty = 6;}
}

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

  • Posts: 83409
  • Thank you received: 13502
  • MODERATOR
4 years 9 months ago #319788

Hi,

This indicates that your custom code has a problem.
Either the system is using another view file or your code is missing some bits.
I would recommend to check the HTML of the quantity input field:
monosnap.com/file/PkHAF4NTuZR7bJghwLzvimB05IegQ7
There, you'll see extra "data" attributes where we have the minimum, the maximum and the increment (mod). The javascript then relies on these for the behavior of the quantity input field.
What you describe indicates that these data attributes don't have the values they should have if your customization was working.
So then check your code so that these data attributes are properly set.
And use the "Display view files" setting to make sure you're editing the correct view file.

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

  • Posts: 5
  • Thank you received: 1
4 years 9 months ago #319817

Hi Nicolas

I'd checked all that before logging the ticket, obviously. As such, the code works fine but for some reason a number of values no longer seems to be passing and I can't find out why. I checked this by echoing the given field values, which return blanks.

$this->element->dflt_qty ==> no longer retrieves the custom field value stored in "dflt_qty" (returns a blank if you try to echo it)

In the original code (version 4.3.0, view show_quantity), your code to choose the quantity layout per product is:
if(!isset($this->quantityLayout)) {
$quantityLayout = $this->config->get('product_quantity_display', 'show_default_div');
if(!isset($this->row))
$quantityLayout = $this->getProductQuantityLayout($this->row);
} else
$quantityLayout = $this->quantityLayout;


If I set the quantity layout at product level, however, this value (bold) does not pass either. The system always seems to pick up the quantity layout from the configuration file, not from the product settings.

Any idea why these values are not passing?

Attachments:

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

  • Posts: 83409
  • Thank you received: 13502
  • MODERATOR
4 years 9 months ago #319841

Hi,

I'm not able to reproduce any problem with the selection of the product page layout on my end.
But let's not drift and focus on your issue.
Does your product has variants ? If yes, then $this->element->dflt_qty is the value of the custom field in the default variant.
And the value you want (from the main product) is in $this->element->main->dflt_qty
Maybe that's why it doesn't work like you want ?
Besides that, I don't see the reason why the custom field value wouldn't in there.

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

Time to create page: 0.059 seconds
Powered by Kunena Forum