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.

#26 09-19-2019 08:16:31

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: Shipping surcharge per post code

Change:

Code:

if (( preg_match( '/EC\d{1,2}/i', $postcode ))||( preg_match( '/NW\d{1,2}/i', $postcode ))||( preg_match( '/SE\d{1,2}/i', $postcode ))||( preg_match( '/SW\d{1,2}/i', $postcode ))||( preg_match( '/WC\d{1,2}/i', $postcode ))||( preg_match( '/E\d{1,2}/i', $postcode ))||( preg_match( '/N\d{1,2}/i', $postcode ))) {

     $method .= ' with Inner London Surcharge';
     $total  += 1.00;

} // End of if statement.

To:

Code:

$dosurcharge = 0;

if     (preg_match('/EC\d{1,2}/i', $postcode)) {$dosurcharge++;}
elseif (preg_match('/NW\d{1,2}/i', $postcode)) {$dosurcharge++;}
elseif (preg_match('/SE\d{1,2}/i', $postcode)) {$dosurcharge++;}
elseif (preg_match('/SW\d{1,2}/i', $postcode)) {$dosurcharge++;}
elseif (preg_match('/WC\d{1,2}/i', $postcode)) {$dosurcharge++;}
elseif (preg_match('/E\d{1,2}/i', $postcode))  {$dosurcharge++;}
elseif (preg_match('/N\d{1,2}/i', $postcode))  {$dosurcharge++;}

if ($info['stateprov'] != 'London') {$dosurcharge = 0;}

if (!(empty($dosurcharge))) {

     $method .= ' with Inner London Surcharge';
     $total  += 1.00;

} // End of if statement.

Nick Hendler

Offline

 

#27 09-19-2019 08:38:57

west4
Member
From: UK
Registered: 04-16-2008
Posts: 645
Website

Re: Shipping surcharge per post code

Hi Nick,

I think that's it..

Cheers,
Bruce.


I'd rather have a full bottle in front of me, than a full frontal labotomy.

Offline

 

#28 08-06-2020 07:13:38

west4
Member
From: UK
Registered: 04-16-2008
Posts: 645
Website

Re: Shipping surcharge per post code

Hi Nick,

This code needs a little tweak so as not to show the surcharge when the quantity is above a certain amount, as we ask them to contact us when they order alot/bulk,

example code:

Code:

if ($quantity >= 1001) {

    $method = 'For Delivery Quote, contact Westfield4Schools on 0121 233 1671..';
    $total  = '00.00';
}

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

Is still showing the surcharge at checkout.

Cheers,
Bruce.


I'd rather have a full bottle in front of me, than a full frontal labotomy.

Offline

 

#29 08-07-2020 10:18:09

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: Shipping surcharge per post code

Perhaps you want to do:

Code:

//Deal with london postcode surcharge          
if (( preg_match( '/EC\d{1,2}/i', $postcode ))||( preg_match( '/NW\d{1,2}/i', $postcode ))||( preg_match( '/SE\d{1,2}/i', $postcode ))||( preg_match( '/SW\d{1,2}/i', $postcode ))||( preg_match( '/WC\d{1,2}/i', $postcode ))||( preg_match( '/E\d{1,2}/i', $postcode ))||( preg_match( '/N\d{1,2}/i', $postcode ))){

$custom = array('Inner London Surcharge' => '1.0',);
$this->globals('ecom.customship_response',$custom);
return 1;

} // End of if statement.

//end of Bruces bit

Nick Hendler

Offline

 

#30 08-07-2020 12:34:26

anaysha
Member
From: Houston, TX, US
Registered: 08-07-2020
Posts: 1
Website

Re: Shipping surcharge per post code

Effects of Green Tea


Green Tea has been a popular choice of drink for many years now. The effects of green tea are its light flavor that has several antioxidants, EGCG, and nutrients that are proven to help lose weight, fight cancer, heart disease, diabetes, and improve skin. Improved brain function, fat loss, a lower risk of cancer are some benefits of green tea. https://www.livingstylebits.com/health- … green-tea/


Are you looking for Assignment Help?GotoAssignmenthelp is one of the most famous Assignment providers in the world. Our online assignment makers provide quality assignment writing services but should be an option for all students. Which is why we are pleased to provide you with nursing assignment help.

Offline

 

#31 08-10-2020 02:45:18

west4
Member
From: UK
Registered: 04-16-2008
Posts: 645
Website

