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 03-27-2018 12:20:43

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

Shipping surcharge for special items

I know this was discussed in v8, I thought it had been added in v9 but I don't see it.

We use realtime rates.  Some of our products are 5 gallon jugs and when we ship these we just slap a label right on the bottle.  (We learned that when we put these 50 lb. bottles in a box, they are much more likely to thrown/dropped and leak.)

Fedex charges a $12 surcharge for non-standard packaging when we ship these, so we would like $12 to be added to the realtime rate, seamless to the customer.  Other than a custom shipping script, is there a way to do this?  Ideally there would be a place in the Inventory Items / Delivery - Config for an "item based delivery surcharge".

Thanks,
Nathan

Offline

 

#2 03-28-2018 08:09:25

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

Re: Shipping surcharge for special items

This is best handled with a custom shipping script.  I'd suggest doing the following, assuming right now 100% of your items are using realtime shipping via FedEx:

(1) Create a new custom shipping script using Store / Shipping / Custom Shipping Methods.  Make the id 'customfedex'.  Use the following code, which should work.  If not, we can help you through the custom shop:

Code:

<?php 

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

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

$surcharge = 0;

foreach ($info['delitems'] as $diid => $one) {

     foreach ($cart as $cnum => $cdata) {

          if ($cdata['savetype'] != 'CART') {continue;}
          if ($cdata['xinvid'] != $diid)    {continue;}
          if (empty($cdata['customdata']))  {continue;}

          $customdata      = array();
          $list_customdata = $this->make_list($proddisp['customdata']);

          foreach ($list_customdata as $lcdnum => $lcditem) {list($lcditemid,$lcditemdata) = preg_split('/\:/s', $lcditem, 2); $customdata[$lcditemid] = $lcditemdata;}

          if ((empty($customdata)) || (empty($customdata['FedExSurcharge']))) {continue;}

          $surcharge += ($cdata['quantity'] * $customdata['FedExSurcharge']);

     } // End of foreach statement.

} // End of foreach statement.

// +--
// | Rate Via FedEx, Add in Surcharge
// +--

$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']));

if ((!($this->isError($result))) && (!(empty($result)))) {

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

} // End of if statement.

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

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

?>

(2) This step sets all your inventory items to use this new script.  You could update them individually by setting Custom Shipping as the delivery method, and the new 'fedexcustom' script as the custom shipping script.  Access System / Database / Raw Database Admin and choose to Execute a Raw SQL Statement.  Execute this statement:

Code:

UPDATE ecom_inventory SET delmethod='C', customship='fedexcustom'

(3) Access Store / Inventory / Inventory Items and update each of the special items that have a surcharge.  For each, update the Inventory Item's Custom Data field.  That field takes comma delimited data, so if it's blank, enter 'FedExSurcharge:12.00', or if it's not blank (you've already got custom data in it), append your custom data with a comma then add 'FedExSurcharge:12.00'.  Based on how the custom shipping script works, you can use any surcharge amount you want.

Adjust as necessary.


Nick Hendler

Offline

 

#3 03-28-2018 12:57:39

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

Re: Shipping surcharge for special items

That's all clear, thank you.

I guess depending on how many others would use it, you can consider a per-item packaging/delivery surcharge field.  I did see one thread about it in v8 forum, but no other requests.

Thanks,
Nathan

Offline

 

#4 03-28-2018 15:02:45

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

Re: Shipping surcharge for special items

This works very well, exactly why the custom data fields are there.  Another user who needs to do something similar but not quite can follow this and accomplish the same thing.


Nick Hendler

Offline

 

Board footer