Forums / Addon Shipping Modules / US and rest of the world shipping configuration

US and rest of the world shipping configuration

Started by keneso on 20 Jan 2016, 10:38 AM · Views: 3,827

Results 1 to 20 of 25
20 Jan 2016, 10:38 AM
#1
keneso avatar

keneso

Totally Zenned

Join Date:
May 2009
Posts:
1,273
Plugin Contributions:
3

US and rest of the world shipping configuration

Hi

I need to set up shipping for a US based business for which I have configured the "table rate" for US shipping prices, and need to set for the international (rest of the world) shipping, I downloaded "USPS K8" module to get the quotes for that.

I also need to set free shipping for orders over a given amount, for which I configured the "free shipping options".

I'd need to keep the table rate for US, and use the USPS for the international, and I am not sure I understand how to best deal with it.

The packages are small in size, and weight (items are scarves).

Please advise me on the best approach so that US customers have the "table rate", and the rest of the world gets the "USPS" quotes, and both will benefit from "free shipping".

Thank you

20 Jan 2016, 11:52 AM
#2
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: US and rest of the world shipping configuration

So because the described criteria is purely destination based and or total value of purchase based, this becomes a relatively easy series of logic....

The logic is applied typically at the onset of the applicable shipping code.

Table rate enabled: if admin enabled, destination is US (zone) and below your price threshold (could be unique for US shipments, but if not consistent for US and international will complicate the free shipping part). All other conditions, disabled.
USPS: if admin enabled, destination is outside US (zone based) and below price threshold (could be unique for international, but will complicate the free shipping part). All other conditions, disabled.
Free shipping: if price regardless of destination, then enabled if enabled in admin and total price is at or above the price threshold. If individual for US and international, then enabled if enabled in admin and either of the following, US destination and price at or above US threshold or international destination and price is at or above international price...

This method would eliminate the ability to pick between free shipping or the applicable shipping method for the destination...

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

20 Jan 2016, 4:20 PM
#3
keneso avatar

keneso

Totally Zenned

Join Date:
May 2009
Posts:
1,273
Plugin Contributions:
3

Re: US and rest of the world shipping configuration

Thank you.

I know my English comprehension is causing me some difficulties ... so please bare with me.

What do you mean by " if admin enabled" and "then enabled if enabled in admin"?

Let me say what I have done so far:

Set 3 zones in
locations/taxes > zone definitions
-- California:
--------- country: USA - zone: California
-- USA:
--------- country: USA - zone: All zones
-- International:
--------- country: All countries - zone: All zones

Set tax rates
locations/taxes > tax rates
-- California:
--------- priority: 0 - zone: California - tax rate: 8.5%
-- USA:
--------- priority: 0 - zone: USA - tax rate: 0%
-- International:
--------- priority: 0 - zone: International - tax rate: 0%

Set shipping
modules > shipping > table rate [the circle is yellow] obviously I don't know what setting to correct.
-- shipping table: 1:5.00,4:8.00,5:10.00,10000:9%
-- table method: item
-- handlung fee: 0
-- handling per: order
-- tax class: none
-- tax basis: shipping
-- shipping zone: USA
-- sort order: 0

modules > shipping > free shipping options
-- enable Free Options Shipping: true
-- shipping Cost: 0
-- handling Fee: 0
-- total >=: 100
-- total <=:
-- weight >=:
-- weight <=
-- item count >=
-- item count <=
-- tax class: none
-- tax basis: shipping
-- shipping zone: none
-- sort order: 0

modules > shipping > USPS
Have not configure anything yet (still in local), and the default settings are in place, I guess I'd need to configure only the international rates only?

20 Jan 2016, 5:00 PM
#4
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: US and rest of the world shipping configuration

> keneso:

Thank you.

I know my English comprehension is causing me some difficulties ... so please bare with me.

What do you mean by " if admin enabled" and "then enabled if enabled in admin"?

