We will be doing some site maintenance and need to take the site down for 10 minutes.

Site will go down at 19:00 UTC

Forums / Discounts/Coupons, Gift Certificates, Newsletters, Ads / Apply coupon discount to more than one line item

Apply coupon discount to more than one line item

Started by keyconn on 1 Jun 2015, 6:41 PM · Views: 6,470

Results 21 to 23 of 23
2 Jun 2015, 10:04 PM
#21
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Apply coupon discount to more than one line item

This should work for you ...

Edit the file:
/includes/modules/order_total/ot_coupon.php

and add the code in RED:

        if (strval($orderTotalDetails['orderTotal']) >= $coupon->fields['coupon_minimum_order'])
        {
[B]if ($coupon->fields['coupon_type'] == 'F' || $coupon->fields['coupon_type'] == 'O') {
  global $cart;
  $products = $_SESSION['cart']->get_products();
  $coupon_product_count = 0;
  for ($i=0; $i<sizeof($products); $i++) {
    if (is_product_valid($products[$i]['id'], $coupon->fields['coupon_id'])) {
      $coupon_product_count += $_SESSION['cart']->get_quantity($products[$i]['id']);
    }
  }
//$messageStack->add_session('checkout_payment', 'Coupon cont: ' . $coupon_product_count, 'caution');
}
[/B]          switch($coupon->fields['coupon_type'])

Then edit the line:

            case 'F':
              $od_amount['total'] = zen_round($coupon->fields['coupon_amount'] * ($orderTotalDetails['orderTotal']>0)[B] * $coupon_product_count[/B], $currencyDecimalPlaces);
              $od_amount['type'] = $coupon->fields['coupon_type']; // amount off 'F' or amount off and free shipping 'O'
              $ratio = $od_amount['total']/$orderTotalDetails['orderTotal'];
              break;

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

3 Jun 2015, 7:04 PM
#22
keyconn avatar

keyconn

New Zenner

Join Date:
Apr 2015
Location:
Pennsylvania, USA
Posts:
21
Plugin Contributions:
0

Re: Apply coupon discount to more than one line item

Works beautifully! Thank You!

3 Jun 2015, 10:04 PM
#23
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Apply coupon discount to more than one line item

You are most welcome ... thanks for the update that this works for you ...

I have built this into Zen Cart v1.6 the ability to have this feature and set it per Discount Coupon ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!