I have been trying to develop a solution for uCommerce whereby the price of a product can be changed depending on the value of a price definition.
For example, I have a base product that is priced at £10. I have three product definitions (height, width and thickness) which are drop down lists based on an enum data type.
I have created a dynamic user control (product configurator) that can take any product and render any definition depending on its data type. In this particular instance, the user contol renders the standard product data and the three product definitions as drop down lists. This is fine so far.
At this point, when a drop down list value is changed (ie the width) I want to be able to fire a request to a custom web service (custom logic) which will then return me a new price value.
I have read that I need to use the IPricingService interface. I have run through some initial tests to try and manipulate the data, however, what I am not quite understanding is how do i access the product definition data and which product definition value has changed?
Has anyone got any similar experiences with this particular approach?
IPricingService is used various places to add the price to the basket. Basically it just fetches the price from either the parent or the variant product. You can use this approach, but then as you say the default price of the product: £10 is not persisted - the price will always be dynamically calculated.
How do you want to use this "product configurator".
Is it a way of creating products and then set the price and have that product for future purchase or
is every product unique every time it is getting bought?
If 1: i would create the product with your configurator, then calculate and set the price. Then you don't have to fiddle around with IPricingService.
You can also just have the base price of your product and use IPricingService to fetch the price when it is being added to the basket.
IPricingService should then be overriden in Custom.Config by id "PriceService".
ProductDefinition data and products are linked together as ProductProperties which you can access in various ways:
As an indexer on Product with ProductDefinitionFieldName as the name.
Properties as it's collection can also be used directly.
I don't think you need to detect changes. You can start out by changeing properties and then calculate the price.
Thank you for your swift reply. I was hoping that you were going to suggest setting the values on the indexer of the product!
I think this approach will suit our scenario perfectly. However before I can progress with this, i was hoping that maybe you could answer a couple more queries:
1) As far as I am aware, the pricing pipeline is used on the product page and category pages (or any product listing page). Is there anywhere else within the solution that will use the pricing pipeline and potentially cause us some issues with our apporach?
2) When we 'Add to Basket', we will also need to update the price in the basket based on the configurator. Would you suggest using the 'AddPriceGroupPrice' method on the product when running the basket pipeline to achieve this?
3) How is the basket data stored?
Once again, many thanks for your swift reply. Its much appreciated!
1) The basket pipeline should execute every time the order is modified. Displaying a price on a product page should use CatalogLibrary.CalculatePrice(product); (Which in the end will somewhere use PricingService).
2) AddToBasket will use the pricing service to get the price on the product or product variant. So if the price of the product is store properly it will be reflected when you addToBasket.
3) Basket data is stored in The database as any other Order (just with status basket). A cookie is used to restore the basket for the user when he returns.
If you want to modify the price of a product you should use AddPriceGroupPrice. But not in the BasketPipeline.
Products and baskets are disconnected to each other. When you add a product to the basket, only a snapshot of the product is stored in the basket. Hence adding a product will use pricingservice to get the price of the product and set that on the orderline. Changeing a price on a product afterwards wont affect the basket.
I think i miss something here :)
When a user adds a product to his basket. Is he the one specifying which properties should be on the product?
Custom pricing
Hi all,
I have been trying to develop a solution for uCommerce whereby the price of a product can be changed depending on the value of a price definition.
For example, I have a base product that is priced at £10. I have three product definitions (height, width and thickness) which are drop down lists based on an enum data type.
I have created a dynamic user control (product configurator) that can take any product and render any definition depending on its data type. In this particular instance, the user contol renders the standard product data and the three product definitions as drop down lists. This is fine so far.
At this point, when a drop down list value is changed (ie the width) I want to be able to fire a request to a custom web service (custom logic) which will then return me a new price value.
I have read that I need to use the IPricingService interface. I have run through some initial tests to try and manipulate the data, however, what I am not quite understanding is how do i access the product definition data and which product definition value has changed?
Has anyone got any similar experiences with this particular approach?
Many thanks in advance.
Adam
Hello Adam,
Depending on how you want to proceed:
IPricingService is used various places to add the price to the basket. Basically it just fetches the price from either the parent or the variant product. You can use this approach, but then as you say the default price of the product: £10 is not persisted - the price will always be dynamically calculated.
How do you want to use this "product configurator".
Is it a way of creating products and then set the price and have that product for future purchase or
is every product unique every time it is getting bought?
If 1: i would create the product with your configurator, then calculate and set the price. Then you don't have to fiddle around with IPricingService.
You can also just have the base price of your product and use IPricingService to fetch the price when it is being added to the basket.
IPricingService should then be overriden in Custom.Config by id "PriceService".
ProductDefinition data and products are linked together as ProductProperties which you can access in various ways:
As an indexer on Product with ProductDefinitionFieldName as the name.
Properties as it's collection can also be used directly.
I don't think you need to detect changes. You can start out by changeing properties and then calculate the price.
Hope this helps.
Otherwise let me know :)
Best regards
Morten
Hi Morten,
Thank you for your swift reply. I was hoping that you were going to suggest setting the values on the indexer of the product!
I think this approach will suit our scenario perfectly. However before I can progress with this, i was hoping that maybe you could answer a couple more queries:
1) As far as I am aware, the pricing pipeline is used on the product page and category pages (or any product listing page). Is there anywhere else within the solution that will use the pricing pipeline and potentially cause us some issues with our apporach?
2) When we 'Add to Basket', we will also need to update the price in the basket based on the configurator. Would you suggest using the 'AddPriceGroupPrice' method on the product when running the basket pipeline to achieve this?
3) How is the basket data stored?
Once again, many thanks for your swift reply. Its much appreciated!
Thanks
Adam
1) The basket pipeline should execute every time the order is modified. Displaying a price on a product page should use CatalogLibrary.CalculatePrice(product); (Which in the end will somewhere use PricingService).
2) AddToBasket will use the pricing service to get the price on the product or product variant. So if the price of the product is store properly it will be reflected when you addToBasket.
3) Basket data is stored in The database as any other Order (just with status basket). A cookie is used to restore the basket for the user when he returns.
If you want to modify the price of a product you should use AddPriceGroupPrice. But not in the BasketPipeline.
Products and baskets are disconnected to each other. When you add a product to the basket, only a snapshot of the product is stored in the basket. Hence adding a product will use pricingservice to get the price of the product and set that on the orderline. Changeing a price on a product afterwards wont affect the basket.
I think i miss something here :)
When a user adds a product to his basket. Is he the one specifying which properties should be on the product?
is working on a reply...