How to Modify the Price of an Item Based on the Characteristics of the Item

ID: Q229822


The information in this article applies to:


SUMMARY

Commerce Store administrators may want to base the price of an item on a characteristic of the item; for example, charge a different price for an item based on its size or another attribute.

Commerce Server currently only permits administrators to set a list price and sale price for a particular product. Products with different sizes or weights must be added as individual product entities. The following example illustrates one method of charging different prices for a specific product based on the size of the product.


MORE INFORMATION

To accommodate this functionality, it is necessary to generate a site using dynamic attributes for the products in the store, and then define the dynamic attributes in the Site Manager pages with the "Attribute / Price" format. For example: define the first dynamic attribute for your product with a name of Size and with the following values:

Small / $9.99
Medium / $10.00
Large / $11.99
X-Large / $12.99
When the product is displayed to the shopper, the shopper will be presented with a drop-down box that allows them to choose the desired Size/Price combination. To force the Size/Price combination that the shopper has chosen to change the actual price that is charged for the product, simply create a scriptor component in Plan.pcf and insert it right before the DefaultItemPrice component:

function MSCSExecute(config, orderform, context, flags)
for each x in orderform.items
x.[_product_list_price] =  (mid(x.attr_value1,instr(1,x.attr_value1,"$")+ 1 ,len(x.attr_value1)- instr(1,x.attr_value1,"$")))*100
MSCSExecute = 1
next
end function 
The key here is to substitute the correct value for attr_value1; this is just the name in the order form for the dynamic product attribute that contains the Size/Price combination that the shopper selects.

It is also important that the dynamic attribute values are entered in the format "Size / $#.##" on the Manager pages for the scriptor to function correctly. This scriptor is merely setting the price of the product to the integer value of everything to the right of the dollar sign ( $ ) of the size attribute.

Additional query words:


Keywords          : 
Version           : winnt:3.0
Platform          : winnt 
Issue type        : kbhowto 

Last Reviewed: May 17, 1999