[ic] Change the price on the fly, without CommonAdjust

Mike Heins interchange-users@lists.akopia.com
Wed Jun 27 17:22:01 2001


Quoting Ron Phipps (takedown@cdsnet.net):
> Hello list,
> 
> I've been reading the documentation for CommonAdjust that was posted by Mike
> here:
> 
> http://developer2.akopia.com/archive/interchange-users/2001/msg03850.html
> 
> It appears that CommonAdjust is based off of values in the pricing table and
> fields in the product database.  However for the project that I'm working on
> does not seem to fit this mold.  I'll first explain the situation.
> 
> The code I have now generates a case order form based on records both in the
> products table and support tables I have designed for the case modifiers.
> Each part of the case can be customized with a different anodized color.  If
> the user selects a color already in the list they are not charged extra for
> these colors.  However if they select 'Custom Color' they are charged $15.00
> for each additional color.  If they select Custom Color for 10 parts and the
> custom color they would like is the same for all 10 parts then they are only
> charged $15.00 (since the anodizing is done in a batch) not $150.00.  Each
> part is a modifier to the case (the case is one product sku) and each part
> also has a modifier for the color.

I don't see why putting a UserTag in CommonAdjust wouldn't work here.
You have all item attributes available in $item -- I have posted UserTag
access examples many times.

> 
> I already have the code that determines the price of the case and what I
> would like to do is set the price of the case for that particular item in
> the cart.  All of the mailing lists items I looked through (516) talked
> about using CommonAdjust but in those case it was only one level of
> modifiers (size, color, etc..) and in this case it is two levels (a modifier
> of a modifier).  Is it possible to use perl to change the price for a
> certain cart item after it is added to the cart?  Is it possible to change
> the price before it's added to the cart?  If I change the price of the item
> will the other subtotal and total fields work properly?

You can always set the mv_price attribute in the item:

[perl]
	foreach my $item (@$Items) {
		# All items are $5.00 in this store!
		$item->{mv_price} = 5;
	}
	return;
[/perl]

To use mv_price, you need to have an atom which is $ (or begins with $).

    CommonAdjust   $ ;pricing:price_group,q2,q5,q10:, ;:price, ==options

will work this way.  And of course it does work with all of the subtotals
and such, just as all standard methods do.

-- 
Red Hat, Inc., 3005 Nichols Rd., Hamilton, OH  45013
phone +1.513.523.7621      <mheins@redhat.com>

Just because something is obviously happening doesn't mean something
obvious is happening. --Larry Wall