modules > shipping > free shipping options
-- enable Free Options Shipping: true
-- shipping Cost: 0
-- handling Fee: 0
-- total >=: 100
-- total <=:
-- weight >=:
-- weight <=
-- item count >=
-- item count <=
-- tax class: none
-- tax basis: shipping
-- shipping zone: none
-- sort order: 0

modules > shipping > USPS
Have not configure anything yet (still in local), and the default settings are in place, I guess I'd need to configure only the international rates only?

To address just the few things above...

If admin enabled or if enabled in admin are the same thing... Notice above that for free shipping options, the first line is: enable Free Options Shipping. The constant that is set there represents whether the option is enabled in admin or not. (Ie. if you are in your admin panel and disabled free shipping, would you want a customer to be offered free shipping?) I would think the answer would be no. :)

The "words" (sometimes also called pseudo-code) identify the criteria that would be needed to be met and "translated" to computer code.
For the above free shipping, it is set to show when the total is >= 100 regardless of the destination. Basically that portion of the code takes care of itself and will be offered to the customer if the criteria is met of the total price equaling or exceeding the entry of 100 regardless of the destination zone.

As for USPS, yes if that "clone" will only be used for international purposes, then basically the code takes care of itself to not process through the US shipping (don't forget to consider what you define as US, because there are territories and other destinations that are part of the US, but not part of say the lower continental 48 states, or the 50 united states, etc...) and will only need to be setup for the international part.

Now as far as "specific" code... In ZC 1.5.4, the flat rate shipper code is in part:

// class constructor 
     function flat() { 
       global $order, $db; 
  
       $this->code = 'flat'; 
       $this->title = MODULE_SHIPPING_FLAT_TEXT_TITLE; 
       $this->description = MODULE_SHIPPING_FLAT_TEXT_DESCRIPTION; 
       $this->sort_order = MODULE_SHIPPING_FLAT_SORT_ORDER; 
       $this->icon = ''; 
       $this->tax_class = MODULE_SHIPPING_FLAT_TAX_CLASS; 
       $this->tax_basis = MODULE_SHIPPING_FLAT_TAX_BASIS; 
  
       // disable only when entire cart is free shipping 
       if (zen_get_shipping_enabled($this->code)) { 
         $this->enabled = ((MODULE_SHIPPING_FLAT_STATUS == 'True') ? true : false); 
       } 
  
       if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_FLAT_ZONE > 0) ) { 
         $check_flag = false; 
         $check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_FLAT_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id"); 
         while (!$check->EOF) { 
           if ($check->fields['zone_id'] < 1) { 
             $check_flag = true; 
             break; 
           } elseif ($check->fields['zone_id'] == $order->delivery['zone_id']) { 
             $check_flag = true; 
             break; 
           } 
           $check->MoveNext(); 
         }

         if ($check_flag && $_SESSION['cart']->show_total() >= '100') { // This could be written to support the way the free shipper code is written so that as free shipper is modified, so is this section...
           $check_flag = false;
         }
  

         /* // ie: Below is a portion of the free shipping options code for the total price of the cart.  It deactivates this method of shipping if the current method has been identified as possible to be active and if the free shipping method is active.
         if($check_flag) {
          switch (true) { 
           case ((MODULE_SHIPPING_FREEOPTIONS_TOTAL_MIN !='' and MODULE_SHIPPING_FREEOPTIONS_TOTAL_MAX !='')): 
 // free shipping total should not need adjusting 
 //            if (($_SESSION['cart']->show_total() - $_SESSION['cart']->free_shipping_prices()) >= MODULE_SHIPPING_FREEOPTIONS_TOTAL_MIN and ($_SESSION['cart']->show_total() - $_SESSION['cart']->free_shipping_prices()) <= MODULE_SHIPPING_FREEOPTIONS_TOTAL_MAX) { 
             if (($_SESSION['cart']->show_total()) >= MODULE_SHIPPING_FREEOPTIONS_TOTAL_MIN and ($_SESSION['cart']->show_total()) <= MODULE_SHIPPING_FREEOPTIONS_TOTAL_MAX) { 
               $check_flag = false; 
             } 
             break; 
           case ((MODULE_SHIPPING_FREEOPTIONS_TOTAL_MIN !='')): 
 //            if (($_SESSION['cart']->show_total() - $_SESSION['cart']->free_shipping_prices()) >= MODULE_SHIPPING_FREEOPTIONS_TOTAL_MIN) { 
             if (($_SESSION['cart']->show_total()) >= MODULE_SHIPPING_FREEOPTIONS_TOTAL_MIN) { 
               $check_flag = false; 
             } 
             break; 
           case ((MODULE_SHIPPING_FREEOPTIONS_TOTAL_MAX !='')): 
//            if (($_SESSION['cart']->show_total() - $_SESSION['cart']->free_shipping_prices()) <= MODULE_SHIPPING_FREEOPTIONS_TOTAL_MAX) { 
             if (($_SESSION['cart']->show_total()) <= MODULE_SHIPPING_FREEOPTIONS_TOTAL_MAX) { 
               $check_flag = false; 
             } 
             break; 
           } 
         } 
       

         */
         if ($check_flag == false) { 
           $this->enabled = false; 
         } 
       } 
     } 

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

