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 05-22-2012 04:29:27

moto
Member
From: UK
Registered: 01-30-2005
Posts: 174
Website

Another Shipping Script!!

Cannot get this shipping script to work.

Can anyone point me in the right direction.

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
// |

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

$method = 'Standard Shipping';

$shipcountry = $info['country'];

$ukcountries = array('UK - Mainland'                     ,
                     'UK - Highlands & Islands Scotland' ,
                     'UK - Isle of Man'                  ,
                     'UK - Northern Ireland');

$eucountries = array('Andorra'              ,
                     'Austria'              ,
                     'Belgium'              ,
                     'Bulgaria'             ,
                     'Canary Islands'       ,
                     'Croatia'              ,
                     'Cyprus'               ,
                     'Czech Republic'       ,
                     'Denmark'              ,
                     'Estonia'              ,
                     'Faroe Islands'        ,
                     'Finland'              ,
                     'France'               ,
                     'France, Metropolitan' ,
                     'Germany'              ,
                     'Gibraltar'            ,
                     'Greece'               ,
                     'Hungary'              ,
                     'Iceland'              ,
                     'Ireland'              ,
                     'Italy'                ,
                     'Latvia'               ,
                     'Leichtenstein'        ,
                     'Lithuania'            ,
                     'Luxembourg'           ,
                     'Malta'                ,
                     'Monaco'               ,
                     'Netherlands'          ,
                     'Norway'               ,
                     'Poland'               ,
                     'Portugal'             ,
                     'Romania'              ,
                     'San Marino'           ,
                     'Slovakia'             ,
                     'Slovenia'             ,
                     'Spain'                ,
                     'Sweden'               ,
                     'Switzerland'          ,
                     'UK - Channel Islands' ,
                     'Vatican City State');

$nacountries = array('Canada' ,
                     'United States');

if (in_array($shipcountry,$ukcountries)) { // UK shipping

        $method = 'Shipping - United Kingdom';
        if ($info['total'] >= '0' && $info['total'] <= '29.99') {

     $custom = array($method => '2.00');

} elseif ($info['total'] > '29.99' && $info['total'] <= '59.99') {

     $custom = array($method => '4.00');

} else {

     $custom = array($method => '7.00');

} // End of if statement.

} elseif (in_array($shipcountry,$eucountries)) {  // EU shipping - non UK

        $method = 'Shipping - Europe';
        if ($info['total'] >= '0' && $info['total'] <= '29.99') {

     $custom = array($method => '4.00');

} elseif ($info['total'] > '29.99' && $info['total'] <= '59.99') {

     $custom = array($method => '8.00');

} else {

     $custom = array($method => '16.00');

} // End of if statement.

} elseif (in_array($shipcountry,$nacountries)) {  // North America shipping

        $method = 'Shipping - North America';
        if ($info['total'] >= '0' && $info['total'] <= '29.99') {

     $custom = array($method => '5.00');

} elseif ($info['total'] > '29.99' && $info['total'] <= '59.99') {

     $custom = array($method => '10.00');

} else {

     $custom = array($method => '25.00');

} // End of if statement.

} else {  // WORLDWIDE SHIPPING

    $method = 'Shipping - Worldwide';
    if ($info['total'] >= '0' && $info['total'] <= '29.99') {

     $custom = array($method => '5.00');

} elseif ($info['total'] > '29.99' && $info['total'] <= '59.99') {

     $custom = array($method => '10.00');

} else {

     $custom = array($method => '45.00');

} // End of if statement.

$custom = array($method => $total);
$this->globals('ecom.customship_response',$custom);

?>

Many thanks

Offline

 

#2 05-22-2012 07:14:26

htw_simon
Member
From: UK
Registered: 11-20-2007
Posts: 83
Website

Re: Another Shipping Script!!

You are missing a closing } at the end of the WORLDWIDE SHIPPING section.

Offline

 

#3 05-22-2012 07:49:48

moto
Member
From: UK
Registered: 01-30-2005
Posts: 174
Website

Re: Another Shipping Script!!

Thanks but it is still not working.

Offline

 

#4 05-22-2012 08:58:37

htw_simon
Member
From: UK
Registered: 11-20-2007
Posts: 83
Website

Re: Another Shipping Script!!

Try and remove the following from the end of the file:

$custom = array($method => $total);

You have not set a value for $total and $custom is set within each if statement anyway.

Offline

 

#5 05-22-2012 09:20:40

moto
Member
From: UK
Registered: 01-30-2005
Posts: 174
Website

Re: Another Shipping Script!!

Yeah that's it, works perfect now.

Many thanks

Offline

 

Board footer