Discount coupon code amount greater than cart order total

When discount coupon code amount is greater than cart order total, calculated order total is wrong. For example coupon code amount is $40.63 and cart order total is $35.95. Here are two steps to fix this problem. In ot_coupon.php make these changes.

1. In function calculate_deductions function comment one line.

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

          // comment this line so that the actual coupon amount is propagated.
          //if ($od_amount['total'] > $orderTotal) $od_amount['total'] = $orderTotal;
          //
          switch ($this->calculate_tax) {
            case 'None':
              if ($this->include_tax == 'true') {
                reset($order->info['tax_groups']);
                foreach ($order->info['tax_groups'] as $key=>$value) {
                  $od_amount['tax_groups'][$key] = $order->info['tax_groups'][$key] * $ratio;
                }
              }
            break;
            case 'Standard': ...

2. Comment three lines in process function

  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'];

      //comment these lines
      //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']);
    }
  }

Finally check discount coupon configuration in admin to make sure it does not include shipping.

Bookmark and Share

Automated Order Export System – Zencart, Creloaded, Oscommerce

Very fast and easy export of all order data you need.

Need to export order data? Efficient Order Export System performs the task of export in a very fast and effective manner – it will take you literally minutes, if not seconds, to set up export profile and get the files with order data in CSV or TAB format. Also the system lets you automate the order export process – you will just need to create an export profile and configure a cron job to launch the profile url according to your preferred schedule.

  • is easy to use;
  • export invoice in pdf;
  • performs export very rapidly;
  • uses little server resources;
  • exports all order information;
  • lets you choose orders with which status to export (it is possible to export orders with all statuses at once)
  • lets you export either all order information or only specific one;
  • enables you to launch export profiles via url and by cron;
  • allows to save export file to the local server,  email, or upload it via ftp to any other;
  • lets you specify date format for dates within export output file;
  • supports CSV, TAB and XML formats;
Bookmark and Share