Try this for cat to cat discounts:
You'll have to apply this to the other methods, but it's all I needed.PHP Code:function get_discount($discount_item, &$all_items) {
$discount = 0;
for ($dis=0, $n=count($this->discountlist); $dis<$n; $dis++) {
$found_match = false;
$li = $this->discountlist[$dis];
// Based on type, check ident1
if ( ($li->flavor == PROD_TO_PROD) ||
($li->flavor == PROD_TO_CAT) ) {
if ($li->ident1 == $discount_item['id']) {
continue;
} else {
$found_match = true;
}
} else { // CAT_TO_CAT, CAT_TO_PROD
// check to make sure a discount product has been added
if (zen_product_in_category((int)$discount_item['id'], $li->ident1)) { // modified to support linked products and top level categories
$found_match = true;
} else {
continue;
}
}
if ($found_match) {
for ($i=sizeof($all_items) - 1; $i>= 0; $i--) {
if ($all_items[$i]['quantity'] == 0)
continue;
$match = 0;
if ( ($li->flavor == PROD_TO_PROD) ||
($li->flavor == CAT_TO_PROD) ) {
if ($all_items[$i]['id'] == $li->ident2) {
$match = 1;
}
} else { // CAT_TO_CAT, PROD_TO_CAT
// check that a product in the other category exists
if (zen_product_in_category((int)$all_items[$i]['id'], $li->ident2)) { // modified to support linked products and top level categories
$match = 1;
}
}
if ($match == 1) {
$all_items[$i]['quantity'] -= 1;
if ($li->type == "$") {
$discount = $li->amt;
} else { // %
$discount = $all_items[$i]['final_price'] *
$li->amt / 100;
}
return $discount;
}
}
}
}
return 0;
}


Reply With Quote
