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-02-2017 19:23:05

larry
Member
Registered: 07-21-2003
Posts: 437

custom shipping script - realtime rates with delivery dates

Our ancient custom shipping script was created in CCPv7, carried to V8 nicely and works in V9 to a point. It calculates insurance rates  and adds it to the appropriate ship methods. 

We would like to incorporate the estimated delivery dates returned by FedEx realtime rates in the ship method names, just as if the items were set up to use FedEx realtime rates directly.  They aren't showing, so assume there's a different way to access that information.

Can anyone help?

Code:

<?php 


$app = 'ecom';

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





$shmeths = "FEDEX, USPS";
$delinfo = array('stateprov'     => $shipto['stateprov'],
                 'country'       => $shipto['country'],
                 'postalcode'    => $shipto['postalcode'],
                 'rescom'        => $shipto['rescom'],
                 'shipstateprov' => $shipto['shipstateprov'],
                 'shipcountry'   => $shipto['shipcountry'],
                 'shipzip'       => $shipto['shipzip'],
                 'shipmethods'   =>  $shmeths,
                 'shiptype'      => 'R');

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

//       NOW ADD INSURANCE 
if ($shipto['total'] < 51) {$insurance = 0;}
else if ($shipto['total'] < 101) {$insurance = 1.75;}
else
 {
              $hunnerts = $shipto['total'] / 100;
              $ceilng   = ceil($hunnerts);
              $insurance = $ceilng * .85;
              if ($insurance < 2.55) {$insurance = 2.55;}

}

foreach ($result as $num => $service) 
{
    
               $service['amount'] = $service['amount'] + $insurance;
               $custom[$service['name']] = $service['amount'];
             
}



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

?>

Laurie Stephens




Offline

 

#2 02-03-2017 10:18:37

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

Re: custom shipping script - realtime rates with delivery dates

Delivery dates are available in the $result array.  Just look up the key 'delest' as in:

Code:

foreach ($result as $num => $service) 
{
 
               $methodname = $service['name']; if (!(empty($service['delest']))) {$methodname .= ' (' . $service['delest'] . ')';}
   
               $service['amount'] = $service['amount'] + $insurance;
               $custom[$methodname] = $service['amount'];
             
}

Nick Hendler

Offline

 

#3 02-03-2017 15:12:08

stage
Member
Registered: 12-12-2005
Posts: 170

Re: custom shipping script - realtime rates with delivery dates

This is what I've been using in v8.  It looks pretty much the same as Larry's above.  I've got an upcharge, which was my attempt at adding the insurance/declared value fee, which I understood to not be included at the time.

My problem was that I used a new account with no discounts, because I was having difficulty before getting the "retail" rates instead of my costs.  And even though I didn't ship with this new account, it somehow because linked with my other one and began to display discounted prices.  I guess somebody at Fedex noticed the "mistake" and did my a "favor". 

So far on v9 I decided to try the stock script, and I got a new meter number and passkey.  But I must have done something wrong because it isn't delivering any rates at all.  I may go back to the below.

Nathan

Code:

<?php 

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

$upcharge = $info['total'] * .01;

$delinfo = array('stateprov'     => $info['stateprov'],
                 'country'       => $info['country'],
                 'postalcode'    => $info['postalcode'],
                 'rescom'        => $info['rescom'],
                 'shipstateprov' => $info['shipstateprov'],
                 'shipcountry'   => $info['shipcountry'],
                 'shipzip'       => $info['shipzip'],
                 'shipmethods'   => 'FEDEX',
                 'shiptype'      => 'R');

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

foreach ($result as $num => $service) {

     $custom[$service['name']] = $service['amount'] + $upcharge;

} // End of foreach statement.

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

?>

Offline

 

#4 02-03-2017 17:12:57

larry
Member
Registered: 07-21-2003
Posts: 437

Re: custom shipping script - realtime rates with delivery dates

I've spent quite a few days on the V9 shipping.  Here's my recommendation:
Create a brand new FedEx account, login, etc.  use a gmail email account if you have to to keep them separate, and never associate it at any time with your "real" FedEx account.  Never log in to it ever again on fedex.com , except when upgrading CCP.

If your  "upcharge" is solely to reconcile the freight differences between FedEx retail rates, and what is returned to the shopping cart, then your problem is solved.   The Rates returned from FedEx now, truly do match the retail rates.

If it a surcharge of some type,  there's some good functionality within V9 now that may lend itself to your situation.

We have been able to completely dump our custom shipping script and rely solely on the built-in functions in V9.  So much cleaner and never have to deal with behind the scenes logic and keeping up with the latest changes.


Laurie Stephens




Offline

 

#5 02-04-2017 13:43:17

larry
Member
Registered: 07-21-2003
Posts: 437

Re: custom shipping script - realtime rates with delivery dates

Your script works fine.  I just ran it on our test site and it returned FedEx rates. Must be your FedEx connection.


Laurie Stephens




Offline

 

Board footer