PDA

View Full Version : CCGV(trad)



michael_s
03-04-2010, 04:00 PM
Fix for products with attributes, applies to all versions that I'm aware of.

The problem:
Products with attributes are not discounted if you apply a discount for just one category. The reason is the current code strips the attributes prior to doing the cart qty check, the cart cannot find the item because the attribute has been stripped, so it sets the qty as 0 and no discount is applied for that product. I believe this affects regular attributes and definitely affects anyone who uses the option type attributes contribution. Recommended that you combine this with the fix by softagz directly below to fix the mutliple category issue as well.

After a little experimenting I found the fix is simple, just change these two lines of code in includes/modules/order_total/ot_coupon.php

CHANGE
//$pr_c = $order->products[$i]['final_price']*$order->products[$i]['qty'];
$pr_c = $this->product_price($order->products[$i]['id']);

TO:
//$pr_c = $order->products[$i]['final_price']*$order->products[$i]['qty'];
$pr_c = $this->product_price($order->products[$i]['id']);


CHANGE:
function get_product_price($product_id) {
global $cart, $order;
$products_id = tep_get_prid($product_id);
// products price
$qty = $cart->contents[$product_id]['qty'];

TO:
function get_product_price($product_id) {
global $cart, $order;
// products price
$qty = $cart->contents[$product_id]['qty']; $products_id = tep_get_prid($product_id);

More... (http://addons.oscommerce.com/info/4135)