Results 1 to 10 of 10
  1. #1
    Join Date
    Jun 2006
    Posts
    298
    Plugin Contributions
    0

    Default Need help with group discount + restricted coupon

    I'm having some trouble achieving the correct calculations with my order total modules.

    We have a discount group that gets 3% off all orders.

    I have set up a $10 coupon that is valid only on one product, with no minimum purchase.

    If I restrict the coupon to the product, it calculates $10 minus the group discount, instead of applying the full $10.

    Example:

    Product A $10.00
    Product B $1.00
    Coupon restricted to product A

    Order total shows:

    Sub-Total: CDN $11.00
    Group Discount - 3%: -CDN $0.33
    Discount Coupon: wy487nwb: -CDN $9.67
    Warehouse Pickup: CDN $0.00
    13% Tax (ON): CDN $0.09
    Total: CDN $0.76

    Why is the coupon deducting the group discount from the coupon amount?

    If I remove the restriction, the coupon applies correctly.

    My order total modules sort order:
    100 Sub-Total
    102 Group Discount
    103 Discount Coupon
    200 Shipping
    300 Tax
    310 Gift Certificates
    900 Total

  2. #2
    Join Date
    Jun 2006
    Posts
    298
    Plugin Contributions
    0

    Default Re: Need help with group discount + restricted coupon

    Also, if the group discount is larger than $10, it won't allow you to apply the coupon at all.

  3. #3
    Join Date
    Jun 2006
    Posts
    298
    Plugin Contributions
    0

    Default Re: Need help with group discount + restricted coupon

    I can't reorder the group discount to apply after the coupon, because then any percentage coupons are calculated on the full subtotal instead of the subtotal minus the group discount. I guess I'm kind of stuck.

    In a perfect world, what *should* happen is that restricted dollar amount coupons should be applied to the product price minus the group discount. NOT the entire subtotal minus the group discount. I'm sure that's not something that would be an easy fix though...

  4. #4
    Join Date
    Jun 2006
    Posts
    298
    Plugin Contributions
    0

    Default Re: Need help with group discount + restricted coupon

    What I'd like to try is to change the code so that when the coupon is for a dollar amount AND there is more than one product, the coupon will ignore the group discount. Can anyone help?

    I'm assuming it would be in this function?

    Code:
     /**
       * Method used to produce final figures for deductions. This information is used to produce the output<br>
       * shown on the checkout pages
       *
       */
      function process() {
        global $order, $currencies;
        $order_total = $this->get_order_total();
        $od_amount = $this->calculate_deductions($order_total['total']);
        $this->deduction = $od_amount['total'];
        if ($od_amount['total'] > 0) {
          reset($order->info['tax_groups']);
          $tax = 0;
          while (list($key, $value) = each($order->info['tax_groups'])) {
            if ($od_amount['tax_groups'][$key]) {
              $order->info['tax_groups'][$key] -= $od_amount['tax_groups'][$key];
              $tax += $od_amount['tax_groups'][$key];
            }
          }
          if ($od_amount['type'] == 'S') $order->info['shipping_cost'] = 0;
          $order->info['total'] = $order->info['total'] - $od_amount['total'];
          if (DISPLAY_PRICE_WITH_TAX != 'true') {
            $order->info['total'] -= $tax;
          }
          $order->info['tax'] = $order->info['tax'] - $tax;
          //      if ($this->calculate_tax == "Standard") $order->info['total'] -= $tax;
          if ($order->info['total'] < 0) $order->info['total'] = 0;
          $this->output[] = array('title' => $this->title . ': ' . $this->coupon_code . ' :',
                                  'text' => '-' . $currencies->format($od_amount['total']),
                                  'value' => $od_amount['total']);
        }
      }
      /**

  5. #5
    Join Date
    Jun 2006
    Posts
    298
    Plugin Contributions
    0

    Default Re: Need help with group discount + restricted coupon

    What I need is:

    If the coupon type is 'F' (flat amount)
    AND there is more than 1 product in the cart
    AND the customer is in a discount group
    THEN the coupon = the full coupon amount up to 100% of the subtotal price

    I think I would need to change this code... But not sure how.

    Code:
    } elseif ($coupon->fields['coupon_type'] == 'F') {
                $od_amount['total'] = round($coupon->fields['coupon_amount'] * ($orderTotal>0), 3);
                $od_amount['type'] = 'F';
                $ratio = $od_amount['total']/$orderTotal;
              }

  6. #6
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Need help with group discount + restricted coupon

    What happens if you change the Modules ... Order Total ... sort orders to the defaults:
    100 Sub-Total
    102 Group Discount 290
    103 Discount Coupon 280
    200 Shipping
    300 Tax
    310 Gift Certificates 840
    900 Total
    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: v1.5.5]
    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!

  7. #7
    Join Date
    Jun 2006
    Posts
    298
    Plugin Contributions
    0

    Default Re: Need help with group discount + restricted coupon

    If I do that, then a percentage coupon is taken off the full subtotal instead of the subtotal after the group discount. I need the group discount to come off first, then the additional coupon discount to come off after that.

  8. #8
    Join Date
    Jun 2006
    Posts
    298
    Plugin Contributions
    0

    Default Re: Need help with group discount + restricted coupon

    Maybe it would be easier to edit the group pricing module to force the discount to be based off the product subtotal?

  9. #9
    Join Date
    Jun 2006
    Posts
    298
    Plugin Contributions
    0

    Default Re: Need help with group discount + restricted coupon

    Quote Originally Posted by abcisme View Post
    Maybe it would be easier to edit the group pricing module to force the discount to be based off the product subtotal?
    Ugh, that doesn't make proper sense either. I would still need the percentage coupons to be calculated after the group discount.

  10. #10
    Join Date
    Jun 2006
    Posts
    298
    Plugin Contributions
    0

    Default Re: Need help with group discount + restricted coupon

    Came up with a solution. This edit makes it so that if the coupon is a dollar amount AND is restricted to one product AND the customer is in a discount group, the coupon will deduct the value of the coupon MINUS the discount group percentage.

    This allows me to offer a full dollar amount coupon that is restricted to a single product and have it adjust the price if the customer is in a discount group. For example, a coupon for $10 off a $10 product will adjust to $9.70 if the customer gets a 3% discount, otherwise it will be $10.

    If you want to make sure it is the full amount, you can just restrict the coupon to a second product that is disabled. For example, if you want a coupon for $5 off a $10 product and you want group discount members to get the entire $5, you would restrict the coupon to the eligible product, then add a second restriction for a disabled product.

    Percentage coupons will be deducted from the subtotal AFTER the group discount (as long as your coupon order total module is after the group discount module).

    Code:
      
              } elseif ($coupon->fields['coupon_type'] == 'F') {
                  
                //IF customer is in a discount group
                //AND coupon code is dollar amount (not percentage)
                //AND coupon is only valid on one item
                //THEN coupon amount is the total coupon minus group discount
                //ELSE coupon amount is 100% of coupon value
    
                $group_query = $db->Execute("select customers_group_pricing from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$_SESSION['customer_id'] . "'");
                $cr_query = $db->Execute("select count(product_id) as total_restrictions from " . TABLE_COUPON_RESTRICT . " where coupon_id = '" . (int)$coupon->fields['coupon_id'] . "' and coupon_restrict = 'N' and category_id = '0'");
    
                if ($group_query->fields['customers_group_pricing'] != '0' && (int)$cr_query->fields['total_restrictions'] == 1) {
                    $group_percentage_query = $db->Execute("select group_percentage from " . TABLE_GROUP_PRICING . "
                                          where group_id = '" . (int)$group_query->fields['customers_group_pricing'] . "'");
                    $coupon->fields['coupon_amount'] -= $coupon->fields['coupon_amount'] * $group_percentage_query->fields['group_percentage']/100;
                }
                  
                $od_amount['total'] = round($coupon->fields['coupon_amount'] * ($orderTotal>0), 3);
                $od_amount['type'] = 'F';
                $ratio = $od_amount['total']/$orderTotal;
              }

 

 

Similar Threads

  1. Problem with custom Group Pricing and Discount Coupon
    By mvstudio in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 1
    Last Post: 2 Aug 2011, 04:20 PM
  2. Products Restricted to Certain Discount Group
    By impulse120 in forum Managing Customers and Orders
    Replies: 0
    Last Post: 17 Mar 2011, 08:24 PM
  3. Replies: 18
    Last Post: 12 Mar 2010, 06:37 PM
  4. Need help with 1st Discount coupon
    By zerocool in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 5
    Last Post: 29 May 2007, 01:10 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR