Forum for discussing general topics related to Couch.
4 posts Page 1 of 1
Hello everyone, I'm developing a new website with CouchCMS and I have to solve the following "problem":

I must create a product page and this product must have variants which you can choose the quantity and this changes the final product price, for example.

- Product A (base price $10.00)
-- Variant A (+$1.00)
-- Variant B (+$2.00)
-- Variant C (+$3.00)

So, if the user buy the "Product A" with 2 units of the "Variant A", he should pay $12.00, or if he buy the "Product A" and 1 unit of the "Variant C", he should pay $13.00, for example.

The user would go to the product page, there would be number inputs to him select the quantity of the variants, when he hit the "Add to cart" button, the system would calculate the variants.

While I had used Couch before, I don't know how is the best way to solve this issue, could you help me?
A little clarification needed - you mentioned
So, if the user buy the "Product A" with 2 units of the "Variant A", he should pay $12.00

Shouldn't that be $22 (Variant A = $11 (Base Price $10 + $1) multiply by 2)?

Please let me know.
KK wrote: A little clarification needed - you mentioned
So, if the user buy the "Product A" with 2 units of the "Variant A", he should pay $12.00

Shouldn't that be $22 (Variant A = $11 (Base Price $10 + $1) multiply by 2)?

Please let me know.


No, it would really be $12.00, it is like the variants would be "sub-products".

It's something like this:
The base product is a software that controls sensors, it has its price (for example, $10), but together with the software you should buy at least 1 sensor, which, as the example, would be $1.00 each. So, if you want to buy the software and 5 sensors, you would pay $15.00, $10.00 for the software and $5.00 for the sensors.

Also, there are different sorts of sensor and then may have different prices.

I'd make it separated, but they request me to make the buy all together (software + sensors) in a single form.
Thanks for the clarification.

Well, so what you are looking for is not the 'variations' of the same product. Rather, it is more like 'bundled' products.

I gave this use-case some thought but couldn't come up with any straight-forward solution, I am sorry.

One way of doing it could be by declaring two variations of the product -
1. The 'VariantA', 'VariantB' etc. (dropdown or radiobuttons) with their price-modifiers
2. A 'dummy' variant showing a dropdown of values 1, 2, 3, 4, 5, etc. This would be to choose the quantity of whatever variant is chosen from step 1 above.

We cannot use the default quantity spinner that shows up with the product because that sets the quantity of the main product (e.g. the 'software' in your case) whereas this one sets the quantity of the auxiliary addon product (e.g. the 'sensor'). Hence the need for a separate input for quantity in step 2 above.

So, suppose, the visitor chooses 'VariantB' (price-modifier $2, e.g.) and '2' as quantity, we can now use some PHP in cart_ex.php (in the pre_calc() function specifically) to multiply the $2 with the 2 of quantity and add this to the base price.

Kind of hacky but should work if there are only a finite number values for the 'quantity' dropdown.

Let me know how that sounds and whether you'd need any help in coding it up.

Thanks.
4 posts Page 1 of 1