Percentage discount for a specific item in cart
I'm sure it's something stupid, but for the life of me I can't spot what I'm doing wrong.
I have to put in a discount rule that allows the customer to apply a coupon for a given percentage off on one item with a specific ProductID.
I set up database-driven coupons for flat-rate and percentage off (they work great), but adapting them for specific products doesn't seem to work for me.
I have session variables in place for the coupon's PromoProduct, PromoAmount and PromoType, and the correct values are showing. I also have a column in the eCart object for ProductID.
This is the rule that appears in eCart1.php:
function WAEC_eCart1_PercentageOffProduct() {
$totalDiscount = 0;
if (true && ((sizeof($this->Items) > 0) && (isset($_SESSION['PromoCode'])) && (isset($_SESSION['PromoAmount'])) && (isset($_SESSION['PromoProduct'])) && ((isset($_SESSION['PromoPSpecific'])?$_SESSION['PromoPSpecific']:"") == "product") && ($this->ConditionalTotal("Quantity", "ProductID", "".$_SESSION['PromoProduct'] ."") > 0))) {
$totalDiscount += (floatval($this->GetInfo("".$_SESSION['PromoProduct'] ."", "Price")) * ($_SESSION['PromoAmount'] / 100));//Result
}
return WA_eCart_FormatNumber($totalDiscount, $this->ForceDecimalsC, $this->DecimalPlacesC);
}
I've confirmed that all the session variables, the eCart columns, and the discount calculation are returning the expected values.