Display minimum quantity price on product page

  • Posts: 11
  • Thank you received: 0
13 years 1 week ago #30374

Hi,

I have a product with variants that have different unit prices. There is a minimum order quantity of 50 units. Is there an easy way to display the minimum order price on the product page so that it displays, for example, "From £5.00 (Min order 50 units)". The displayed price would be unit price multiplied by minimum quantity.

I can see that this is possible by changing the code in the listing_price view but the problem is that when the user selects a new variant, the javascript onChange() function replaces the displayed price with the unit price! Where can this be changed (or is there a better way?)

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

  • Posts: 82906
  • Thank you received: 13378
  • MODERATOR
13 years 1 week ago #30396

Hi,

You should indeed do the modification in that listing_price view file. This file is used for both the default price and all the other variants prices so if you modify it properly you won't have that problem.

If you don't want that the price changes when the variant changes, you can just remove the block below in the "show" file of the product view:
<div id="hikashop_product_price_<?php echo $variant_name;?>" style="display:none;">
<?php

if($this->params->get('show_price')){
$this->row =& $variant;
$this->setLayout('listing_price');
echo $this->loadTemplate();
}
?>
</div>

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

  • Posts: 11
  • Thank you received: 0
13 years 1 week ago #30466

Thank you Nicholas.

However, I have encountered two problems.

First, although the minimum quantity is available on the default variant, it is always zero for subsequent variants. This means that when the user selects the second variant from the drop-down box, the price changes to zero (or you can use the max() function to at least get the unit price:
if($this->params->get('price_with_tax')){
echo $this->currencyHelper->format(max($price->price_value_with_tax,$price->price_value_with_tax*$price->price_min_quantity),$price->price_currency_id);
}

I even tried setting minimum order value on the variant but it is still zero in the view.

The second problem is that the mini-cart uses the same 'listing_price' code so price shown in the cart is multiplied again (because it thinks the unit price is (unit price x min quantity)).

John.

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

  • Posts: 82906
  • Thank you received: 13378
  • MODERATOR
13 years 1 week ago #30481

I'm not sure I understand the problem on your first point. Unit prices and minimum quantities setup in variants should be loaded for each variants.

fir your second point, that's indeed the case and you avoid that you could simply use such check:

if(JRequest::getVar('hikashop_front_end_main',0)){
//listings and product pages
}else{
//cart module
}

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

  • Posts: 11
  • Thank you received: 0
13 years 1 week ago #30617

Thanks again Nicolas. First problem was due to bad config on variant - sorry.

Second problem solved with your suggested code.

John.

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

Time to create page: 0.062 seconds
Powered by Kunena Forum