20 Jan 2016, 5:46 PM
#5
keneso avatar

keneso

Totally Zenned

Join Date:
May 2009
Posts:
1,273
Plugin Contributions:
3

Re: US and rest of the world shipping configuration

mc12345678:

(Ie. if you are in your admin panel and disabled free shipping, would you want a customer to be offered free shipping?) I would think the answer would be no. :)

;)
Yes I got that part some time back.

What confused me, and now I think I am understanding is you were suggesting to do some coding, and put in plain text what the reasoning (logic) to follow, right?

If above is correct no wonder I had hard time, at least I do understand some English as opposed to coding!

So please see if I got it correctly:
the settings I have are fine (save the USPS that need to be set for international), and I need to add the code you supplied to modules/shipping/flat.php

If above is correct I then have a few questions:

Shall I add the code to the flat.php file, thus I need to enable the "flat rate" module instead of "table rate" module?
Or was it an overlook and I should add it to the modules/shipping/table.php
If it was an overlook where in table.php I need to add the code?

Either case, do I need to uncomment the commented part of code (blu in your previous post), and use both the red, and blue part of the code?

In the red part of code is the number 100 the value I put in the "free shipping options" setting in admin, to be more clear, if I change that value in the admin, I need to change it in the code as well, right?

Notice the if if, I am learning :laugh:

20 Jan 2016, 6:33 PM
#6
rixstix avatar

rixstix

Totally Zenned

Join Date:
Aug 2009
Location:
North Idaho, USA
Posts:
2,015
Plugin Contributions:
0

Re: US and rest of the world shipping configuration

I may have misunderstood something, but....

Is table rate working for you? If yes, do nothing
Is free shipping options for orders over $xxx USA only, International only or everyone. set zone appropropriately.
Is USPS for International only, If yes, set zone to International and configure the International classes you wish to offer.

If i missed something, just ignore my comments above.
Note: Freeshipping is not the same as FreeShippingOptions

Rick
RixStix (dot) com
aka: ChainWeavers (dot) com

20 Jan 2016, 7:29 PM
#7
keneso avatar

keneso

Totally Zenned

Join Date:
May 2009
Posts:
1,273
Plugin Contributions:
3

Re: US and rest of the world shipping configuration

RixStix:

I may have misunderstood something, but....

Thank you.

I don't think you misunderstood, I did a couple tests (need to do some more) with the settings I have, and seems to behave as I need.

Do you have any idea about why the yellow dot on "table rate" what setting am I doing wrong?

