Page 1 of 1

Advice for complex order item

Posted: Fri Jan 11, 2013 12:09 pm
by denis
Hi,

I would like to have your opinion on a new functionnality that I have to develop :

I must have the possibility to create some Virtual Products :

A virtual product haven't a fixed price. The price is defined by :

- A modality access (DAY, MONTH, YEAR...), for instance 10$ for 1 month
- A list of Product Options, each product option have a price by a modality access, (for instance CITY ==> 1 MONTH ==> 5$)
(so final price for one Month and the option city is ==> 10$ + 5$ = 15$)

So I have only 1 sku (the default sku) for this type of product.

I have a problem when i add an item to the cart (DiscreteOrderItem) because i calculate and set the new Price to the order item but the pricing workflow use the default sku price (0$) and update the price of the order item added.

I don't really know which is the best solution :
- create a sku for each order item ?
- override all the pricing workflow ?
- Other idea ?

Thank for your advice !

Re: Advice for complex order item

Posted: Fri Jan 11, 2013 12:37 pm
by phillipuniverse
The price of the sku should take into account the product option values associated with it (see getRetailPrice() and getSalePrice() on SkuImpl). The price associated with the product option values should be added to the default Sku price (in this case, 0). Is there a bug in this process?

You might have to do something unique for the modality access part (perhaps http://docs.broadleafcommerce.org/curre ... ation.html) depending on how that is represented in the model.

Re: Advice for complex order item

Posted: Fri Jan 11, 2013 1:18 pm
by denis
Thanks for your reply phillipuniverse.

In fact we don't use product option values for this type of product

We have a custom ProductOption class (MyProductOption) and we use this class to create product options which are used to generate a form and then customers set a value (it can be an input) for each product option.

We don't generate skus (and maybe it's the problem) but a price for each option and each modality access (VirtualProductPriceByOptionAndModalityAccess).

The final goal is to generate a subscription related to a product, for instance :

Virtual Product : SubscriptionWeather
ModalityAccess : 1$/day, 10$/month, 100$/year

each product has one or several options (product option) with a price by modality access :
option1 : FullWeather
price : 10$/day, 11$/month, 200$/year

option2 : email
price: 5$/day, 15$/month, 30$/year

So if the customer select the modality access YEAR for the product SubscriptionWeather and choose the 2 options : the total will be : 100$ + 200$ + 30$. You can also choose X times the same option, if i choose 2 times the option2, total price will be :
100$+ 200$ + 30$ + 30$.

This is why it's difficult to generate all the possibilities (skus).

As far im concerned, i think there are 2 solutions :
1/ Generate a new sku each time i add a new product into the cart,
2/ Generate a sku for each modality access linked to the product (10$/day, 20$/month, 50$/year) and add Sku fees for each product option selected

What is your opinion ?

I hope I am clear enough.