[ic] How to give each cart item its own flat rate shipping cost?AutoModifier, mv_sku/code problems

John1 list_subscriber at yahoo.co.uk
Sun Oct 23 16:51:27 EDT 2005

On Sunday, October 23, 2005 3:23 PM, mike at perusion.com wrote:

> Quoting John1 (list_subscriber at yahoo.co.uk):

>> I believe if I change AutoModifier to:
>> AutoModifier products:shipping_cost:mv_sku
>> it would then work for matrix option products but not standard
>> products.
>> How do I set it up so that the delivery cost is always looked up from
>> the field shipping_cost in the products table, regardless of whether
>> the cart item is a product with matrix options or a standard product.
> Hmm. I believe you are correct. Actually, I would want
> AutoModifier  shipping_cost
> to work, as we should use item_common to populate it. But alas, it
> does not.
Great, thanks.  So if I use ship.pm from the CVS my scenario should work

I noticed the call to "item_common" to populate AutoModifier.  What is

> That is now fixed in CVS. It only works for the no-table case of
> the attribute (i.e. shipping_cost or other_mod=shipping_cost).
> It also might not be completely what would always be wanted, since
> it has the precedence:
>    mv_ib->code
>    mv_ib->mv_sku
>    products->code
>    products->mv_sku
>    variants->code
>    variants->mv_sku
> It is important in this case to make sure you have the table set
> in the item mv_ib pointer, as otherwise products->mv_sku will shadow
> variants->code.
I think I see what you are saying - are you saying that I must
explicitly define the table used for variants in catalog.cfg in order
for the variants->code to take precedence over products->mv_sku?

BTW, in the end I found another solution to my problem by creating a
[calc_shipping] user tag to be called via "f [calc_shipping]" in

The user tag code is:

UserTag calc_shipping Order
UserTag calc_shipping Routine <<EOR
sub {

 my $total_shipping_cost;

 for (@$Items) {
  my $sku = $_->{mv_sku} || $_->{code};
  unless (defined $_->{shipping_cost}) {$_->{deliv_cost} =
  $total_deliv_cost += $_->{quantity} * $_->{shipping_cost};

 return $total_shipping_cost;


This seemed to do the trick, so I am happy.  I am not much of a Perl
programmer so would be grateful for any suggestions on improving the
above code if necessary.

Now I have this [calc_shipping] tag I haven't even bothered setting
AutoModifier or MV_SHIP_MODIFIERS.  Instead, I have tried to ensure the
database is only queried once by using "unless (defined
$_->{shipping_cost})" - is this a reasonable approach?

Thank you for your help Mike - it is always very much appreciated...

More information about the interchange-users mailing list