If this is your first visit, check our documentation. To post, register or login.
Forums / Configuring the Zen Cart Admin / Managing Customers and Orders / Minimum Order plugin converted to Maximum Order

Minimum Order plugin converted to Maximum Order

Started by kadeepro on 7 May 2020, 9:20 PM · Views: 1,367

Results 1 to 2 of 2
7 May 2020, 9:20 PM
#1
kadeepro avatar

kadeepro

New Zenner

Join Date:
Sep 2017
Location:
White City
Posts:
15
Plugin Contributions:
0

Minimum Order plugin converted to Maximum Order

Due to postal regulations foreign orders have a max order value of $2500.

So I am trying to use the Minimum Order plugin that i converted to work as a Maximum Order plugin and it works.

The problem I am running in to is I only want the plugin to run on International orders. I haven't been able to make the plugin only work for International orders.

I thought something like this would work but it just breaks my site. (My International zone is 2)

// bof: International Shipping
if (!IS_ADMIN_FLAG) {
global $cart;
if ($this->enabled == true && $check->fields['zone_id'] = 2) {
$this->enabled = true;
} else {
$this->enabled = false;
}
}
// eof: International Shipping

Any help how to add a international only function to the plugin would be very helpful.
I am really surprised this is something that there is not a fix for already.
Thanks in advance.

7 May 2020, 10:24 PM
#2
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Minimum Order plugin converted to Maximum Order

kadeepro:

Due to postal regulations foreign orders have a max order value of $2500.

So I am trying to use the Minimum Order plugin that i converted to work as a Maximum Order plugin and it works.

The problem I am running in to is I only want the plugin to run on International orders. I haven't been able to make the plugin only work for International orders.

I thought something like this would work but it just breaks my site. (My International zone is 2)

// bof: International Shipping
if (!IS_ADMIN_FLAG) {
global $cart;
if ($this->enabled == true && $check->fields['zone_id'] = 2) {
$this->enabled = true;
} else {
$this->enabled = false;
}
}
// eof: International Shipping

Any help how to add a international only function to the plugin would be very helpful.
I am really surprised this is something that there is not a fix for already.
Thanks in advance.

For one, the "check" does an assignment rather than a validation because of a missing "=":

// bof: International Shipping
 if (!IS_ADMIN_FLAG) {
global $cart;
if ($this->enabled == true && $check->fields['zone_id'] == 2) {
$this->enabled = true;
} else {
$this->enabled = false;
}
 }
 // eof: International Shipping

There is though a "method" to evaluate whether a destination is international or not as seen in the checkout_shipping header file:

  $pass = true;
  $free_shipping = false;
  if ( defined('MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING') && (MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING == 'true') ) {
    $pass = false;

    switch (MODULE_ORDER_TOTAL_SHIPPING_DESTINATION) {
      case 'national':
        if ($order->delivery['country_id'] == STORE_COUNTRY) {
          $pass = true;
        }
        break;
      case 'international':
        if ($order->delivery['country_id'] != STORE_COUNTRY) {
          $pass = true;
        }
        break;
      case 'both':
        $pass = true;
        break;
    }

    if ( ($pass == true) && ($_SESSION['cart']->show_total() >= MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER) ) {
      $free_shipping = true;
    }
  }

While the above relates to free shipping, the principle is the same, basically if the delivery location isn't in the same country as the store, then it is obviously "international" to the store... There perhaps could be other such associations, but it is more "generic" (and easier to maintain) to identify nationality as related to the store rather than some other adjustable defined area...

Anyways, when the store "breaks" with trying the above modified code, there should be a myDebug log file in the logs directory (for ZC 1.5.1 and above) the contents of which should help identify the issue and a potential solution. I would further suggest that this discussion be carried out in the associated forum thread if one exists for that plugin, that way those more familiar with the plugin could help and/or benefit from the discussion. I am not specifically familiar with it to guide much further.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...