How to Modify the Price of an Item Based on the Characteristics of the ItemID: Q229822
|
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.
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.99When 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:
Medium / $10.00
Large / $11.99
X-Large / $12.99
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. Additional query words:
Keywords :
Version : winnt:3.0
Platform : winnt
Issue type : kbhowto
Last Reviewed: May 17, 1999