Zen Cart Logo
Forums / All Other Contributions/Addons / Help with a little bit of PHP coding for discounting ....

Help with a little bit of PHP coding for discounting ....

Views: 895

Results 1 to 4 of 4
13 Jan 2012, 2:41 PM
#1
plymgary1 avatar

plymgary1

Zen Follower

Join Date:
Feb 2009
Posts:
121
Plugin Contributions:
0

Help with a little bit of PHP coding for discounting ....

Hello,

I have a module that was built where if multiples of 3 are put into the cart then, one of the products is free.

Today, I modified the code so that the first product would be £5.99 then **every **product after would be discounted by £3.49. The problem is that for every multiple of two products that are added £3.49 is deducted!

I'm sure it should be a simple coding fix? I would really appreciate it if someone could take a minute to have a look at the relevant bit and tell me what I need to change. Please. :)

Here's the code:

  }

		$disc_amount += $this->get_disc_amount($all_items, $price);
		  
       $this->explanation = YOUR_CURRENT_3_FOR_2_DISCOUNT_CONFETTI . "\\n" . "\\n"; 
       $this->explanation .= "\\n\\n" . TOTAL_DISCOUNT . $this->print_amount($disc_amount); 
	   $od_amount['total'] = round($disc_amount, 2); 
       return $od_amount;
   }

   function get_disc_amount($count,$price) {
      $disc_amount = 0;
	  $new_count = $count - ($count%2);
//	  if (($count % 2) == 0) {
	  	$disc_amount = ($new_count/2) * 3.49;
//	  }	
      return $disc_amount; 
   } 

Many thanks,

Gary :smile:

14 Jan 2012, 11:14 AM
#2
plymgary1 avatar

plymgary1

Zen Follower

Join Date:
Feb 2009
Posts:
121
Plugin Contributions:
0

Re: Help with a little bit of PHP coding for discounting ....

Can anyone help, please? :)

16 Jan 2012, 11:39 AM
#3
pg_dev avatar

pg_dev

New Zenner

Join Date:
Jan 2012
Posts:
2
Plugin Contributions:
0

Re: Help with a little bit of PHP coding for discounting ....

I'm not 100% sure what you are asking for, but this should work. I read it that you didn't want the multiples of 3 thing any more, just deduct 3.49 from each if ordering more than 1 (excluding the first).

 
function get_disc_amount($count,$price) {
$disc_amount = ($count - 1)* 3.49;
return $disc_amount; 
}
16 Jan 2012, 2:46 PM
#4
plymgary1 avatar

plymgary1

Zen Follower

Join Date:
Feb 2009
Posts:
121
Plugin Contributions:
0

Re: Help with a little bit of PHP coding for discounting ....

That worked perfectly. Thanks very much. :)