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

Free Shipping with Multi Vendor Shipping Module MVS

If you attempt to offer free shipping with MVS you will get ERROR_NO_SHIPPING_SELECTED_SELECTED. To fix this problem, open vendor_shipping.php, located in includes/modules.

Replace

<td class=”main” width=”100%”><?php echo sprintf(FREE_SHIPPING_DESCRIPTION, $currencies->format(MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER)) . tep_draw_hidden_field(‘shipping’, ‘free_free’); ?></td>

with

<td class=”main” width=”100%”><?php echo sprintf(FREE_SHIPPING_DESCRIPTION, $currencies->format(MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER)) . tep_draw_hidden_field(‘shipping_’ . $vendor_id, ‘free_free_0′) . tep_draw_hidden_field(‘products_’ . $vendor_id, implode(“_”, $products_ids));?></td>

Bookmark and Share