Screen: ShopSite > Commerce Setup > Shipping > Custom Shipping Add-On

Custom Shipping Add-On Examples

ShopSite Input to Shipping Program Example

This is an example of what a two-item order might look like to the shipping program. Each field is shown here on a separate line for clarity, but there are no line breaks in actual operation.

?locale=en-US
&storeid=MyStore
&cust_zip=80863
&cust_country=US
&merch_zip=93257
&merch_country=US
&parm1=testing
&parm2=testing2
¤cy_code=USD
&item_total=2
&weight_unit=LBS
&p1name=Hewlett%20Packard%20OfficeJet%20d145
&p1sku=1234-56
&p1uprice=410.99
&p1price=410.99
&p1option_total=0
&p1ship=Y
&p1quantity=1
&p1weight=30
&p1dimension=20x18x18
&p1type=T
&p2name=Inkjet%20Paper
&p2sku=9876-12
&p2uprice=4.99
&p2price=9.98
&p2option_total=2
&p2option1=20lb
&p2option2=Photo%20quality
&p2ship=Y
&p2quantity=2
&p2weight=6
&p2dimension=
&p2type=T

Shipping Program Data Returned to ShopSite Example

This example shows the data returned by a shipping program for three shipping options.

status=pass
option_count=3
s1option=Ground
s1price=14.95
s2option=2-Day%20Air
s2price=29.00
s3option=Overnight%20Air
s3price=40.00

Shipping Program Error Message Example

This is an example error message returned from a shipping program.

status=fail
error=Shipping%20options%20not%20currently%20available%20-
%20try%20again%20in%20a%20few%20minutes.

Shipping Program Warning Message Example

This is an example of a warning message returned by a shipping program.

status=warn
error=Ground%20shipping%20not%20availble%20to%20Hawaii
option_count=2
s1option=2-Day%20Air
s1price=29.00
s2option=Overnight%20Air
s2price=40.00

Sample Perl Program

This Perl program displays sample shipping choices.

#!/usr/bin/perl
if ($ENV{'REQUEST_METHOD'} =~ /get/i) { 
    $buffer = $ENV{'QUERY_STRING'};
print "buffer=$buffer\n";
    $method = "Get";
}
else {
    read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
    $method = "Post";
}

@nvpairs = split(/&/, $buffer);
foreach $pair (@nvpairs)
{
  ($name, $value) = split(/=/, $pair);

  $name  =~ tr/+/ /;
  $name  =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
  $value =~ tr/+/ /;
  $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

  print "$name = $value\n";
  $pos = index($name,"quantity");
  if ($pos != -1)
  {
    $quantity = $value;
  }
  $pos = index($name,"weight");
  if ($pos != -1)
  {
    if ($value != 0.00)
    {
      $total += ($quantity * $value); 
      $quantity = 0.00;
    }
  }
}
# output status=pass if everything is okay
print "status=pass\n";
#
# output status=warn if everything is okay but you need to tell the
# customer something so also output the error=.... 
#print "status=warn\n";
#print "error=Items%20will%20be%20shipped%20in%20several%20boxes\n";

print "option_count=3\n";
print "s1option=API%20Ground\n";
printf ("s1price=%0.2f\n",1.00*$total);
print "s2option=API%20Next%20Week\n";
printf ("s2price=%0.2f\n",2.00*$total);
print "s3option=API%20Tomorrow\n";
printf ("s3price=%0.2f\n",4.00*$total);

ShopSite Help and Resource Center
February 13, 2004
Give Feedback

© 2007, ShopSite, Inc.
ShopSite Shopping Cart Software