[ic] Is there a different cart used when a user logs in
????
Ed LaFrance
edl at newmediaems.com
Mon Oct 6 12:05:07 EDT 2003
At 10:09 AM 10/6/2003 -0700, you wrote:
>Hi,
>
>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?
>
>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.
I would suggest you post the relevant rows from shipping.asc.
- Ed L.
>-------------
>
>
>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
>Information Dept
>College of Agriculture and Home Economics
>Washington State University
>
>_______________________________________________
>interchange-users mailing list
>interchange-users at icdevgroup.org
>http://www.icdevgroup.org/mailman/listinfo/interchange-users
===============================================================
New Media E.M.S. Technology Solutions for Business
11630 Fair Oaks Blvd., #250 eCommerce | Consulting | Hosting
Fair Oaks, CA 95628 edl at newmediaems.com
(916) 961-0446 http://www.newmediaems.com
(866) 519-4680 Toll-Free (916) 961-0447 Fax
===============================================================
More information about the interchange-users
mailing list