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 12-08-2008 14:52:17

picstart
Member
From: United Kingdom
Registered: 07-11-2006
Posts: 428

shipping script problem

I have been playing with the following script but it does'nt seem to work it always returns a value of £10 which is the default value if it cant find a value for shipping
anybody any ideas

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

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


if ($info['total'] <= '249.99' && (($info['country'] == 'UK - England & Wales')||($info['country'] == 'UK - Highlands & Islands Scotland')||($info['country'] == 'UK - Isle of Man')||($info['country'] == 'UK - Channel Islands')||($info['country'] == 'UK - Northern Ireland')){
     // UK shipping
    

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

} else ($info['total'] <= '249.99' && (($info['country'] == 'UK - England & Wales')||($info['country'] == 'UK - Highlands & Islands Scotland')||($info['country'] == 'UK - Isle of Man')||($info['country'] == 'UK - Channel Islands')||($info['country'] == 'UK - Northern Ireland')){


else ($info['total'] >= '250.00' && (($info['country'] == 'UK - England & Wales')||($info['country'] == 'UK - Highlands & Islands Scotland')||($info['country'] == 'UK - Isle of Man')||($info['country'] == 'UK - Channel Islands')||($info['country'] == 'UK - Northern Ireland')){
     // UK shipping
    

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

} else ($info['total'] <= '249.99' && (($info['country'] == 'UK - England & Wales')||($info['country'] == 'UK - Highlands & Islands Scotland')||($info['country'] == 'UK - Isle of Man')||($info['country'] == 'UK - Channel Islands')||($info['country'] == 'UK - Northern Ireland')){


} else if (($info['country'] == 'Ireland')||($info['country'] == 'Cyprus')||($info['country'] == 'Gibraltar')||($info['country'] == 'San Marino')||($info['country'] == 'Slovenia') ||($info['country'] == 'Switzerland')||($info['country'] == 'Austria') ||($info['country'] == 'Belgium')  ||($info['country'] == 'Denmark') ||($info['country'] == 'France') ||($info['country'] == 'Germany') ||($info['country'] == 'Greece') ||($info['country'] == 'Italy') ||($info['country'] == 'Luxembourg') ||($info['country'] == 'Netherlands') ||($info['country'] == 'Portugal') ||($info['country'] == 'Spain') ||($info['country'] == 'Sweden')){
     // European counties charge 

     $method  = 'European Delivery';
     $total = '24.99';
     $custom = array($method => $total);

} else {
     // Rest of the world
     $method  = 'World Delivery';
     $total = '28.99';
     $custom = array($method => $total);

}

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

"It may be my worst nightmare at present..... but soon it will be my dream"

Offline

 

#2 12-08-2008 15:40:02

Dave
Member
Registered: 07-05-2003
Posts: 11233

Re: shipping script problem

Your script has multiple syntax errors which are causing it to never be executed.  You also have several tests for the same thing with no values ever being assigned.  The version below doesn't have any syntax errors but you will probably want/need to examine the logic closely to make sure it's doing what you want/expect it to.

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

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


if ($info['total'] <= '249.99' &&
   ($info['country'] == 'UK - England & Wales'||
    $info['country'] == 'UK - Highlands & Islands Scotland' ||
    $info['country'] == 'UK - Isle of Man' ||
    $info['country'] == 'UK - Channel Islands' ||
    $info['country'] == 'UK - Northern Ireland')) {
     // UK shipping

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

} elseif ($info['total'] <= '249.99' && (
          $info['country'] == 'UK - England & Wales' ||
          $info['country'] == 'UK - Highlands & Islands Scotland' ||
          $info['country'] == 'UK - Isle of Man' ||
          $info['country'] == 'UK - Channel Islands' ||
          $info['country'] == 'UK - Northern Ireland')) {

} elseif ($info['total'] >= '250.00' && (
          $info['country'] == 'UK - England & Wales' ||
          $info['country'] == 'UK - Highlands & Islands Scotland' ||
          $info['country'] == 'UK - Isle of Man' ||
          $info['country'] == 'UK - Channel Islands' ||
          $info['country'] == 'UK - Northern Ireland')) {
     // UK shipping

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

} elseif ($info['total'] <= '249.99' && (
          $info['country'] == 'UK - England & Wales' ||
          $info['country'] == 'UK - Highlands & Islands Scotland' ||
          $info['country'] == 'UK - Isle of Man' ||
          $info['country'] == 'UK - Channel Islands' ||
          $info['country'] == 'UK - Northern Ireland')) {

} elseif ($info['country'] == 'Ireland' ||
          $info['country'] == 'Cyprus'  ||
          $info['country'] == 'Gibraltar' ||
          $info['country'] == 'San Marino' ||
          $info['country'] == 'Slovenia' ||
          $info['country'] == 'Switzerland' ||
          $info['country'] == 'Austria' ||
          $info['country'] == 'Belgium'  ||
          $info['country'] == 'Denmark' ||
          $info['country'] == 'France' ||
          $info['country'] == 'Germany' ||
          $info['country'] == 'Greece' ||
          $info['country'] == 'Italy' ||
          $info['country'] == 'Luxembourg' ||
          $info['country'] == 'Netherlands' ||
          $info['country'] == 'Portugal' ||
          $info['country'] == 'Spain' ||
          $info['country'] == 'Sweden') {
     // European counties charge

     $method  = 'European Delivery';
     $total = '24.99';
     $custom = array($method => $total);

} else {
     // Rest of the world
     $method  = 'World Delivery';
     $total = '28.99';
     $custom = array($method => $total);
}

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

Offline

 

Board footer