20 Jan 2016, 7:51 PM
#8
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: US and rest of the world shipping configuration

keneso:

Thank you.

I don't think you misunderstood, I did a couple tests (need to do some more) with the settings I have, and seems to behave as I need.

Do you have any idea about why the yellow dot on "table rate" what setting am I doing wrong?

The yellow comes from this line in admin/modules.php:

                      echo ' ' . ((!empty($module->enabled) && is_numeric($module->sort_order)) ? zen_image(DIR_WS_IMAGES . 'icon_status_green.gif') : ((empty($module->enabled) && is_numeric($module->sort_order)) ? zen_image(DIR_WS_IMAGES . 'icon_status_yellow.gif') : zen_image(DIR_WS_IMAGES . 'icon_status_red.gif'))); 
244  

Which effectively indicates that the enabled status of the module evaluates to a false condition ($module->enabled doesn't exist or equals false) and that the sort order is non-numeric (in your case 0)...

I believe the "solution" to the yellow is to make the sort order non-zero, but if I remember correctly in ZC 1.5.4 and below if a shipping module's sort order is non-zero, then all need to be non-zero and also unique (not the same for all of them). If correct, this condition is resolved in ZC 1.5.5 allowing all to be zero or all to be the same value. I could be thinking about payment modules though...

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

20 Jan 2016, 7:58 PM
#9
keneso avatar

keneso

Totally Zenned

Join Date:
May 2009
Posts:
1,273
Plugin Contributions:
3

Re: US and rest of the world shipping configuration

mc12345678:

The yellow comes from this line in admin/modules.php:

Which effectively indicates that the enabled status of the module evaluates to a false condition ($module->enabled doesn't exist or equals false) and that the sort order is non-numeric (in your case 0)...

I believe the "solution" to the yellow is to make the sort order non-zero

Thank you.

You are killing me with all the extra info (code), please don't get me wrong I appreciate, as I do learn (try to) from every bit of extra info, it's just my head that is limited!

I changed the 0 to 1, but didn't turn green.

20 Jan 2016, 7:59 PM
#10
ajeh avatar

ajeh

Oba-san

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

Re: US and rest of the world shipping configuration

You are seeing the yellow icon because you have a Zone set ... :smile:

A Shipping module will show as Yellow when either:
A module is installed but NOT enabled in the Admin
A valid Zone is set

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!

20 Jan 2016, 8:26 PM
#11
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: US and rest of the world shipping configuration

Ajeh:

You are seeing the yellow icon because you have a Zone set ... :smile:

A Shipping module will show as Yellow when either:
A module is installed but NOT enabled in the Admin
A valid Zone is set

I know you're right, I'm just not seeing where that evaluation (or "reassignment") occurs to give that result... Grr...

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

20 Jan 2016, 8:39 PM
#12
rixstix avatar

rixstix

Totally Zenned

Join Date:
Aug 2009
Location:
North Idaho, USA
Posts:
2,015
Plugin Contributions:
0

Re: US and rest of the world shipping configuration

keneso:

Thank you.
I don't think you misunderstood, I did a couple tests (need to do some more) with the settings I have, and seems to behave as I need.
Do you have any idea about why the yellow dot on "table rate" what setting am I doing wrong?

The yellow dot question was answered by the expert.
Sometimes all that is necessary is to use the code as designed instead of modifying code and making a small nightmare for yourself when upgrade time comes around.

It doesn't sound like you need to fiddle with any code modifications to accomplish what you described.

Rick
RixStix (dot) com
aka: ChainWeavers (dot) com

20 Jan 2016, 9:11 PM
#13
ajeh avatar

ajeh

Oba-san

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

Re: US and rest of the world shipping configuration

mc12345678:

I know you're right, I'm just not seeing where that evaluation (or "reassignment") occurs to give that result... Grr...

Don'tcha hate when the DrByte wizardry kicks in and you have a user moment? I am ... :lookaroun

But, that is how that works and at the moment it is escaping me as to the magic used for the Zone setting triggering the yellow icon but that is what I told him to do ... ain't he a smart guy? :cool:

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!

20 Jan 2016, 9:37 PM
#14
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: US and rest of the world shipping configuration

Ajeh:

Don'tcha hate when the DrByte wizardry kicks in and you have a user moment? I am ... :lookaroun

But, that is how that works and at the moment it is escaping me as to the magic used for the Zone setting triggering the yellow icon but that is what I told him to do ... ain't he a smart guy? :cool:

Absolutely on both accounts... I mean I even went searching for cases where the zone constant for the shipping module was split out to apply to any such shipping module... Found some inventive notifiers in ZC 1.6 by that method, but nothing that said: hey you. Go yellow. :P

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

20 Jan 2016, 9:44 PM
#15
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: US and rest of the world shipping configuration

@keneso,

Yeah, the pseudocode (logic) provided is apparently already addressed pretty much by the fab ZC team. The answer to the question of the color coding was that it was intended to use one or the other, not both. But the code section just above the added code indirectly took care of the situation. Upcoming code changes more directly control the situation rather than relying on the lack of assignment of being enabled to indicate that the shipping method is disabled...

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

20 Jan 2016, 10:42 PM
#16
keneso avatar

keneso

Totally Zenned

Join Date:
May 2009
Posts:
1,273
Plugin Contributions:
3

Re: US and rest of the world shipping configuration

Thank you all.

Greatly appreciated your comments.

I hope in the next release the whole shipping, and zones will be more "idiot" friendly!

21 Jan 2016, 12:37 AM
#17
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: US and rest of the world shipping configuration

mc12345678:

I even went searching for cases where the zone constant for the shipping module was split out to apply to any such shipping module... but nothing that said: hey you. Go yellow. :P
It is a bit obscure. Here's how it works: The admin modules screen has no knowledge of any actual "address", so when it runs the various status tests on each module and hits the "does the provided address have any zone restrictions disallowing this module to be used?" it trips the yellow flag like this:

  • a zone restriction exists, so now we have to test whether the provided address falls within that zone
  • since the provided address (there isn't one) doesn't fall within that zone (it can't), the module trips the $this->enabled variable to be false.
    And that's what triggers the yellow icon in relation to zones. At least in v1.3.x-1.5.5 anyway.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

21 Jan 2016, 10:03 AM
#18
keneso avatar

keneso

Totally Zenned

Join Date:
May 2009
Posts:
1,273
Plugin Contributions:
3

Re: US and rest of the world shipping configuration

Thank you for the explanation DrByte.

Talking from non coder perspective, and as average user that is very confusing - am not talking about the process leading to the yellow flag, but to the fact that under zone definition that yellow flag means some misconfiguration, or incomplete one, whereas in the shipping means something else, and an average user has no clue, and starts worrying.

Something to consider in the new version (IMHO).

21 Jan 2016, 10:07 AM
#19
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: US and rest of the world shipping configuration

keneso:

Thank you for the explanation DrByte.

Talking from non coder perspective, and as average user that is very confusing - am not talking about the process leading to the yellow flag, but to the fact that under zone definition that yellow flag means some misconfiguration, or incomplete one, whereas in the shipping means something else, and an average user has no clue, and starts worrying.

Something to consider in the new version (IMHO).
Understood. I suspect that to make it indicate zone status differently might require changing code in every individual module.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

21 Jan 2016, 11:35 AM
#20
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: US and rest of the world shipping configuration

DrByte:

Understood. I suspect that to make it indicate zone status differently might require changing code in every individual module.

I believe that true; however, perhaps an easier method might be to use a little space at the top to provide a key of what the indicators mean. (One module change, no other shipping modules affected and no "developed" modules affected) or every module affected having more of a description in the "data" area or additional text adjacent to the shipping name when those conditions are met...

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