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 11-21-2012 19:49:40

klink
Member
Registered: 11-14-2007
Posts: 55

shipping script based on cost

I really have no idea what I'm doing. I have a script that was created for me based on weight. I'd like to set up a temporary one based on cost so I can offer free shipping over $35 and $5.50 off our international rates. I used the script I have and copied it to do this. Am I on the right track?

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

$ship_meth_us           = 'Domestic Shipping';
$ship_total_us          = 0.000;
$ship_meth_ca           = 'United States Post Office';
$ship_total_ca          = 0.000;
$ship_meth_rw           = 'United States Post Office';
$ship_total_rw          = 0.000;
$freeship  = 0.00;


if ($info['total'] >= '0' && $info['total'] <= '34.99') {

     $ship_total_us          = 5.50;
     $ship_total_ca          = 12.95;
     $ship_total_rw          = 16.95;

} elseif ($info['total'] > '35.00' && $info['total'] <= '99.99') {

     $ship_total_us          = 0.00;
     $ship_total_ca          = 7.50;
     $ship_total_rw          = 11.50;

} elseif ($info['total'] > '100.00' && $info['total'] <= '500.00') {

     $ship_total_us          = 0.00;
     $ship_total_ca          = 20.50;
     $ship_total_rw          = 28.50;

} else {

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

} // End of if statement.

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

?>

Offline

 

#2 11-21-2012 21:22:25

dh783
Member
From: Avondale, Arizona
Registered: 04-06-2005
Posts: 6233
Website

Re: shipping script based on cost

Your shipping cost will always be 0.00 as that is what you set the custom shipping array to with this line

Code:

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

that is only if it gets that far, otherwise it not set at all which will leave you with the default shipping being used. You have to have some logic determaining which country the customer is from, something like

Code:

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

     $method = $ship_meth_us;

  if (($info['total'] >= '0.00') && ($info['total'] <=  '34.99')) {

     $cusom = array($method => '5.50');

  } else if (($infor['total'] >= '35.00') && $info['total'] <= '99.99')) {

    // the rest of the coding.

  } 

} else if ($info['country'] == 'Canada') {

      $method = $ship_meth_ca;

   if (($info['total'] >= '0.00') && ($info['total'] <=  '34.99')) {

      $cusom = array($method => '12.95');

  } else if (($infor['total'] >= '35.00') && $info['total'] <= '99.99')) {

    // the rest of the coding.

  } 

} else {

        $method = $ship_meth_rw;

   if (($info['total'] >= '0.00') && ($info['total'] <=  '34.99')) {

        $cusom = array($method => '16.95');

  } else if (($infor['total'] >= '35.00') && $info['total'] <= '99.99')) {

    // the rest of the coding.

  } 

}

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

this is just an example as there are many ways to code this.

John

Offline

 

#3 11-21-2012 21:52:07

klink
Member
Registered: 11-14-2007
Posts: 55

Re: shipping script based on cost

Thank you that is helpful. I'll keep working on it.

Offline

 

Board footer