Kryptronic Software Support Forum

You are viewing this forum as a guest. Login to an existing account, or create a new account, to reply to topics and to create new topics.

#1 09-09-2011 09:04:12

ashley
Member
Registered: 08-16-2010
Posts: 41

Shipping cost based on country

I need to be able to set certain shipping costs based on their country, I'm going to be using DPD/interlink express. For example:

Belgium, France, Germany, Luxembourg, Netherlands, Rep Ireland  - 15
Italy, Spain, Czech Rep, Slovakia  - 20

Obviously I have a complete list,  but I need to set shipping based on where they're shipping it to. I've noticed there is zone-based shipping for Royal Mail & Parceforce... but those don't look like they do what I describe, it doesn't look like it's based on country.

Thanks in advance!

Last edited by ashley (09-09-2011 09:11:15)

Offline

 

#2 09-09-2011 09:46:58

vbsaltydog
Member
From: Florida
Registered: 05-02-2005
Posts: 947
Website

Re: Shipping cost based on country

You want to use a custom shipping script.


Latest CCP 7 XMods Available:


Offline

 

#3 09-09-2011 10:02:51

ashley
Member
Registered: 08-16-2010
Posts: 41

Re: Shipping cost based on country

vbsaltydog wrote:

You want to use a custom shipping script.

Thanks for the reply, but I was hoping for a little more detail. For example, what steps should be taken to achieve what I stated?

Offline

 

#4 09-09-2011 11:03:30

JDLS88
Moderator
From: Maryland, USA
Registered: 07-06-2011
Posts: 102
Website

Re: Shipping cost based on country

Go into the admin area. Under the third dropdown menu from the left, click Shipping. Then click on "Custome Shipping Methods".
There should be a list of a few pre-made custome shipping options (based on cost, quantity, weight, etc.), but nothing on location. So you'll have to create your own.

So at the top, click "Create: Add a new item". Give it an identifier and a name (can be more or less anything. Just for labeling and referencing purposes). Then under "Shipping Method PHP Content", paste this code into it:

Code:

<?php 


// +--
// | All custom shipping scripts work in the same way.  A global
// | variable named 'ecom.customship' contains the following PHP
// | array.  Array keys with value info:
// |
// | weight        => Total weight of items being shipped.
// | total         => Subtotal of items being shipped.
// | quantity      => Quantity of items being shipped.
// | stateprov     => Ship to state/province.
// | country       => Ship to country.
// | postalcode    => Ship to postal code.
// | rescom        => Ship to residential/commercial status.
// | shipstateprov => Ship origin state/province.
// | shipcountry   => Ship origin country.
// | shipzip       => Ship origin postal code.
// | packages      => An array containing all packages with
// |                  each package defined in it's own array
// |                  with keys: length, width, height, weight.
// | delinfo       => Delivery information array.
// | delitems      => An array containing all items with
// |                  each item id as a key and the item quantity 
// |                  as a value.
// |
// | This script must set a global variable named 
// | 'ecom.customship_response' which is an array in the 
// | following format:
// |
// | method name => amount
// |
// | NOTE: Do not print anything within custom shipping
// | scripts.  They are designed only to return names and 
// | prices for custom shipping methods.
// |
// | This script is a Calculation On Total Item Weight script that
// | returns a prices based on total item weight.
// +--

$info = $this->globals('ecom.customship');

//$variable_name          = 'Display name for Shipping Options';

$ship_reg                   = 'Regular Shipping';


if (($info['country'] == 'Belgium') || ($info['country'] == 'Germany') || ($info['country'] == 'Luxembourg')){
          $ship_reg_total = 15;
     }
elseif (($info['country'] == 'Italy') || ($info['country'] == 'Spain') || ($info['country'] == 'Czech Republic')){
          $ship_reg_total = 20;
     }  
else{
          $ship_reg_total= 10;
     }
          

//$custom = array($METHODNAME1 => $METHODTOTAL1);
$custom = array($ship_reg => $ship_reg_total);


$this->globals('ecom.customship_response',$custom);

?>

Using some of the countries you listed as examples, the above should work as you see fit. I'm not sure how familiar you are with PHP (sorry if I sound patronizing), but you would just copy/paste this line after itself for every string of coutnries you would need:

