gargsuchi Posted March 4, 2006 Share Posted March 4, 2006 Pls ignore my last 3 posts - I have been ablr to srt out the issues i faced there. The only problem that I now have is the following: I have a unique issue on my store. Bsically I want the following: If someone adds 6-11 items (can be six completely different products from the category 21) to the cart, those items should be discounted by 10% and the discount should be reflected in the price shown. If they add 12 or more, the price should be discounted by 15%. I tried to do this using this contrib. I added the following "Discount Rates" 21:6:10:p,21:12:15:p This works well for the first part - i.e. it shows Category Offer : Order 6 and we take 10% OFF ! But what abt the formula for someone ordering > 12? How do i reflect that in my store? Quote Link to comment Share on other sites More sharing options...
boxtel Posted March 4, 2006 Author Share Posted March 4, 2006 Pls ignore my last 3 posts - I have been ablr to srt out the issues i faced there. The only problem that I now have is the following: I have a unique issue on my store. Bsically I want the following: If someone adds 6-11 items (can be six completely different products from the category 21) to the cart, those items should be discounted by 10% and the discount should be reflected in the price shown. If they add 12 or more, the price should be discounted by 15%. I tried to do this using this contrib. I added the following "Discount Rates" 21:6:10:p,21:12:15:p This works well for the first part - i.e. it shows Category Offer : Order 6 and we take 10% OFF ! But what abt the formula for someone ordering > 12? How do i reflect that in my store? the contribution does not support multiple discounts per category, then you need to do some rewriting. Quote Treasurer MFC Link to comment Share on other sites More sharing options...
maniac101 Posted March 4, 2006 Share Posted March 4, 2006 Hi Amanda, Ive been setting up category discount. got it working and fixed a problem i was having with discounts being applied when i have attributes. in includes\modules\orders_total\ot_cat_qty_discount.php in function fill_discount_array() find and see the last line of: $products = $cart->get_products(); for ($p=0; $p<sizeof($products); $p++) { $t_prid = tep_get_prid($products[$p]['id']); $cat_query = tep_db_query("select categories_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . $t_prid . "'"); $cat_result = tep_db_fetch_array($cat_query); for ($i=0; $i<sizeof($cat_qty_discount_array); $i++) { $cat_path = tep_get_cat_path($cat_result['categories_id']); $cat_path_array = split("_" , $cat_path); // if ($cat_result['categories_id'] == $cat_qty_discount_array[$i]["cat"]) { if (in_array ($cat_qty_discount_array[$i]["cat"],$cat_path_array)) { // maniac101 modified to work with attributes $cat_qty_discount_array[$i]["cqty"] = $cat_qty_discount_array[$i]["cqty"] + $cart->get_quantity($products[$p]['id']); i basically changed the get_quantity($t_prid) to get_quantity($products[$p]['id']) so that the get_quantity function in classes\shopping_cart.php now returns the quantity correctly for products with and without attributes. That took me ages to work out ! Hope it works for others too. I also added a syntax change to the includes\functions\category_discount.php in function category_discount_display: if (MODULE_CAT_QTY_DISCOUNT_STATUS == 'true') { $discount_rate = split("[:,]" , MODULE_CAT_QTY_DISCOUNT_RATES); $size = sizeof($discount_rate); for ($i=0; $i<$size; $i+=4) { $cat_disc_message = ''; // maniac101 added for multiples if ($discount_rate[$i+1] > 1) { $disc_message_q = CAT_DISCOUNT_SPECIAL_QTYS; $disc_message_m = CAT_DISCOUNT_SPECIAL_MONS; $disc_message_p = CAT_DISCOUNT_SPECIAL_PRIS; } else { $disc_message_q = CAT_DISCOUNT_SPECIAL_QTY; $disc_message_m = CAT_DISCOUNT_SPECIAL_MON; $disc_message_p = CAT_DISCOUNT_SPECIAL_PRI; } // end mod for suffix additions ...//.. switch ($discount_rate[$i+3]) { case 'q' : $cat_disc_message = sprintf($disc_message_q, $discount_rate[$i+1],$cat_name,$discount_rate[$i+2]); break; case 'm' : $money = $currencies->format($discount_rate[$i+2]); $cat_disc_message = sprintf($disc_message_m, $discount_rate[$i+1],$cat_name,$money); break; case 'p' : $money = $currencies->format($discount_rate[$i+2]); $cat_disc_message = sprintf($disc_message_p, $discount_rate[$i+1],$cat_name,$money); break; ... You also need the extra messages in the language file All this does is make the messages better english when you have a 1 or more qty: ie before: buy 1 and get 1 item free buy 10 get 10 item free becomes: buy 1 and get 1 item free buy 10 and get 10 items free (notice the plural 's' on items). Not a very exciting change and probably done better in another way.. Now for a question.. Can you help with making a rule for for multi-catagory matching - so you must buy 1 from cat x, 1 from cat y and 1 from cat z to get a discount. would i break the rest of the code less if i tried to do this with an input string like (81,82,85):1:50:z ? or would i be better trying to do it with easy discount instead as a starting point ? Also: I like the Easy discount shopping cart messages and discounts shown - any 'best' way to incorporate that code into the category discount contrib as well so the customer can see the discount before they get to the checkout ? I'll keep trying.. thanks Quote Regards Mark Brindle Link to comment Share on other sites More sharing options...
boxtel Posted March 5, 2006 Author Share Posted March 5, 2006 Hi Amanda,Ive been setting up category discount. got it working and fixed a problem i was having with discounts being applied when i have attributes. in includes\modules\orders_total\ot_cat_qty_discount.php in function fill_discount_array() find and see the last line of: $products = $cart->get_products(); for ($p=0; $p<sizeof($products); $p++) { $t_prid = tep_get_prid($products[$p]['id']); $cat_query = tep_db_query("select categories_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . $t_prid . "'"); $cat_result = tep_db_fetch_array($cat_query); for ($i=0; $i<sizeof($cat_qty_discount_array); $i++) { $cat_path = tep_get_cat_path($cat_result['categories_id']); $cat_path_array = split("_" , $cat_path); // if ($cat_result['categories_id'] == $cat_qty_discount_array[$i]["cat"]) { if (in_array ($cat_qty_discount_array[$i]["cat"],$cat_path_array)) { // maniac101 modified to work with attributes $cat_qty_discount_array[$i]["cqty"] = $cat_qty_discount_array[$i]["cqty"] + $cart->get_quantity($products[$p]['id']); i basically changed the get_quantity($t_prid) to get_quantity($products[$p]['id']) so that the get_quantity function in classes\shopping_cart.php now returns the quantity correctly for products with and without attributes. That took me ages to work out ! Hope it works for others too. I also added a syntax change to the includes\functions\category_discount.php in function category_discount_display: if (MODULE_CAT_QTY_DISCOUNT_STATUS == 'true') { $discount_rate = split("[:,]" , MODULE_CAT_QTY_DISCOUNT_RATES); $size = sizeof($discount_rate); for ($i=0; $i<$size; $i+=4) { $cat_disc_message = ''; // maniac101 added for multiples if ($discount_rate[$i+1] > 1) { $disc_message_q = CAT_DISCOUNT_SPECIAL_QTYS; $disc_message_m = CAT_DISCOUNT_SPECIAL_MONS; $disc_message_p = CAT_DISCOUNT_SPECIAL_PRIS; } else { $disc_message_q = CAT_DISCOUNT_SPECIAL_QTY; $disc_message_m = CAT_DISCOUNT_SPECIAL_MON; $disc_message_p = CAT_DISCOUNT_SPECIAL_PRI; } // end mod for suffix additions ...//.. switch ($discount_rate[$i+3]) { case 'q' : $cat_disc_message = sprintf($disc_message_q, $discount_rate[$i+1],$cat_name,$discount_rate[$i+2]); break; case 'm' : $money = $currencies->format($discount_rate[$i+2]); $cat_disc_message = sprintf($disc_message_m, $discount_rate[$i+1],$cat_name,$money); break; case 'p' : $money = $currencies->format($discount_rate[$i+2]); $cat_disc_message = sprintf($disc_message_p, $discount_rate[$i+1],$cat_name,$money); break; ... You also need the extra messages in the language file All this does is make the messages better english when you have a 1 or more qty: ie before: buy 1 and get 1 item free buy 10 get 10 item free becomes: buy 1 and get 1 item free buy 10 and get 10 items free (notice the plural 's' on items). Not a very exciting change and probably done better in another way.. Now for a question.. Can you help with making a rule for for multi-catagory matching - so you must buy 1 from cat x, 1 from cat y and 1 from cat z to get a discount. would i break the rest of the code less if i tried to do this with an input string like (81,82,85):1:50:z ? or would i be better trying to do it with easy discount instead as a starting point ? Also: I like the Easy discount shopping cart messages and discounts shown - any 'best' way to incorporate that code into the category discount contrib as well so the customer can see the discount before they get to the checkout ? I'll keep trying.. thanks well, a multicat match needs so thought. if it is a one-off, I would use easy discount if you have a lot of those, then maybe add another line to admin and use it as a separate discount table. The problem being that the definition string formats need to be consistent or you have to create an elaborate string parse logic. think of situations like buy 2 of cat 54 and 3 of cat 33 and 1 of cat 78 ..... or only 2 categories or 4 etc. the messages, you could try a version like below which will fill a discount array (much like easy discount) instead of returning the total discount amount in calculate. That enables you to retain the individual discounts and list them. Simply create a function which gets the discounts array and use that for display in the cart. did not test this fully so you will need to go over it with taxes and things like that. also needs some finetuning and multi language stuff but the basics is there. <?php class ot_cat_qty_discount { var $title, $output, $discounts; function ot_cat_qty_discount() { $this->code = 'ot_cat_qty_discount'; $this->title = MODULE_CAT_QTY_DISCOUNT_TITLE; $this->description = MODULE_CAT_QTY_DISCOUNT_DESCRIPTION; $this->enabled = ((MODULE_CAT_QTY_DISCOUNT_STATUS == 'true') ? true : false); $this->sort_order = MODULE_CAT_QTY_DISCOUNT_SORT_ORDER; $this->include_shipping = MODULE_CAT_QTY_DISCOUNT_INC_SHIPPING; $this->include_tax = MODULE_CAT_QTY_DISCOUNT_INC_TAX; $this->calculate_tax = MODULE_CAT_QTY_DISCOUNT_CALC_TAX; $this->output = array(); $this->discounts = array(); } function process() { global $order, $currencies, $ot_subtotal, $cat_qty_discount_array, $cart_items_in_discount, $cart; $this->deduction = 0; $cat_qty_discount_array = $this->fill_discount_array($cat_qty_discount_array); $this->calculate_discount($cat_qty_discount_array); $n = sizeof($this->discounts); for ($i = 0; $i < $n; $i++) { $tod_amount = 0; $od_amount = $this->discounts[$i]['discount']; $this->output[] = array('title' => sprintf(MODULE_CAT_QTY_DISCOUNT_FORMATED_TITLE). ' ' .$this->discounts[$i]['text'], 'text' => $currencies->format($this->discounts[$i]['discount']), 'value' => $od_amount); if ($this->calculate_tax == 'true') $tod_amount = $this->calculate_tax_effect($od_amount); $this->deduction += $od_amount+$tod_amount; $this->taxes += $tod_amount; } $order->info['total'] -= $this->deduction; $order->info['tax'] -= $this->taxes; if ($this->sort_order < $ot_subtotal->sort_order) $order->info['subtotal'] -= $this->deduction; } function fill_discount_array() { global $cart_items_in_discount, $cat_qty_discount_array, $cart; $cart_items_in_discount = 0; // fill the discount conditions $discount_rate = split("[:,]" , MODULE_CAT_QTY_DISCOUNT_RATES); $size = sizeof($discount_rate); $index = 0; for ($i=0; $i<$size; $i+=4) { $cat_qty_discount_array[$index]["cat"] = $discount_rate[$i]; $cat_qty_discount_array[$index]["xqty"] = $discount_rate[$i+1]; $cat_qty_discount_array[$index]["yqty"] = $discount_rate[$i+2]; $cat_qty_discount_array[$index]["type"] = $discount_rate[$i+3]; $cat_qty_discount_array[$index]["cqty"] = 0; $cat_qty_discount_array[$index]["price"] = 0; $index++; } // add the quantities from the shopping cart $products = $cart->get_products(); for ($p=0; $p<sizeof($products); $p++) { $t_prid = tep_get_prid($products[$p]['id']); $cat_query = tep_db_query("select categories_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . $t_prid . "'"); $cat_result = tep_db_fetch_array($cat_query); for ($i=0; $i<sizeof($cat_qty_discount_array); $i++) { $cat_path = tep_get_cat_path($cat_result['categories_id']); $cat_path_array = split("_" , $cat_path); if (in_array ($cat_qty_discount_array[$i]["cat"],$cat_path_array)) { $cat_qty_discount_array[$i]["cqty"] = $cat_qty_discount_array[$i]["cqty"] + $cart->get_quantity($t_prid); $cat_qty_discount_array[$i]["price"] = $cat_qty_discount_array[$i]["price"] + $products[$p]['price']*$cart->get_quantity($products[$p]['id']); $cart_items_in_discount++; } } } return $cat_qty_discount_array; } function calculate_discount($cat_qty_discount_array) { global $qty_discount, $order_total_array; $od_amount = 0; if ((MODULE_CAT_QTY_DISCOUNT_DISABLE_WITH_COUPON == 'true') && (isset($_SESSION['cc_id']))) return $od_amount; for ($i=0; $i<sizeof($cat_qty_discount_array); $i++) { switch ($cat_qty_discount_array[$i]['type']) { case 'm' : $discount = floor(($cat_qty_discount_array[$i]['cqty'] / $cat_qty_discount_array[$i]['xqty'])) * $cat_qty_discount_array[$i]['yqty']; if ($discount > 0) $this->discounts[] = array('text' => 'M Discount', 'discount' => $discount); break; case 'q' : $discount = floor(($cat_qty_discount_array[$i]['cqty'] / $cat_qty_discount_array[$i]['xqty'])) * ($cat_qty_discount_array[$i]['price']/$cat_qty_discount_array[$i]['cqty']); if ($discount > 0) $this->discounts[] = array('text' => 'Q Discount', 'discount' => $discount); break; case 'p' : if ($cat_qty_discount_array[$i]['cqty'] >= $cat_qty_discount_array[$i]['xqty']) { $discount = ($cat_qty_discount_array[$i]['cqty'] * $cat_qty_discount_array[$i]['yqty']); if ($discount > 0) $this->discounts[] = array('text' => 'P Discount', 'discount' => $discount); } break; case 'a' : if ($cat_qty_discount_array[$i]['cqty'] >= $cat_qty_discount_array[$i]['xqty']) { $discount = ($cat_qty_discount_array[$i]['price'] * $cat_qty_discount_array[$i]['yqty'] / 100); if ($discount > 0) $this->discounts[] = array('text' => 'a Discount', 'discount' => $discount); } break; } } } function calculate_tax_effect($od_amount) { global $order; $tod_amount = 0; reset($order->info['tax_groups']); while (list($key, $value) = each($order->info['tax_groups'])) { $god_amount = 0; $tax_rate = tep_get_tax_rate_from_desc($key); $net = ($tax_rate * $order->info['tax_groups'][$key]); if ($net>0) { $god_amount = ($tax_rate/100)*$od_amount; $tod_amount += $god_amount; $order->info['tax_groups'][$key] = $order->info['tax_groups'][$key] - $god_amount; } } return $tod_amount; } function check() { if (!isset($this->check)) { $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_CAT_QTY_DISCOUNT_STATUS'"); $this->check = mysql_num_rows($check_query); } return $this->check; } function keys() { return array('MODULE_CAT_QTY_DISCOUNT_STATUS', 'MODULE_CAT_QTY_DISCOUNT_SORT_ORDER', 'MODULE_CAT_QTY_DISCOUNT_DISABLE_WITH_COUPON', 'MODULE_CAT_QTY_DISCOUNT_RATES', 'MODULE_CAT_QTY_DISCOUNT_INC_SHIPPING', 'MODULE_CAT_QTY_DISCOUNT_INC_TAX', 'MODULE_CAT_QTY_DISCOUNT_CALC_TAX'); } function install() { tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Activate Category Quantity Discount', 'MODULE_CAT_QTY_DISCOUNT_STATUS', 'true', 'Do you want to enable the category quantity discount module?', '6', '1','tep_cfg_select_option(array(\'true\', \'false\'), ', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_CAT_QTY_DISCOUNT_SORT_ORDER', '2', 'Sort order of display.', '6', '2', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Disable If Coupon Used', 'MODULE_CAT_QTY_DISCOUNT_DISABLE_WITH_COUPON', 'true', 'Do you want to disable the quantity discount module if a discount coupon is being used by the user?', '6', '3','tep_cfg_select_option(array(\'true\', \'false\'), ', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Discount Rates', 'MODULE_CAT_QTY_DISCOUNT_RATES', '98:10:1:q,103:10:100:m', 'The discount is based on the number of items in the same category. Example: 94:10:1:q,56:5:2:m.. buy 10 from category 94 you get 1 item free - 1 dollar or the price of 1 item. q = quantity m = money', '6', '5', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function ,date_added) values ('Include Shipping', 'MODULE_CAT_QTY_DISCOUNT_INC_SHIPPING', 'false', 'Include Shipping in calculation', '6', '6', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function ,date_added) values ('Include Tax', 'MODULE_CAT_QTY_DISCOUNT_INC_TAX', 'false', 'Include Tax in calculation.', '6', '7','tep_cfg_select_option(array(\'true\', \'false\'), ', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function ,date_added) values ('Calculate Tax', 'MODULE_CAT_QTY_DISCOUNT_CALC_TAX', 'true', 'Re-calculate Tax on discounted amount.', '6', '8','tep_cfg_select_option(array(\'true\', \'false\'), ', now())"); } function remove() { tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')"); } } //// // Get tax rate from tax description if (!function_exists(tep_get_tax_rate_from_desc)) { function tep_get_tax_rate_from_desc($tax_desc) { $tax_query = tep_db_query("select tax_rate from " . TABLE_TAX_RATES . " where tax_description = '" . $tax_desc . "'"); $tax = mysql_fetch_assoc($tax_query); return $tax['tax_rate']; } } ?> Quote Treasurer MFC Link to comment Share on other sites More sharing options...
boxtel Posted March 5, 2006 Author Share Posted March 5, 2006 well, a multicat match needs so thought. if it is a one-off, I would use easy discount if you have a lot of those, then maybe add another line to admin and use it as a separate discount table. The problem being that the definition string formats need to be consistent or you have to create an elaborate string parse logic.think of situations like buy 2 of cat 54 and 3 of cat 33 and 1 of cat 78 ..... or only 2 categories or 4 etc. the messages, you could try a version like below which will fill a discount array (much like easy discount) instead of returning the total discount amount in calculate. That enables you to retain the individual discounts and list them. Simply create a function which gets the discounts array and use that for display in the cart. did not test this fully so you will need to go over it with taxes and things like that. also needs some finetuning and multi language stuff but the basics is there. <?php class ot_cat_qty_discount { var $title, $output, $discounts; function ot_cat_qty_discount() { $this->code = 'ot_cat_qty_discount'; $this->title = MODULE_CAT_QTY_DISCOUNT_TITLE; $this->description = MODULE_CAT_QTY_DISCOUNT_DESCRIPTION; $this->enabled = ((MODULE_CAT_QTY_DISCOUNT_STATUS == 'true') ? true : false); $this->sort_order = MODULE_CAT_QTY_DISCOUNT_SORT_ORDER; $this->include_shipping = MODULE_CAT_QTY_DISCOUNT_INC_SHIPPING; $this->include_tax = MODULE_CAT_QTY_DISCOUNT_INC_TAX; $this->calculate_tax = MODULE_CAT_QTY_DISCOUNT_CALC_TAX; $this->output = array(); $this->discounts = array(); } function process() { global $order, $currencies, $ot_subtotal, $cat_qty_discount_array, $cart_items_in_discount, $cart; $this->deduction = 0; $cat_qty_discount_array = $this->fill_discount_array($cat_qty_discount_array); $this->calculate_discount($cat_qty_discount_array); $n = sizeof($this->discounts); for ($i = 0; $i < $n; $i++) { $tod_amount = 0; $od_amount = $this->discounts[$i]['discount']; $this->output[] = array('title' => sprintf(MODULE_CAT_QTY_DISCOUNT_FORMATED_TITLE). ' ' .$this->discounts[$i]['text'], 'text' => $currencies->format($this->discounts[$i]['discount']), 'value' => $od_amount); if ($this->calculate_tax == 'true') $tod_amount = $this->calculate_tax_effect($od_amount); $this->deduction += $od_amount+$tod_amount; $this->taxes += $tod_amount; } $order->info['total'] -= $this->deduction; $order->info['tax'] -= $this->taxes; if ($this->sort_order < $ot_subtotal->sort_order) $order->info['subtotal'] -= $this->deduction; } function fill_discount_array() { global $cart_items_in_discount, $cat_qty_discount_array, $cart; $cart_items_in_discount = 0; // fill the discount conditions $discount_rate = split("[:,]" , MODULE_CAT_QTY_DISCOUNT_RATES); $size = sizeof($discount_rate); $index = 0; for ($i=0; $i<$size; $i+=4) { $cat_qty_discount_array[$index]["cat"] = $discount_rate[$i]; $cat_qty_discount_array[$index]["xqty"] = $discount_rate[$i+1]; $cat_qty_discount_array[$index]["yqty"] = $discount_rate[$i+2]; $cat_qty_discount_array[$index]["type"] = $discount_rate[$i+3]; $cat_qty_discount_array[$index]["cqty"] = 0; $cat_qty_discount_array[$index]["price"] = 0; $index++; } // add the quantities from the shopping cart $products = $cart->get_products(); for ($p=0; $p<sizeof($products); $p++) { $t_prid = tep_get_prid($products[$p]['id']); $cat_query = tep_db_query("select categories_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . $t_prid . "'"); $cat_result = tep_db_fetch_array($cat_query); for ($i=0; $i<sizeof($cat_qty_discount_array); $i++) { $cat_path = tep_get_cat_path($cat_result['categories_id']); $cat_path_array = split("_" , $cat_path); if (in_array ($cat_qty_discount_array[$i]["cat"],$cat_path_array)) { $cat_qty_discount_array[$i]["cqty"] = $cat_qty_discount_array[$i]["cqty"] + $cart->get_quantity($t_prid); $cat_qty_discount_array[$i]["price"] = $cat_qty_discount_array[$i]["price"] + $products[$p]['price']*$cart->get_quantity($products[$p]['id']); $cart_items_in_discount++; } } } return $cat_qty_discount_array; } function calculate_discount($cat_qty_discount_array) { global $qty_discount, $order_total_array; $od_amount = 0; if ((MODULE_CAT_QTY_DISCOUNT_DISABLE_WITH_COUPON == 'true') && (isset($_SESSION['cc_id']))) return $od_amount; for ($i=0; $i<sizeof($cat_qty_discount_array); $i++) { switch ($cat_qty_discount_array[$i]['type']) { case 'm' : $discount = floor(($cat_qty_discount_array[$i]['cqty'] / $cat_qty_discount_array[$i]['xqty'])) * $cat_qty_discount_array[$i]['yqty']; if ($discount > 0) $this->discounts[] = array('text' => 'M Discount', 'discount' => $discount); break; case 'q' : $discount = floor(($cat_qty_discount_array[$i]['cqty'] / $cat_qty_discount_array[$i]['xqty'])) * ($cat_qty_discount_array[$i]['price']/$cat_qty_discount_array[$i]['cqty']); if ($discount > 0) $this->discounts[] = array('text' => 'Q Discount', 'discount' => $discount); break; case 'p' : if ($cat_qty_discount_array[$i]['cqty'] >= $cat_qty_discount_array[$i]['xqty']) { $discount = ($cat_qty_discount_array[$i]['cqty'] * $cat_qty_discount_array[$i]['yqty']); if ($discount > 0) $this->discounts[] = array('text' => 'P Discount', 'discount' => $discount); } break; case 'a' : if ($cat_qty_discount_array[$i]['cqty'] >= $cat_qty_discount_array[$i]['xqty']) { $discount = ($cat_qty_discount_array[$i]['price'] * $cat_qty_discount_array[$i]['yqty'] / 100); if ($discount > 0) $this->discounts[] = array('text' => 'a Discount', 'discount' => $discount); } break; } } } function calculate_tax_effect($od_amount) { global $order; $tod_amount = 0; reset($order->info['tax_groups']); while (list($key, $value) = each($order->info['tax_groups'])) { $god_amount = 0; $tax_rate = tep_get_tax_rate_from_desc($key); $net = ($tax_rate * $order->info['tax_groups'][$key]); if ($net>0) { $god_amount = ($tax_rate/100)*$od_amount; $tod_amount += $god_amount; $order->info['tax_groups'][$key] = $order->info['tax_groups'][$key] - $god_amount; } } return $tod_amount; } function check() { if (!isset($this->check)) { $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_CAT_QTY_DISCOUNT_STATUS'"); $this->check = mysql_num_rows($check_query); } return $this->check; } function keys() { return array('MODULE_CAT_QTY_DISCOUNT_STATUS', 'MODULE_CAT_QTY_DISCOUNT_SORT_ORDER', 'MODULE_CAT_QTY_DISCOUNT_DISABLE_WITH_COUPON', 'MODULE_CAT_QTY_DISCOUNT_RATES', 'MODULE_CAT_QTY_DISCOUNT_INC_SHIPPING', 'MODULE_CAT_QTY_DISCOUNT_INC_TAX', 'MODULE_CAT_QTY_DISCOUNT_CALC_TAX'); } function install() { tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Activate Category Quantity Discount', 'MODULE_CAT_QTY_DISCOUNT_STATUS', 'true', 'Do you want to enable the category quantity discount module?', '6', '1','tep_cfg_select_option(array(\'true\', \'false\'), ', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_CAT_QTY_DISCOUNT_SORT_ORDER', '2', 'Sort order of display.', '6', '2', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Disable If Coupon Used', 'MODULE_CAT_QTY_DISCOUNT_DISABLE_WITH_COUPON', 'true', 'Do you want to disable the quantity discount module if a discount coupon is being used by the user?', '6', '3','tep_cfg_select_option(array(\'true\', \'false\'), ', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Discount Rates', 'MODULE_CAT_QTY_DISCOUNT_RATES', '98:10:1:q,103:10:100:m', 'The discount is based on the number of items in the same category. Example: 94:10:1:q,56:5:2:m.. buy 10 from category 94 you get 1 item free - 1 dollar or the price of 1 item. q = quantity m = money', '6', '5', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function ,date_added) values ('Include Shipping', 'MODULE_CAT_QTY_DISCOUNT_INC_SHIPPING', 'false', 'Include Shipping in calculation', '6', '6', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function ,date_added) values ('Include Tax', 'MODULE_CAT_QTY_DISCOUNT_INC_TAX', 'false', 'Include Tax in calculation.', '6', '7','tep_cfg_select_option(array(\'true\', \'false\'), ', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function ,date_added) values ('Calculate Tax', 'MODULE_CAT_QTY_DISCOUNT_CALC_TAX', 'true', 'Re-calculate Tax on discounted amount.', '6', '8','tep_cfg_select_option(array(\'true\', \'false\'), ', now())"); } function remove() { tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')"); } } //// // Get tax rate from tax description if (!function_exists(tep_get_tax_rate_from_desc)) { function tep_get_tax_rate_from_desc($tax_desc) { $tax_query = tep_db_query("select tax_rate from " . TABLE_TAX_RATES . " where tax_description = '" . $tax_desc . "'"); $tax = mysql_fetch_assoc($tax_query); return $tax['tax_rate']; } } ?> with this : function cat_name ($cat_id) { global $languages_id; $cat_query = tep_db_query("select categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '".$cat_id."' and language_id = '" . (int)$languages_id . "'"); $cat = tep_db_fetch_array($cat_query); return $cat['categories_name']; } function calculate_discount($cat_qty_discount_array) { global $qty_discount, $order_total_array; $od_amount = 0; if ((MODULE_CAT_QTY_DISCOUNT_DISABLE_WITH_COUPON == 'true') && (isset($_SESSION['cc_id']))) return $od_amount; for ($i=0; $i<sizeof($cat_qty_discount_array); $i++) { switch ($cat_qty_discount_array[$i]['type']) { case 'm' : $discount = floor(($cat_qty_discount_array[$i]['cqty'] / $cat_qty_discount_array[$i]['xqty'])) * $cat_qty_discount_array[$i]['yqty']; if ($discount > 0) $this->discounts[] = array('text' => $this->cat_name($cat_qty_discount_array[$i]["cat"]).'- Buy '.$cat_qty_discount_array[$i]['xqty'].' get '.$cat_qty_discount_array[$i]['yqty'].' off'.' ['.$cat_qty_discount_array[$i]['cqty'].']', 'discount' => $discount); break; case 'q' : $discount = floor(($cat_qty_discount_array[$i]['cqty'] / $cat_qty_discount_array[$i]['xqty'])) * ($cat_qty_discount_array[$i]['price']/$cat_qty_discount_array[$i]['cqty']); if ($discount > 0) $this->discounts[] = array('text' => $this->cat_name($cat_qty_discount_array[$i]["cat"]).'- Buy '.$cat_qty_discount_array[$i]['xqty'].' get '.$cat_qty_discount_array[$i]['yqty'].' for FREE'.' ['.$cat_qty_discount_array[$i]['cqty'].']', 'discount' => $discount); break; case 'p' : if ($cat_qty_discount_array[$i]['cqty'] >= $cat_qty_discount_array[$i]['xqty']) { $discount = ($cat_qty_discount_array[$i]['cqty'] * $cat_qty_discount_array[$i]['yqty']); if ($discount > 0) $this->discounts[] = array('text' => $this->cat_name($cat_qty_discount_array[$i]["cat"]).'- Buy '.$cat_qty_discount_array[$i]['xqty'].' get '.$cat_qty_discount_array[$i]['yqty'].' off each'.' ['.$cat_qty_discount_array[$i]['cqty'].']', 'discount' => $discount); } break; case 'a' : if ($cat_qty_discount_array[$i]['cqty'] >= $cat_qty_discount_array[$i]['xqty']) { $discount = ($cat_qty_discount_array[$i]['price'] * $cat_qty_discount_array[$i]['yqty'] / 100); if ($discount > 0) $this->discounts[] = array('text' => $this->cat_name($cat_qty_discount_array[$i]["cat"]).'- Buy '.$cat_qty_discount_array[$i]['xqty'].' get '.$cat_qty_discount_array[$i]['yqty'].'% discount'.' ['.$cat_qty_discount_array[$i]['cqty'].']', 'discount' => $discount); } break; } } } you get something like this : Quote Treasurer MFC Link to comment Share on other sites More sharing options...
boxtel Posted March 5, 2006 Author Share Posted March 5, 2006 with this : function cat_name ($cat_id) { global $languages_id; $cat_query = tep_db_query("select categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '".$cat_id."' and language_id = '" . (int)$languages_id . "'"); $cat = tep_db_fetch_array($cat_query); return $cat['categories_name']; } function calculate_discount($cat_qty_discount_array) { global $qty_discount, $order_total_array; $od_amount = 0; if ((MODULE_CAT_QTY_DISCOUNT_DISABLE_WITH_COUPON == 'true') && (isset($_SESSION['cc_id']))) return $od_amount; for ($i=0; $i<sizeof($cat_qty_discount_array); $i++) { switch ($cat_qty_discount_array[$i]['type']) { case 'm' : $discount = floor(($cat_qty_discount_array[$i]['cqty'] / $cat_qty_discount_array[$i]['xqty'])) * $cat_qty_discount_array[$i]['yqty']; if ($discount > 0) $this->discounts[] = array('text' => $this->cat_name($cat_qty_discount_array[$i]["cat"]).'- Buy '.$cat_qty_discount_array[$i]['xqty'].' get '.$cat_qty_discount_array[$i]['yqty'].' off'.' ['.$cat_qty_discount_array[$i]['cqty'].']', 'discount' => $discount); break; case 'q' : $discount = floor(($cat_qty_discount_array[$i]['cqty'] / $cat_qty_discount_array[$i]['xqty'])) * ($cat_qty_discount_array[$i]['price']/$cat_qty_discount_array[$i]['cqty']); if ($discount > 0) $this->discounts[] = array('text' => $this->cat_name($cat_qty_discount_array[$i]["cat"]).'- Buy '.$cat_qty_discount_array[$i]['xqty'].' get '.$cat_qty_discount_array[$i]['yqty'].' for FREE'.' ['.$cat_qty_discount_array[$i]['cqty'].']', 'discount' => $discount); break; case 'p' : if ($cat_qty_discount_array[$i]['cqty'] >= $cat_qty_discount_array[$i]['xqty']) { $discount = ($cat_qty_discount_array[$i]['cqty'] * $cat_qty_discount_array[$i]['yqty']); if ($discount > 0) $this->discounts[] = array('text' => $this->cat_name($cat_qty_discount_array[$i]["cat"]).'- Buy '.$cat_qty_discount_array[$i]['xqty'].' get '.$cat_qty_discount_array[$i]['yqty'].' off each'.' ['.$cat_qty_discount_array[$i]['cqty'].']', 'discount' => $discount); } break; case 'a' : if ($cat_qty_discount_array[$i]['cqty'] >= $cat_qty_discount_array[$i]['xqty']) { $discount = ($cat_qty_discount_array[$i]['price'] * $cat_qty_discount_array[$i]['yqty'] / 100); if ($discount > 0) $this->discounts[] = array('text' => $this->cat_name($cat_qty_discount_array[$i]["cat"]).'- Buy '.$cat_qty_discount_array[$i]['xqty'].' get '.$cat_qty_discount_array[$i]['yqty'].'% discount'.' ['.$cat_qty_discount_array[$i]['cqty'].']', 'discount' => $discount); } break; } } } you get something like this : added this function to the ot class: function display_discounts () { global $currencies, $cat_qty_discount_array; $cat_qty_discount_array = $this->fill_discount_array($cat_qty_discount_array); $this->calculate_discount($cat_qty_discount_array); $n = sizeof($this->discounts); for ($i = 0; $i < $n; $i++) { $tod_amount = 0; $od_amount = $this->discounts[$i]['discount']; echo '<tr><td align="right">'.MODULE_CAT_QTY_DISCOUNT_FORMATED_TITLE. ' - ' .$this->discounts[$i]['text'].':</td><td align="right">'. sprintf(MODULE_CAT_QTY_DISCOUNT_FORMATED_TEXT,$currencies->format($this->discounts[$i]['discount'])).'</td></tr>'; if ($this->calculate_tax == 'true') $tod_amount = $this->calculate_tax_effect($od_amount); $this->deduction += $od_amount+$tod_amount; } return $this->deduction; } added this to shopping cart.php: right after : <td align="right" width="85%"><?php echo SUB_TITLE_SUB_TOTAL; ?></td><td align="right"> <?php echo $currencies->format($cart->show_total()); ?> </td> </tr> add this : <?php $new_total = $cart->show_total(); include (DIR_WS_MODULES.'order_total/ot_cat_qty_discount.php'); include(DIR_WS_LANGUAGES . $language . '/modules/order_total/ot_cat_qty_discount.php'); $cat_qty_discount = new ot_cat_qty_discount; $cat_deduction = $cat_qty_discount->display_discounts(); if ($cat_deduction > 0) { $new_total = $new_total - $cat_deduction; } if ($easy_discount->count() > 0) { echo easy_discount_display(); if ($easy_discount->total() > 0) { $new_total = $new_total - $easy_discount->total(); } } if ($new_total == 0) { echo '<tr><td align="right">'.SUB_TITLE_TOTAL.'</td><td align="right">'.FREE_TEXT.'</td></tr>'; } else { echo '<tr><td align="right">'.SUB_TITLE_TOTAL.'</td><td align="right">'.$currencies->format($new_total).'</td></tr>'; } ?> adjust at will. Quote Treasurer MFC Link to comment Share on other sites More sharing options...
boxtel Posted March 5, 2006 Author Share Posted March 5, 2006 added this function to the ot class: function display_discounts () { global $currencies, $cat_qty_discount_array; $cat_qty_discount_array = $this->fill_discount_array($cat_qty_discount_array); $this->calculate_discount($cat_qty_discount_array); $n = sizeof($this->discounts); for ($i = 0; $i < $n; $i++) { $tod_amount = 0; $od_amount = $this->discounts[$i]['discount']; echo '<tr><td align="right">'.MODULE_CAT_QTY_DISCOUNT_FORMATED_TITLE. ' - ' .$this->discounts[$i]['text'].':</td><td align="right">'. sprintf(MODULE_CAT_QTY_DISCOUNT_FORMATED_TEXT,$currencies->format($this->discounts[$i]['discount'])).'</td></tr>'; if ($this->calculate_tax == 'true') $tod_amount = $this->calculate_tax_effect($od_amount); $this->deduction += $od_amount+$tod_amount; } return $this->deduction; } added this to shopping cart.php: right after : <td align="right" width="85%"><?php echo SUB_TITLE_SUB_TOTAL; ?></td><td align="right"> <?php echo $currencies->format($cart->show_total()); ?> </td> </tr> add this : <?php $new_total = $cart->show_total(); include (DIR_WS_MODULES.'order_total/ot_cat_qty_discount.php'); include(DIR_WS_LANGUAGES . $language . '/modules/order_total/ot_cat_qty_discount.php'); $cat_qty_discount = new ot_cat_qty_discount; $cat_deduction = $cat_qty_discount->display_discounts(); if ($cat_deduction > 0) { $new_total = $new_total - $cat_deduction; } if ($easy_discount->count() > 0) { echo easy_discount_display(); if ($easy_discount->total() > 0) { $new_total = $new_total - $easy_discount->total(); } } if ($new_total == 0) { echo '<tr><td align="right">'.SUB_TITLE_TOTAL.'</td><td align="right">'.FREE_TEXT.'</td></tr>'; } else { echo '<tr><td align="right">'.SUB_TITLE_TOTAL.'</td><td align="right">'.$currencies->format($new_total).'</td></tr>'; } ?> adjust at will. gives : Quote Treasurer MFC Link to comment Share on other sites More sharing options...
Guest Posted March 6, 2006 Share Posted March 6, 2006 Hi. How do you set discount by percent? MEan... cat 20 get 2% of discount.. etc? Quote Link to comment Share on other sites More sharing options...
boxtel Posted March 6, 2006 Author Share Posted March 6, 2006 Hi. How do you set discount by percent?MEan... cat 20 get 2% of discount.. etc? 20:1:2:a gives 2% discount on every item from category 20 and its subcategories Quote Treasurer MFC Link to comment Share on other sites More sharing options...
Guest Posted March 6, 2006 Share Posted March 6, 2006 20:1:2:a gives 2% discount on every item from category 20 and its subcategories Nice, but.. how i set an discount to all categories, exept category 3? or cat 40 in example? Quote Link to comment Share on other sites More sharing options...
boxtel Posted March 6, 2006 Author Share Posted March 6, 2006 Nice, but.. how i set an discount to all categories, exept category 3? or cat 40 in example? are you looking for something particular or just a "what if" conversation. Quote Treasurer MFC Link to comment Share on other sites More sharing options...
Guest Posted March 6, 2006 Share Posted March 6, 2006 (edited) are you looking for something particular or just a "what if" conversation. ... Thanks for your help. :( OTW.. if you dont explain in a txt the correct usage, the how to, and etc.. you always get this kind of answers... Forget it.. i will do it. Edited March 6, 2006 by rolohazard Quote Link to comment Share on other sites More sharing options...
maniac101 Posted March 6, 2006 Share Posted March 6, 2006 Hi Amanda, ive been trying to add the modifications you suggested. I now do see some sort of message in the shopping cart but get a few errors with like: Warning: reset(): Passed variable is not an array or object in /**/shop/includes/modules/order_total/ot_cat_qty_discount.php on line 138Warning: Variable passed to each() is not an array or object in /**/shop/includes/modules/order_total/ot_cat_qty_discount.php on line 139 The offending lines being: reset($order->info['tax_groups']); while (list($key, $value) = each($order->info['tax_groups'])) { This is doing a discount like 84:2:1:m The format of the message seems wrong too: Sub-Total: ?111.87 Special Offer Discount: - Cute Lambs- Buy 1 get 1 off [13]: -?13.00 not sure where the [13] has come from. I will try to spend some time looking at this tomorrow. Quote Regards Mark Brindle Link to comment Share on other sites More sharing options...
Kakor_98 Posted March 6, 2006 Share Posted March 6, 2006 well, in the cases that a product can be linked to multiple categories then you need to create a loop inthe order total module. currently it uses this query: $cat_query = tep_db_query("select categories_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . $t_prid . "'"); which determines the category the product belongs to and then determined the entire category path upwarts to see later if any of them is defined for discounts. the code now takes 1 result from that query, so if there are more, run the query and subsequent logic in a loop. Do anyone know how I do this? Quote Link to comment Share on other sites More sharing options...
boxtel Posted March 7, 2006 Author Share Posted March 7, 2006 Do anyone know how I do this? I will have a look at it later. for mark, I cannot reply to your post for some reason. the warnings are because the order object probably does not yet exist when trying to calculate the tax amount. so add the condition : if (is_object($order)) { before the reset() in that function. the 13 is the amount of products in the cart that fall under that discount condition. just put it in the message to check if the quantities add up. Quote Treasurer MFC Link to comment Share on other sites More sharing options...
stephen495 Posted March 7, 2006 Share Posted March 7, 2006 Hello, Can anyone help me on the install instructions for this contribution? Is this include to be added after */ >3) in top of index.php add: >include(DIR_WS_FUNCTIONS.'category_discount.php'); Can you show me what the nested and products sections look like? >4) in index.php in the "nested" AND in the "products" section you add >echo category_discount_display($current_category_id); Thanks, Stephen Quote Link to comment Share on other sites More sharing options...
boxtel Posted March 7, 2006 Author Share Posted March 7, 2006 Hello, Can anyone help me on the install instructions for this contribution? Is this include to be added after */ >3) in top of index.php add: >include(DIR_WS_FUNCTIONS.'category_discount.php'); Can you show me what the nested and products sections look like? >4) in index.php in the "nested" AND in the "products" section you add >echo category_discount_display($current_category_id); Thanks, Stephen the top is always after require('includes/application_top.php'); index.php consists of 3 distinct parts: categories display starts at : if ($category_depth == 'nested') { products display starts at : } elseif ($category_depth == 'products' || isset($HTTP_GET_VARS['manufacturers_id'])) { main page display starts at : } else { // default page Quote Treasurer MFC Link to comment Share on other sites More sharing options...
maniac101 Posted March 7, 2006 Share Posted March 7, 2006 for mark, I cannot reply to your post for some reason.the warnings are because the order object probably does not yet exist when trying to calculate the tax amount. so add the condition : if (is_object($order)) { before the reset() in that function. the 13 is the amount of products in the cart that fall under that discount condition. just put it in the message to check if the quantities add up. Thanks Amanda, got the messages working now in the main shopping cart now - although it would be good to show the tax too since all our prices already show and include tax. The 'order' object seems to get created as part of the checkout process but if i try to use it in a similar manner i get errors since i have an 'estimated shipping cost box' which also creates the order object too and seems to clash. Any ideas about accessing the order object from the shopping cart? should i move some code to application_top instead ? I would also ideally like to get the discount value in the shopping cart box too. I tried using similar code to the main shoping_cart.php like: if (MODULE_CAT_QTY_DISCOUNT_STATUS == 'true') { $new_total = $cart->show_total(); $cat_qty_discount = new ot_cat_qty_discount; $cat_deduction = $cat_qty_discount->display_discounts(); if ($cat_deduction > 0) { $info_box_contents [] = array('align' => ' right ', 'text' => 'Discounts: <font color="red">- '.$currencies->format($cat_deduction).'</font>'); $info_box_contents [] = array('align' => ' right ', 'text' => 'Total: '.$currencies->format($cart->show_total() - $cat_deduction)); } } // end cat discount mod but get errors like: Fatal error: Cannot instantiate non-existent class: ot_cat_qty_discount in /***/shop/includes/boxes/shopping_cart.php on line 80 line 80 being $cat_qty_discount = new ot_cat_qty_discount; But even if this worked id rather not have to use something like: $cat_deduction = $cat_qty_discount->display_discounts(); as this would generate the text messages in the shopping cart box anyway which isnt what i want. I just want the discount amount to play with instead. Any suggestions about generating the discount value without upsetting the order object ? thanks Quote Regards Mark Brindle Link to comment Share on other sites More sharing options...
boxtel Posted March 9, 2006 Author Share Posted March 9, 2006 Thanks Amanda, got the messages working now in the main shopping cart now - although it would be good to show the tax too since all our prices already show and include tax. The 'order' object seems to get created as part of the checkout process but if i try to use it in a similar manner i get errors since i have an 'estimated shipping cost box' which also creates the order object too and seems to clash. Any ideas about accessing the order object from the shopping cart? should i move some code to application_top instead ? I would also ideally like to get the discount value in the shopping cart box too. I tried using similar code to the main shoping_cart.php like: if (MODULE_CAT_QTY_DISCOUNT_STATUS == 'true') { $new_total = $cart->show_total(); $cat_qty_discount = new ot_cat_qty_discount; $cat_deduction = $cat_qty_discount->display_discounts(); if ($cat_deduction > 0) { $info_box_contents [] = array('align' => ' right ', 'text' => 'Discounts: <font color="red">- '.$currencies->format($cat_deduction).'</font>'); $info_box_contents [] = array('align' => ' right ', 'text' => 'Total: '.$currencies->format($cart->show_total() - $cat_deduction)); } } // end cat discount mod but get errors like: line 80 being $cat_qty_discount = new ot_cat_qty_discount; But even if this worked id rather not have to use something like: $cat_deduction = $cat_qty_discount->display_discounts(); as this would generate the text messages in the shopping cart box anyway which isnt what i want. I just want the discount amount to play with instead. Any suggestions about generating the discount value without upsetting the order object ? thanks well, you can access the order object from anywhere as it is a session registered object provided it is instantiated with $order = new order; normally that is done in checkout shipping, checkout payment etc. when it is instantiated it automatically fills itself with the cart contents. I am not sure how your shipping estimates conflict with that, what errors are given? Quote Treasurer MFC Link to comment Share on other sites More sharing options...
ryanm527 Posted March 22, 2006 Share Posted March 22, 2006 I have installed the contribution, following the directions - however I get this error on the homepage: Warning: main(DIR_WS_FUNCTIONScategory_discount.php): failed to open stream: No such file or directory in /home/restaurant/www/www/index.php on line 13 Warning: main(DIR_WS_FUNCTIONScategory_discount.php): failed to open stream: No such file or directory in /home/restaurant/www/www/index.php on line 13 Warning: main(): Failed opening 'DIR_WS_FUNCTIONScategory_discount.php' for inclusion (include_path='.:/usr/local/lib/php') in /home/restaurant/www/www/index.php on line 13 Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/restaurant/www/www/index.php:13) in /home/restaurant/www/www/includes/functions/sessions.php on line 67 Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/restaurant/www/www/index.php:13) in /home/restaurant/www/www/includes/functions/sessions.php on line 67 I found the installation guide a little confusing, so it is entirely possible that I made a mistake, or followed one of the updates incorrectly. Any guidance would be very appreciated! Thanks! Quote Link to comment Share on other sites More sharing options...
boxtel Posted March 23, 2006 Author Share Posted March 23, 2006 I have installed the contribution, following the directions - however I get this error on the homepage: Warning: main(DIR_WS_FUNCTIONScategory_discount.php): failed to open stream: No such file or directory in /home/restaurant/www/www/index.php on line 13 Warning: main(DIR_WS_FUNCTIONScategory_discount.php): failed to open stream: No such file or directory in /home/restaurant/www/www/index.php on line 13 Warning: main(): Failed opening 'DIR_WS_FUNCTIONScategory_discount.php' for inclusion (include_path='.:/usr/local/lib/php') in /home/restaurant/www/www/index.php on line 13 Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/restaurant/www/www/index.php:13) in /home/restaurant/www/www/includes/functions/sessions.php on line 67 Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/restaurant/www/www/index.php:13) in /home/restaurant/www/www/includes/functions/sessions.php on line 67 I found the installation guide a little confusing, so it is entirely possible that I made a mistake, or followed one of the updates incorrectly. Any guidance would be very appreciated! Thanks! do not include files before the inclusion of application_top. now it does not recognize DIR_WS_FUNCTIONS which is handled by that. Quote Treasurer MFC Link to comment Share on other sites More sharing options...
delb Posted March 24, 2006 Share Posted March 24, 2006 Is there anyway to make this contrib work on items with attributes assigned to them. I can make it function on items without them, but not with. Any help would be awesome! Quote Link to comment Share on other sites More sharing options...
boxtel Posted March 25, 2006 Author Share Posted March 25, 2006 Is there anyway to make this contrib work on items with attributes assigned to them. I can make it function on items without them, but not with. Any help would be awesome! believe that was addressed in post 53 Quote Treasurer MFC Link to comment Share on other sites More sharing options...
delb Posted March 25, 2006 Share Posted March 25, 2006 believe that was addressed in post 53 My apologies, my search must not have contained the correct terms, or I must have misspelled them. In any event thanks! Quote Link to comment Share on other sites More sharing options...
EidolonNight Posted April 10, 2006 Share Posted April 10, 2006 Hi Amanda! I am so happy that your contrib. now handles products with attributes as per post #53. I would like to try and take it another step and have the discount apply to products whos attributes do not change the product price. In my store we sell photos that are matted and framed. Our standard product is a matted photo for $18.00. You may choose to have it framed for $17.00 additional. OR You may choose to order the photo only (without mats) for $5.95. There are other options but they are a matter of mat color and do not change the price. In these two examples the options will change the original product price... My category discount will give a $3.00 discount on each photo if more than one photo is ordered. So, if two photos are ordered for $5.95 the new price is $2.95, that's not ok! So what I'm trying to do is have the module not apply the discount if the original product price has changed. What I don't know is, where to apply the IF statement. Can it be added to the catalog/includes/module/order_total/ot_cat_qty_dicount.php? Anyway, I can't get it to work yet but I will continue to work it out, please feel free to post any suggestions. Thank you Quote James Tomasello Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.