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 02-18-2009 15:01:17

jherr
Member
Registered: 09-12-2008
Posts: 26

Combine custom and UPS shipping calculations

I have set up a custom shipping script based on total item weight for customers in the UK that will be handled by a local carrier. For all other countries I would like to plug in UPS so that for all customers outside the UK, the Ups script calculates and handles the shipping cost. Is this possible?

Thanks

Offline

 

#2 02-18-2009 15:46:37

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

Re: Combine custom and UPS shipping calculations

Nick shows an example of how to accomplish that in .

Offline

 

#3 02-18-2009 17:12:20

jherr
Member
Registered: 09-12-2008
Posts: 26

Re: Combine custom and UPS shipping calculations

Thanks Dave. I'm really new to all this and was wondering if you could check this code and let me know if it will do what I need. I know next to nothing about coding and I have not yet activated the UPS tools, so right now I have no way of checking to see if it will work.

Code:

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

$weight = $info['weight'];

if ($weight <= 10) {
    $total = 7.50;
}
if ($weight > 10) {
    $total = 7.50 + (.25 * ($weight - 10));
}
$delinfo = array('stateprov'     => $info['stateprov'],
                 'country'       => $info['country'],
                 'postalcode'    => $info['postalcode'],
                 'rescom'        => $info['rescom'],
                 'shipstateprov' => $info['shipstateprov'],
                 'shipcountry'   => $info['shipcountry'],
                 'shipzip'       => $info['shipzip'],
                 'shipmethods'   => 'UPSTOOLS',
                 'shiptype'      => 'R');

$result = $this->include_namespace($app,'shiprealtime',array('delinfo'  => $delinfo, 'packages' => $info['packages']));

foreach ($result as $num => $service) {$custom[$service['name']] = $service['amount'];}
$custom = array($method => $total);

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

Offline

 

#4 02-18-2009 17:20:02

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

Re: Combine custom and UPS shipping calculations

Well it is valid code so it won't throw an error which is a good thing.  The only thing I see that you're missing is a description of your calculated total.  In this line, $custom = array($method => $total);, $method should be the name you want to use to describe your UK shipping.  So up at the top perhaps you'll want to add something like $method = 'This is my UK shipping charge'; or something along those lines.

I also don't see you checking to see what country the delivery is going to.  If you search a bit here in the fora you'll find examples of how to check for the delivery country and based on your outstanding work so far I'm sure you'll have no trouble adding that bit of checking to what you posted.

Offline

 

#5 02-18-2009 19:01:33

jherr
Member
Registered: 09-12-2008
Posts: 26

Re: Combine custom and UPS shipping calculations

Thanks again Dave. I hope to have it up and running tomorrow.

Offline

 

Board footer