Re: Shipping surcharge per post code

Hi Nick,

I think you used the wrong bit of code to change .. here is a script that needs tweeking for non display if product quantity hits the delivery '$total  = '00.00'' bit.

This is a shipping script for Badges by quantity.

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 Percentage of Total Item Cost script that
// | returns a prices based on a percentage of the total item cost.
// +--

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

if (($info['country'] == 'UK - England & Wales')){
//England & Wales
$method  = 'Badge Shipping to England & Wales';
$quantity = $info['quantity'];


if ($quantity >=   1 and 
    $quantity <= 60) {

    $total = '6.20';
}

if ($quantity >=   61 and 
    $quantity <= 250) {

    $total = '8.84';
}
 
if ($quantity >= 251 and
    $quantity <= 500) {

    $total = '10.40';
} 

if ($quantity >= 501 and
    $quantity <= 1000) {

    $total = '13.47';
}

if ($quantity >= 1001) {

    $method = 'For Delivery Quote, contact Westfield4Schools on 0121 233 1671..';
    $total  = '00.00';
}

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

} elseif (($info['country'] == 'UK - Scotland Lowlands')){
// UK Scotland Lowlands
$method  = 'Badge Shipping to Scottish Lowlands';
$quantity = $info['quantity'];


if ($quantity >=   1 and 
    $quantity <= 60) {

    $total = '8.26';
}

if ($quantity >=   61 and 
    $quantity <= 250) {

    $total = '10.92';
}
 
if ($quantity >= 251 and
    $quantity <= 500) {

    $total = '12.48';
} 

if ($quantity >= 501 and
    $quantity <= 1000) {

    $total = '15.54';
}

if ($quantity >= 1001) {

    $method = 'For Delivery Quote,  contact Westfield4Schools on 0121 233 1671.';
    $total  = '00.00';
}

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

} elseif (($info['country'] == 'UK - Highlands & Islands Scotland')){
// UK - Scotland Highlands
$method  = 'Badge Shipping to Scotland Highlands';
$quantity = $info['quantity'];


if ($quantity >=   1 and 
    $quantity <= 60) {

    $total = '10.86';
}

if ($quantity >=   61 and 
    $quantity <= 250) {

    $total = '13.52';
}
 
if ($quantity >= 251 and
    $quantity <= 500) {

    $total = '15.08';
} 

if ($quantity >= 501 and
    $quantity <= 1000) {

    $total = '18.14';
}

if ($quantity >= 1001) {

    $method = 'For Delivery Quote,  contact Westfield4Schools on 0121 233 1671.';
    $total  = '00.00';
}

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

} else {
// Rest of the world
$method  = 'For Delivery Quote,  contact Westfield4Schools on 0121 233 1671.';
$total = '00.00';
$custom = array($method => $total);

}

// +--
// | Surcharge
// +--

$shipquantity = $info['quantity'];
$shippostcode = $info['postalcode'];
$ordertotal = $info['total'];

$shippostcode = strtoupper($shippostcode);
$postcode     = preg_replace( '/[^a-z0-9]/i', '', $shippostcode );

if ( in_array( strlen( $postcode ), array( 5, 6, 7 ) ) ) {$postcode = substr( $postcode, 0, -3 );}
      
$dosurcharge = 0;

if     (preg_match('/EC\d{1,2}/i', $postcode)) {$dosurcharge++;}
elseif (preg_match('/NW\d{1,2}/i', $postcode)) {$dosurcharge++;}
elseif (preg_match('/SE\d{1,2}/i', $postcode)) {$dosurcharge++;}
elseif (preg_match('/SW\d{1,2}/i', $postcode)) {$dosurcharge++;}
elseif (preg_match('/WC\d{1,2}/i', $postcode)) {$dosurcharge++;}
elseif (preg_match('/E\d{1,2}/i', $postcode))  {$dosurcharge++;}
elseif (preg_match('/N\d{1,2}/i', $postcode))  {$dosurcharge++;}

if ($info['stateprov'] != 'London') {$dosurcharge = 0;}

if (!(empty($dosurcharge))) {

     $method .= ' with Inner London Surcharge';
     $total  += 1.00;

} // End of if statement.

// +--
// | Globalize
// +--

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

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

?>

Hope this helps.

Cheers,
Bruce.


I'd rather have a full bottle in front of me, than a full frontal labotomy.

Offline

 

Board footer