[ic] Shipping charges fail when a user is logged in...

Jim Boyer boyerj at wsu.edu
Fri Oct 24 12:53:59 EDT 2003


Hi,

I am resending because my previous didn't garner any help.  If you have any
insight I would appreciate your help.

I have a shipping function that is based on the contents of the cart,
specifically type of products and price.  The UserTag is defined in the
catalog.cfg and shipping methods and works fine when a customer does not
login to an account.  When the customer logs in to an account the function
fails to work and it appears that the cart is not available to the UserTag.
Do I need to access the cart differently when a user logs in compared to
when they don't log in?  Here are the version specifics, RH 7.2, IC
4.9.7-200305121041, MySql .


Thanks for any help,


I am getting the following error (where pubs is the name of the database),
even when I do a refresh.

ERROR
------------
Note: No match found for mode 'pubs', quantity '', returning 0.
-------------

Here is the shipping.asc file
----------------------------------
stnd    standard        [subtotal noformat=1]   0       0       e Nothing to
ship!              {'ui_ship_type' => "_subtotal",'ups' => "0",'at_least' =>
"1",}
stnd    standard        [subtotal noformat=1]   0       9999999 f
[calc_shipping]               {'PriceDivide' => "1",}
----------------------------------


Here is the UserTag in my catalog.cfg
#------------------------------------------------
# added to calculate shipping for publications
# and cd/video combination
#------------------------------------------------
UserTag calc_shipping Routine <<EOF
sub
{
     # this routine is used to calculate shipping cost
     # here is the business rule
     # shipping is based only on price if no cd or video ordered
     # if cd/video ordered with pubs then
     #    shipping is calculated on pubs subtotal price + a fixed
     #    value for each video or cd ordered
     # if only cd/video ordered then
     #    shipping is calculated as fixed price for the first cd/video
     #    and a lower fixed price for the remaining cd/videos
     #
     # example (cd and pubs)
     #    pubs price total $25 and 2 cds price total $50
     #    shipping is $6 for the pubs + 2($1) for each cd
     #    giving a total of $8 shipping
     #
     # example (1 video and 2 cd)
     #    price for first video/cd = $4 + $1 for each additional
     #    shipping is $4 + 2($1) = $6

     # fixed charges for cd/video
     my $firstCDPrice = 4;
     my $moreCDPrice = 1;

     # temp variables
     my $totalItems = 0;
     my $exceptions = 0;
     my $subTot = 0;
     my $shippingCharge = 0;
     my $pubShipping = 0;
     my $price = 99;

     my $cart = $Carts->{main};

     # loop through the cart items
     foreach my $item (@$cart)
     {
          $price = $Tag->price({
                    code => $item->{code},
                    quantity => $item->{quantity},
                    noformat => 1,
                   });


          # add the quantity to the total number of items
          $totalItems+= $item->{quantity};

          # if sku starts with VT (video) or CD then it is an exception
          if ( ( $item->{code} =~ /^VT/ ) || ( $item->{code} =~ /^CD/ ) )
          {
               # add the quantity of the video or cd to the exceptions
               $exceptions+= $item->{quantity};
          }

          else  # sub total without the video or cd costs
          {
               # add the price * quantity to the sub total
               $subTot+= ($price * $item->{quantity});
          }
     }

     # check for cd or videos
     if ( $exceptions > 0 )
     {
          # are there pubs as well as videos
          if ( $exceptions < $totalItems )
          {
               # calculate pubShipping on sub total without video's or cds
               # this is a small table to check
               ShipBlock1:
               {
                    if ( $subTot <= 3 ) { $pubShipping = 1; last ShipBlock1;
}
                    if ( $subTot <= 4) { $pubShipping = 2; last ShipBlock1;
}
                    if ( $subTot <= 7) { $pubShipping = 4; last ShipBlock1;
}
                    if ( $subTot <= 10) { $pubShipping = 5; last ShipBlock1;
}
                    if ( $subTot <= 25) { $pubShipping = 6; last ShipBlock1;
}
                    if ( $subTot <= 40) { $pubShipping = 7; last ShipBlock1;
}
                    if ( $subTot <= 75) { $pubShipping = 8; last ShipBlock1;
}
                    if ( $subTot <= 100) { $pubShipping = 9; last
ShipBlock1; }
                    if ( $subTot <= 125) { $pubShipping = 10; last
ShipBlock1; }
                    if ( $subTot > 125 ) { $pubShipping = ($subTot * 0.11);
last ShipBlock1; }
                    $pubShipping = 9999;
               }

               $shippingCharge = $pubShipping + ($exceptions *
$moreCDPrice);
          }

          else  # calculate using only videos and cds
          {
               # first one has a different price
               $exceptions--;

               $shippingCharge = $firstCDPrice + ($exceptions *
$moreCDPrice);
          }
     }

     else
     {
          # no videos, calculate shipping on cost
          # this is a small table to check
          ShipBlock2:
          {
               if ( $subTot <= 3 ) { $pubShipping = 1; last ShipBlock2; }
               if ( $subTot <= 4) { $pubShipping = 2; last ShipBlock2; }
               if ( $subTot <= 7) { $pubShipping = 4; last ShipBlock2; }
               if ( $subTot <= 10) { $pubShipping = 5; last ShipBlock2; }
               if ( $subTot <= 25) { $pubShipping = 6; last ShipBlock2; }
               if ( $subTot <= 40) { $pubShipping = 7; last ShipBlock2; }
               if ( $subTot <= 75) { $pubShipping = 8; last ShipBlock2; }
               if ( $subTot <= 100) { $pubShipping = 9; last ShipBlock2; }
               if ( $subTot <= 125) { $pubShipping = 10; last ShipBlock2; }
               if ( $subTot > 125 ) { $pubShipping = ($subTot * 0.11); last
ShipBlock2; }
               $pubShipping = 9999;
          }

          $shippingCharge = $pubShipping;
     }

     # return the shipping cost
     return $shippingCharge;
}
EOF

---------------------------------------------

-------------------------------
Jim Boyer
Systems Programmer
College of Agriculture and Economics 





More information about the interchange-users mailing list