[ic] Shipping tag with cascading methods in shipping.asc [SOLVED]
Rick Bragg
lists at gmnet.net
Tue Aug 31 03:37:56 UTC 2010
On Sat, 2010-08-21 at 18:43 -0400, Rick Bragg wrote:
> On Fri, 2010-08-20 at 19:01 -0400, Rick Bragg wrote:
> > Hi;
> >
> > My overall objective is to offer Ground, 3 Day service, and free
> > shipping on carts that total $200. But also, since some items are very
> > large, I wrote a tag that looks at each item in the cart and applies an
> > additional cost for some items... Also, I wrote another tag that tests
> > to see if there is an item in the cart that is "not allowed" to be
> > shipped by a particular method. This tag returns 0 if an items is not
> > allowed, and 1 if there are no problems with the cart, then forwards to
> > a weight based system. This works no problems, however, if I forward to
> > a price based system first to see if the cart is over 200, then forward
> > again to the final weight based system there are problems.
> >
> >
> > In country.txt for US, I have the following:
> > free_z1 ups_ground_res_z1 ups_3day_z1
> >
> >
> > Here is my shipping.asc:
> >
> > ups_3day_z1: UPS 3 Day Select test - Zone 1
> > criteria [noship_item method=ups_3day_z1]
> > min 0
> > max 0
> > cost e Can not ship item by UPS 3 Day Select - Zone 1.
> > min 1
> > max 1
> > cost >>ups_3day_z1_weight
> >
> > ups_3day_z1_weight: UPS 3 Day Select test2 - Zone 1
> > criteria weight
> > min 0
> > max 4
> > cost f 19 + [shipping_cost method='ups_3day_z1' mode='none']
> > min 4
> > max 15
> > cost f 25 + [shipping_cost method='ups_3day_z1' mode='none']
> > min 15
> > max 25
> > cost f 45 + [shipping_cost method='ups_3day_z1' mode='none']
> > min 25
> > max 9999999
> > cost e Will quote shipping cost.
> >
> >
> >
> > ups_ground_res_z1: UPS Ground - Zone 1
> > criteria [noship_item method=ups_ground_res_z1]
> > min 1
> > max 1
> > cost e Can not ship item by UPS Ground - Zone 1.
> > min 2
> > max 2
> > cost >>ups_ground_res_z1_price
> >
> > ups_ground_res_z1_price: UPS Ground P - Zone 1
> > criteria price
> > min 0
> > max 200
> > cost >>ups_ground_res_z1_weight
> > min 200
> > max 9999999
> > cost >>free_z1_price
> >
> > ups_ground_res_z1_weight: UPS Ground - Zone 1
> > criteria weight
> > min 0
> > max 70
> > cost f 8.50 + [shipping_cost method='ups_ground_res_z1' mode='none']
> > min 70
> > max 9999999
> > cost e Will quote shipping cost.
> >
> >
> >
> > free_z1: Free Shipping!
> > criteria [noship_item method=free_z1]
> > min 1
> > max 1
> > cost e Can not ship item by Free Shipping.
> > min 2
> > max 2
> > cost >>free_z1_price
> >
> > free_z1_price: Free Shipping!
> > criteria price
> > min 0
> > max 200
> > cost e Spend $200 or more and get Free Shipping (on most items.)
> > min 200
> > max 9999999
> > cost f 0 + [shipping_cost method='ups_ground_res_z1' mode='none']
> > free on most items.
> >
> >
> > The shipping tag used in Vermont US now generates the following:
> >
> > shipping =
> > <select name="mv_shipmode">
> > <option value="ups_ground_res_z1_price">UPS Ground - Zone 1 ($8.50) <<<<<------- the problem... Value should be "ups_ground_res_z1"
> > <option value="ups_3day_z1">UPS 3 Day Select - Zone 1 ($19.00)
> > </select>
> >
> >
> > Aha, Notice the value = "ups_ground_res_z1_price"
> >
> > This breaks the form and causes $0 shipping charge!
> >
> > It seems as if you can only "forward" once. If I forward the cost again
> > to another method, it sets the form value to the prior method, (which is
> > not in the country.txt file) when it should set the value to the overall
> > parent method.
> >
> > Also, if there are any errors, I would rather it didn't allow for a
> > checkout at all and instead returned an error notice/page...
> >
> > Has anyone come across this before? and/or fixed it? Or maybe there is a
> > totally new way to do shipping on the way?
> >
> > Thanks!
> > Rick
> >
> >
>
>
> I made some mistakes in the above example when trying to simplify...
>
> Anyway, All the 1's and 2's I have for min-max on the main methods using
> my [noship] tag should be all 0 and 1... Does this make sense? I think
> I am going mad ;) Basically if I forward the "cost" more than once, it
> picks up the prior method label as the value in the <select> <option>
> when it should always be the top parent...
>
> I hate to start digging into the shipping tag, has anyone else run into
> this?
>
> Thanks!
> Rick
>
Hi,
This is a follow up that solved my problem and I hope it helps someone.
Basically, My client wanted a way to add extra charge for some items,
but also stop some items from shipping at all on some methods, but also
to give "Free Shipping" to some methods, but not where shipping should
be stopped, or add an extra cost for some items. I will be working out
finer details, but if anyone is interested, I did the following:
Add shipping_modifier table:
Database shipping_modifier shipping_modifier.txt __SQLDSN__
Database shipping_modifier COLUMN_DEF "code=CHAR(24) NOT NULL PRIMARY KEY"
Database shipping_modifier COLUMN_DEF "sku=VARCHAR(64)"
Database shipping_modifier COLUMN_DEF "quantity=CHAR(4)"
Database shipping_modifier COLUMN_DEF "method=VARCHAR(64)"
Database shipping_modifier COLUMN_DEF "noship=tinyint(1)"
Database shipping_modifier COLUMN_DEF "price=DECIMAL(6,2) DEFAULT '0.00'"
Database shipping_modifier INDEX sku quantity method noship
This is where you would place a sku/method with either an extra price
for that item/method or a "1" in noship field that says do not ship by
this method.
Then I added a noship_item tag:
UserTag noship_item Order method allowfree
UserTag noship_item Routine <<EOR
sub {
my ($method, $allowfree) = @_;
my $noshipcheck;
my $noshipsku;
my $noship;
for (@$Items) {
$noshipcheck = $Tag->query( {
sql => "SELECT sku, noship FROM shipping_modifier
WHERE sku = '$_->{code}'
AND method='$method'
AND noship='1'",
wantarray => 1
} );
$noshipsku = $noshipcheck->[0]->[0];
$noship = $noshipcheck->[0]->[1];
if ($noship) {
$Tag->tmp({
name => "noshipsku",
body => "$noshipsku",
});
$Tag->tmp({
name => "noshipmethod",
body => $method,
});
return 1;
}
}
if ($allowfree){
my $subtotal = $Tag->subtotal({ noformat => 1, });
if ($subtotal >= $allowfree){
return 2;
}
}
else {
return 3;
}
}
EOR
This tag should probably have a different name, but it basically takes 2
args. the name of the method (as defined in shipping.asc) and a flag
for if you should allow for free shipping or not. It returns the
following:
1 - if there is an item in the cart that should stop shipping by this
method. This also sets a tmp variable "noshipsku" (the offending item
in the cart that stops shipping) and "noshipmethod" which is "this"
method. This allows you to test and display the cart in various ways to
show the customer what is going on.
2 - if shipping on the cart is OK, AND the subtotal of the cart is over
a certain price that will allow qualify for "Free Shipping" via this
method.
or 3 - If the subtotal is not quite high enough to qualify for shipping
AND there is nothing in the cart stoping shipping via this method.
Sample use of the tag (in shipping.asc)
ups_ground_res_z1: UPS Ground - Zone 1
criteria [noship_item method=ups_ground_res_z1 allowfree=200]
min 1
max 1
cost e Can not ship item by UPS Ground - Zone 1.
min 2
max 2
cost f 0 + [shipping_cost method='ups_ground_res_z1' mode='none']
free Free Shipping!
min 3
max 3
cost >>ups_ground_res_z1_weight
ups_ground_res_z1_weight: UPS Ground - Zone 1
criteria weight
min 0
max 4
cost f 8.50 + [shipping_cost method='ups_ground_res_z1' mode='none']
min 4
max 15
cost f 11.50 + [shipping_cost method='ups_ground_res_z1' mode='none']
min 15
max 30
cost f 20.50 + [shipping_cost method='ups_ground_res_z1' mode='none']
min 30
max 70
cost f 30 + [shipping_cost method='ups_ground_res_z1' mode='none']
min 70
max 9999999
cost e Please call for shipping cost.
The "allowfree=200" param says "if the subtotal is $200 or more, then
free shipping is allowed for this method.
The last thing is the shipping_cost tag (which should also be named
something else...) that basically looks to see after the first criteria
passes, now look and see if there should be an extra shipping charged
based on items in the cart. The last tag is not quite finished, and
should be consolidated (since I am already looking into
shipping_modifier table anyway on the first tag) but you should get the
idea.
Thanks
Rick
More information about the interchange-users
mailing list