Code:

elseif (($info['country'] == 'Italy') || ($info['country'] == 'Spain') || ($info['country'] == 'Czech Republic')){
          $ship_reg_total = 20;
     }

then replace Italy, Spain, CR, etc. with whatever countries you need. And of course you can have as many coutnries added to that as you want or as few. The differential would just be the cost. So you'd lump all the coutnries that have the same shipping cost into one elseif statement. Your first list of coutnries/prices would be under an if statement and your last list would be under the else statement. And of course you can play around with the variables listed at the top in the big commented block.

Once your script is setup you can apply it to products through the area where you'd add/modify products.




If you need another example, here's my shipping script:

Code:

<?php 

$info = $this->globals('ecom.customship');

//$variable_name          = 'Display name for Shipping Options';

$USAreg                         = 'USA Regular Shipping';
$USA2day                = 'USA Two Day Shipping';
$USAexpress                    = 'USA Express Shipping';

$CANMEXreg                    = 'Canada/Mexico Regular Shipping';
$CANMEX2day                    = 'Canada/Mexico Two Day Shipping';
$CANMEXexpress               = 'Canada/MexicoExpress Shipping';

$WORLDreg                    = 'World Regular Shipping';
$WORLD2day                    = 'World Two Day Shipping';
$WORLDexpress               = 'World Express Shipping';


//If from the US and the total is lower than $25, $5 regular shipping/variabled faster shipping

if ($info['country'] == 'United States') {

     if ( $info['total'] < 25){

         $USAreg_total         =  5.00;
         $USA2day_total      = ((.10 * $info['total']) + 20);
         $USAexpress_total = ((.15 * $info['total']) + 35);

//if from the US and the total is greater than or equal to $25, free shipping/variabled faster shipping. 
     } else {

          $USAreg_total         = 0.00;
          $USA2day_total      = ((.10 * $info['total']) + 20);
          $USAexpress_total = ((.15 * $info['total']) + 35);

     } // end of if statement.

$custom = array($USAreg => $USAreg_total, $USA2day => $USA2day_total, $USAexpress => $USAexpress_total);

//if from Canada or Mexico...

} elseif (($info['country'] == 'Canada') || ($info['country'] == 'Mexico')) {

     $CANMEXreg_total         = ((.12 * $info['total']) + 20);
     $CANMEX2day_total      = ((.15 * $info['total']) + 30);
     $CANMEXexpress_total = ((.20 * $info['total']) + 40);

     $custom = array($CANMEXreg => $CANMEXreg_total, $CANMEX2day => $CANMEX2day_total, $CANMEXexpress => $CANMEXexpress_total);

//if not from US, Can, or Mex...

} else {

     $WORLDreg_total         = ((.15 * $info['total']) + 30);
     $WORLD2day_total      = ((.20 * $info['total']) + 35);
     $WORLDexpress_total = ((.25 * $info['total']) + 50);

     $custom = array($WORLDreg => $WORLDreg_total, $WORLD2day => $WORLD2day_total, $WORLDexpress => $WORLDexpress_total);

}  // end of if statement.


$this->globals('ecom.customship_response',$custom);

?>

Last edited by JDLS88 (09-09-2011 11:06:24)


Jeremy D.

Offline

 

#5 09-09-2011 11:21:32

ashley
Member
Registered: 08-16-2010
Posts: 41

Re: Shipping cost based on country

Thank you! I'll try it out.

Offline

 

#6 11-07-2011 14:14:10

virusys
Member
Registered: 06-09-2010
Posts: 31

Re: Shipping cost based on country

I have this method set up for state-based shipping. I need to add the capability to include other countries as well.

I do not want to specify a definitive cost beforehand and would like international shipping costs to show up as "Quote".

Is there a way to do that?

Offline

 

#7 11-09-2011 21:25:58

stage
Member
Registered: 12-12-2005
Posts: 170

Re: Shipping cost based on country

Well I'm not much of a script writer, but I do know that the terms displayed to the customer are taken from the custom script.  Like in Jeremy's example above, "USA Regular Shipping" is literally what's displayed to the customer, even if that really means UPS Ground.  You can certainly call the delivery method offered to certain countries "Quote", as opposed to "US Mail" or whatever.

Offline

 

Board footer