When a product kit is created with some products selected, the price of the kit is always set to 0 when it's first submitted. If the kit is then edited the discount values are set to 0, so unless they're edited the kit price will remain at 0. If they're deleted (empty string), then the kit price will become the sum of the contained products.
I'm guessing what should happen when the product is first submitted (without the discount values being set because the product option forms don't show until the kit is submitted, see this issue) is that it should default to the price of the product and not 0.
Rather than setting it to the product price in the database (which then wouldn't be updated if the product price is updated later on), may I suggest leaving it at 0 and slightly modifying the behaviour of the discount option such that entering 0 will cause it to use the item price with no discount.
This requires changing in uc_product_kit on line 130:
if ($node->items[$i]['discount'] < 0){
to
if ($node->items[$i]['discount'] <= 0){
on line 307:
'#description' => t('Enter a negative value to lower the item price by that amount. Enter a postive value to set the item price to that amount. This discount is applied to each %product in the kit.', array('%product' => $product->title)),
to
'#description' => t('Enter a negative value to lower (discount) the item price by that amount. Enter 0 to use the item price with no discount. Enter a positive value to set the item price to that amount in this kit. This is applied to each %product in the kit.', array('%product' => $product->title)),
and on line 504:
if ($kit_discount < 0){
to
if ($kit_discount <= 0){
This changes the behaviour so that a discount value of 0 will simply be subtracted from the item price for the kit (so the item price will be used as is) rather than setting the item price to 0 in the kit.



Re: Product kit item discount behaviour
This would mean that someone who wants to offer an item in a kit for free would need to spread the discount to all of the products. I guarantee that someone would ask it to be changed back so that 0 represented a free product.
More options...
Hmm. The main problem I see with the current implementation is that there's no nice way for the user to automatically set the prices of items in a new kit to their current value, or to automatically update when those products prices are modified.
Perhaps it would be nice to let the user choose to use a discount, the current item price, or a fixed price for the item (with the first two options automatically updating when the price of a product in the kit changes, but perhaps this is beyond the scope of this issue?). I can see three ways of presenting this to the user:
1. Add three radio buttons that would let the user choose between: the current item price, a custom item price, or a discount on the item price, the text field would apply only for the last two options.
2. A checkbox could be added. If the checkbox is enabled then it would use the current behaviour, otherwise it would use the current item price.
3. Modify the discount field in the uc_product_kits table to allow null values (and default to null). Add "Leave blank to use the current item price" to the help text, and modify the code to always use the current item price for null or negative values.
I'm happy to code one of these if they're suitable, or some other solution.
oliver coleman wrote: The
The main problem I see with the current implementation is that there's no nice way for the user to automatically set the prices of items in a new kit to their current value, or to automatically update when those products prices are modified.
I agree - the whole pricing system for Product Kits needs work.
What I think should happen is:
1) At Product Kit creation, the kit "List Price", "Cost", and "Sell Price" fields should get initialized by default to the sum over the corresponding fields of all the included products. Right now, these all get set to "0", which is not a good starting point!
2) The admin should have the option of setting the "Sell Price" for the Kit directly, rather than having it be computed by discounts set on each component product separately.
3) Instead of, or in addition to, the discount field for each component product, there should be a markdown field that lets the admin specify a dollar value or percent markdown to apply to the Kit "Sell Price". (Similar to the shipping quotes markup textfield). For my purposes, it is sufficient that the markdown apply to just the Kit price - I don't need to markdown each component separately.
4) Only the price set by method 2) above should be stored in the table as part of the product kit. If the price is not set by method 2), then it should be computed every time based on the prices of the component products, the discount fields, and the markdown field. This way if one or more of the component costs goes up, the Product Kit prices are automatically kept up-to-date.
Re: oliver coleman wrote: The
Points 1 and 2 sound good.
For point 3: it might be best to allow individual markdowns for each product as this allows more flexibility for store owners and for future enhancements (for me, I'd love to be able to allow customers to remove and/or modify/upgrade certain items in a kit (see this thread), allowing a discount for individual items would blend better with this sort of thing).
Point 4: agree, assuming you mean that the store owner has the explicitly stated option of a fixed price for the entire kit which doesn't change (to avoid any nasty surprises), or automatically updated costs/prices calculated from each item and discount fields (to avoid any nasty surprises...)