How to change pricing bulk discount display?

  • Posts: 13201
  • Thank you received: 2322
11 years 6 months ago #102679

Hi,

You will need something like:

$minQties = array();
foreach($this->row->prices as $priceBis){
	$minQties[] = $priceBis->price_min_quantity;
}
foreach($minQties as $key => $minQty){
	if(isset($price->price_min_quantity) && empty($this->cart_product_price) && $this->params->get('per_unit',1)){
		if($price->price_min_quantity == $minQty){
			$key++;
			echo sprintf('%s - %s off = ',$price->price_min_quantity,$minQties[$key]);
		}
	}
}
To get all the possible quantities, and display the interval.

Last edit: 11 years 6 months ago by Xavier.
The following user(s) said Thank You: lcoombes

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

  • Posts: 46
  • Thank you received: 7
11 years 5 months ago #102843

Hi Xavier

This was very helpful. I've changed the code as you suggested, just a couple of little problems. The result I have is in this format:
£ 168.00 ea
3 - 6 off = £ 160.00
6 - 10 off = £ 150.00
10 - off = £ 140.00

Can you advise how to get the first line of prices to say:
1 - 2 off = £ 168.00

And the last line of prices to say

10 + = £ 140.00

Many thanks - Leo

This is the code so far...

echo '<span class="'.implode(' ',$classes).'">';
    if(isset($price->price_min_quantity) && empty($this->cart_product_price) && $this->params->get('per_unit',1)){
if($price->price_min_quantity>1){
      
    $minQties = array();
foreach($this->row->prices as $priceBis){
  $minQties[] = $priceBis->price_min_quantity;
}
foreach($minQties as $key => $minQty){
  if(isset($price->price_min_quantity) && empty($this->cart_product_price) && $this->params->get('per_unit',1)){
    if($price->price_min_quantity == $minQty){
      $key++;
      echo sprintf('%s - %s off = ',$price->price_min_quantity,$minQties[$key]);
    }
  }
}

The following user(s) said Thank You: Jerome

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

  • Posts: 46
  • Thank you received: 7
11 years 5 months ago #105613

Hi Xavier

Can you advise how to get the first line of prices to say:
1 - 2 off = £ 168.00

And the last line of prices to say

10 + = £ 140.00

Many thanks - Leo

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

  • Posts: 13201
  • Thank you received: 2322
11 years 5 months ago #105638

Hi,

You can replace:

if(isset($price->price_min_quantity) && empty($this->cart_product_price) && $this->params->get('per_unit',1)){
    if($price->price_min_quantity == $minQty){
      $key++;
      echo sprintf('%s - %s off = ',$price->price_min_quantity,$minQties[$key]);
    }
}
By:
if(count($minQties) >= 1 && empty($this->cart_product_price) && $this->params->get('per_unit',1)){
    if($price->price_min_quantity == 0){
      $key++;
      echo sprintf('%s - %s off = ','1',$minQties[$key]);
    }
    elseif($price->price_min_quantity == $minQty || $price->price_min_quantity == 0){
      $key++;
      echo sprintf('%s - %s off = ',$price->price_min_quantity,$minQties[$key]);
    }else{
      echo sprintf('%s + = ',$price->price_min_quantity);
    }
}

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

  • Posts: 46
  • Thank you received: 7
11 years 5 months ago #105641

Thanks Xavier, I've pasted in your code, but this is what I get:

£ 168.00 ea
3 + = 3 - 6 off = 3 + = 3 + = 3 + = £ 160.00
6 + = 6 + = 6 - 10 off = 6 + = 6 + = £ 150.00
10 + = 10 + = 10 + = 10 - 26 off = 10 + = £ 140.00
26 + = 26 + = 26 + = 26 + = 26 - off = £ 130.00

Can you troubleshoot this?

Many thanks - Leo

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

  • Posts: 82760
  • Thank you received: 13346
  • MODERATOR
11 years 5 months ago #105811

I'm sorry but we're way off normal support here. We're already provided you a lot of code modifications without asking for anything but these modifications start to get out of hand and it's not anymore one or two lines of code to add...
If you want custom coding like these please use our contact form to request a quote on the job :
www.hikashop.com/en/contact-us.html

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

  • Posts: 46
  • Thank you received: 7
11 years 5 months ago #105880

OK - thanks for letting me know Nicolas. I actually thought it would be an easy change, but I can see it's a lot more complicated than I though.

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

Time to create page: 0.073 seconds
Powered by Kunena Forum