To make it so this one Discount Coupon will work when there are 2 or more Products from this 1 category in the cart, you could make the following customizations ...
Add a new file:
/includes/functions/extra_functions/functions_coupon_check.php
that contains the code:
Code:
<?php
if (!function_exists('in_cart_product_total_quantity_category')) {
function in_cart_product_total_quantity_category($category_id) {
$products = $this->get_products();
//echo '<pre>'; echo print_r($products); echo '</pre>';
$in_cart_product_quantity = 0;
for ($i=0, $n=sizeof($products); $i<$n; $i++) {
if ($products[$i]['category'] == $category_id) {
$in_cart_product_quantity += $products[$i]['quantity'];
}
} // end FOR loop
return $in_cart_product_quantity;
}
}
if (!function_exists('in_cart_product_total_quantity_category_sub')) {
function in_cart_product_total_quantity_category_sub($category_id) {
$chk_cart_quantity = 0;
if (zen_has_category_subcategories($category_id)) {
$subcategories_array = array();
$chk_cat = $category_id; // parent categories_id
zen_get_subcategories($subcategories_array, $chk_cat);
for ($i=0, $n=sizeof($subcategories_array); $i<$n; $i++ ) {
$chk_cart_quantity += in_cart_product_total_quantity_category($subcategories_array[$i]);
}
} else {
$chk_cart_quantity = in_cart_product_total_quantity_category($category_id);
}
return $chk_cart_quantity;
}
}
These funtions are used to count how many Products are in a cart from a Category ...
Then, edit a clean copy of:
/includes/modules/order_total/ot_coupon.php
and add the code in RED around line 212:
Code:
// bof: coupon COOKIES on 2 Products
if ($dc_check == 'COOKIES') {
$cookies_cat_id = 67;
$chk_cookies_count = in_cart_product_total_quantity_category_sub($cookies_cat_id);
if ($chk_cookies_count < 2) {
$foundvalid = false;
}
}
// eof: coupon COOKIES on 2 Products
if (!$foundvalid) {
$this->clear_posts();
}
Set this line:
Code:
$cookies_cat_id = 67;
to be the categories_id for the COOKIE category that you want for this Discount Code ...
Then, set the Discount Coupon code on this line:
Code:
if ($dc_check == 'COOKIES') {
to match your Discount Coupon code for this coupon so that the test runs only for this Discount Coupon to make sure that there are at least quantity 2 of the Cookie Products in the Cart, before it will give the $1.00 Discount ...
Bookmarks