Hi,
I am building a site with drupal commerce, and Commerce Product Attributes (CPA) helped me a lot!
I can now add color and size on add to cart block and form, which is great.
But in my situation a size of a product gives a different price.
How can I change the price when changing the size of a product?
greetings,
Martijn
Comments
Comment #1
andrewscullion commentedYou simply have to change the price for that product, i.e. the SKU of the large has price x and the SKU of the small price y.
Comment #2
wqmeng commentedto:andrewscullion
I am not sure it is a solution or not, simple change the price for a product which have less attributes is a easy thing. But once a product have many attribute and each attribute have many options which may have different prices. It is impossible to do it as simple as you said.
For ex, a DIY Computer have attributes processes, hard drivers, Ram, main board, case, power supply. It is very hard to give each combine a price as there are too many of it.
But it will be more easier to do it once you give each attribute options a base price. Then calculate the products price from it like what Ubercart do.
Comment #3
clasie commentedHi wqmeng,
I read your post and see we have more or less the same topic. If you found a solution it'd be to gratefull to know it.
For the clarity of my situation I can discribe it in short:
I got a product (a saddle pad) with a base price.
The customer has the possibility to add lots of ornamentations on the selected product.
And then the price varies on those.
Thank you for any help.
Clasie
NB: Meanwhile it seems at first sight that the 'inline entity form Module' is a possible solution.
Comment #4
wqmeng commentedThere is no a solution yet if you have many attribues of options with different price. In my case I will get over 10000+ variations for each product, if I count all my options in. It will cause the site performace very worse when you do it. If you in this case, Use Ubercart maybe the best choise.
More discussion can be find here.
http://www.drupalcommerce.org/faq/product-attributes
good luck.
Comment #5
clasie commentedThank you for the reply.
In fact I've had to reject this solution too for the reasons you explaind. I solved this by using rules and components.
Regards
Comment #6
wqmeng commentedHello clasie,
How much attribute and option do you have? Do you use Commerce Product Attributes and Commerce Product Options module to do this?
And could you share your details of how to do it?
Thank you.
Comment #7
clasie commentedHello,
I have very customisable products with a price depending on it. On average it is about 5 lists of options possible per product having in each list +- 8 choices. Then it's about 8x8x8x8x8 = 32768 prices per product. Of course somme have less and other more.
I used product properties and rules. I created a taxonomy to flag a product as 'must be calculated with rules or not and whith which rule'.
When the price calculation rule time occurs I use this flag to avoid trying to calcul for products that don't need to be modified by rule calculation.
I need to use component in order to bring products properties reachable in rules. When a product is detected as candidate to rule's calcul tests (if...) are launched to determine the rule price corresponding to this product 'flag'.
Once the mecanic is installed you can clone components and rules for each rule needed.
Beause I discover drupal commerce I cannot guarantie that there is no more efficient ways of doing this. But as a mater of fact it works quite quickly.
If you have like me lots of fields to put into your 'cart form view' you could perhaps have a look in an issue I encounter, by luck you could have had reached something like that and have found a solution. By chance, whoe knows? :) This issue is here: issue
Regards.
Claude
Comment #8
wqmeng commentedHello clasie
You said that you use product properties, do you mean that you use the the field in the commerce product type? Or you use commerce_product_attributes here?
If you use field so you have created 30000+ variants for each product? Then you use rules to adjust the price of the variants by the field value?
Thanks for sharing the information.
Comment #9
clasie commentedCould you give me an example of a product you sell requiering price adaptation and I'll tune a response according to it?
Claude
Comment #10
wqmeng commentedHello clasie,
I sell servers on line, which may have many attributes and options of each attribute. Such as I have a server base on processor E3-1230.
Server E3-1230
Attributes :
Memory (4G, 8G, 16G, 32G)
Primary HDD (500G, 1TB, 2TB, 3TB, 128G SSD, 256G SSD)
RAID (None, SoftRaid1, SoftRaid0, HardRaid1, HardRaid0, HardRaid10, HardRaid6)
2nd HDD (None, 500G, 1TB, 2TB, 3TB, 128G SSD, 256G SSD)
3rd HDD (None, 500G, 1TB, 2TB, 3TB, 128G SSD, 256G SSD)
4th HDD (None, 500G, 1TB, 2TB, 3TB, 128G SSD, 256G SSD)
Operating system (CentOS, Debian, Ubuntu, Fedora, FreeBSD, XenServer, Windows 2003 Standard, Windows 2003 Enterprise, Windows 2008 Standard, Windows 2008 Enterprise, ...)
OS Architecture (32 BIT, 64 BIT)
OS Language (ENG, ...)
Bandwidth Plan (10Mbps, 100Mbps, 1Gbps, 10TB, 100TB ...)
Additional IP Addresses (5, 13, 29, 61, 125, 255)
Control Panel (Plesk, CPanel, ...)
These attributes and options are must need. You can know that still many attributes that can add such as Locations, Firewall, backup and more.
I have tried many case with Commerce, not get a real solution yet.
Thank you so much for any suggestion.
Comment #11
clasie commentedSorry for the delay.
If you don't know how to use 'Rule component' youd'beter follow tutos on this. As for example those made by Randy Fay as for example here.
Ok my suggestion then...
A] At the product level
-----------------------
1- create a product type 'Server'
2- add price fields in it for ALL options such as
Server
- price_memory_4g -> enter a default price in it
- price_memory_8g -> enter a default price in it
...
- price_control_panel_cpanel -> enter a default price in it
3- Add to this product type another field. A flag field.
The purpose of that field will be to help rules (explained below) to detect if there is any need to calculate the price of this object, and then avoiding lots of test into rules that are not necessary.
This field will be a taxonomy field.
Every instances of this object type that do not need calculation will left this field in the 'none' selection status when creating one instance of it.
Other products will at the contray select the type of server (if any) that could have other prices and/or option to calculate with and then acoordingly select the right rule to calculate the respective server's price.
Basic example of taxo struct
Severs
- E3-1230
- ...
- E3-12700
Now create one or more instances of it.
B] At the display level
-----------------------
1- Create a content type for the server (and add the product instance to it of course).
2- create a custom line item that will be associated with the previously created content type
The custom line item will contain Drop-down list vals as for example:
Memory (mandatory for example)
-4G
-8G
-etc...
Primary HDD
-None
-500G
-etc...
C] At the rules level
-----------------------
Create a rule that will
1- detect if a calculation is needed (the taxo field in the product concerned is not 'none' ?). You can detect this only with 'Rule component'.
1.1 if so which one, the E3-1230 one? then we select the rule created for this case.
1.2 We use here another component containing rules. And for each option we modify the price one option after another if any detected in the line-item.
At the end you could have rules like this:
Rule E3-1230
if -> Call Rule_component_need_calculation'
Then -> Call Rule_component_for_E3-1230 if the caller is an E3-1230 object
Rule E3-1240
if -> Call Rule_component_need_calculation'
Then -> Call Rule_component_for_E3-1240 if the caller is an E3-1240 object
Rule Printer_HP_2020
if -> Call Rule_component_need_calculation'
Then -> Call Rule_component_for_printer_HP_2020 if the caller is an printer_HP_2020 object
NB: Rule_component_for_E3-1230 will be a Rules component containing one rule by option related to this product. When calculating the price the rules will use both the price values you entered into your product and the value of the ids selected by the customer when selecting the options. With both those value it can decide how to improve the price according to your policy or strategy.
Then for example if you have a product needing calculation and having 20 possible options then the 'Rule_component_for_E3-1230' will contain 20 rules. When proceeding through those rules each one will sum up their own calculation and at the end the basic price will be updated to the correct amount.
Hope this will help.
Claude
Comment #12
clasie commentedTo illustrate more completely:
Sample of rules
Rule 46 [1]
if -> Call Rule_component_need_calculation' [2]
Then -> Call Rule_component_for_id_46 [3] if the caller is an id 46 object
------------------------------------------------------------------[1]
{ "rules_calcul_price_vals_for_r_sc_sacs_perso_nonacc_noble" : {
"LABEL" : "Calcul price vals FOR r\/sc\/sacs\/perso\/nonacc\/noble id 46",
"PLUGIN" : "reaction rule",
"TAGS" : [ "Calcul price vals FOR r\/sc\/sacs\/perso\/nonacc\/noble id 46" ],
"REQUIRES" : [ "rules", "commerce_product_reference" ],
"ON" : [ "commerce_product_calculate_sell_price" ],
"IF" : [
{ "entity_has_field" : { "entity" : [ "commerce-line-item" ], "field" : "commerce_product" } },
{ "component_rules_has_val_prices_to_rule_id_46" : { "product" : [ "commerce-line-item:commerce-product" ] } }
],
"DO" : [
{ "component_rules_vals_calculus_filter_id_46" : {
"product" : [ "commerce-line-item:commerce-product" ],
"line_item" : [ "commerce-line-item" ]
}
}
]
}
}
------------------------------------------------------------------[2]
{ "rules_has_val_prices_to_rule_id_46" : {
"LABEL" : "Has val prices to rule id=46",
"PLUGIN" : "and",
"TAGS" : [ "Has val prices to rule id=46" ],
"REQUIRES" : [ "rules" ],
"USES VARIABLES" : { "product" : { "label" : "Product", "type" : "commerce_product" } },
"AND" : [
{ "entity_has_field" : { "entity" : [ "product" ], "field" : "field_rules_to_calcul" } },
{ "NOT data_is_empty" : { "data" : [ "product:field-rules-to-calcul" ] } },
{ "data_is" : { "data" : [ "product:field-rules-to-calcul:tid" ], "value" : "46" } }
]
}
}
------------------------------------------------------------------[3]
{ "rules_vals_calculus_filter_id_46" : {
"LABEL" : "Vals Calculus Filter: id=46",
"PLUGIN" : "rule set",
"TAGS" : [ "Vals Calculus Filter: id=46" ],
"REQUIRES" : [ "rules", "commerce_line_item" ],
"USES VARIABLES" : {
"product" : { "label" : "Product", "type" : "commerce_product" },
"line_item" : { "label" : "Line_item", "type" : "commerce_line_item" }
},
"RULES" : [
{ "RULE" : {
"PROVIDE" : { "result" : { "val_to_add_to_price_bords_dec" : "val_to_add_to_price_bords_dec" } },
"IF" : [
{ "entity_has_field" : {
"entity" : [ "line-item" ],
"field" : "field_sc_sac_perso_nob_bord_dec"
}
},
{ "NOT data_is_empty" : { "data" : [ "line-item:field-sc-sac-perso-nob-bord-dec" ] } },
{ "entity_has_field" : { "entity" : [ "product" ], "field" : "field_prix_bord_decalees" } },
{ "NOT data_is_empty" : { "data" : [ "product:field-prix-bord-decalees" ] } }
],
"DO" : [
{ "data_calc" : {
"USING" : {
"input_1" : [ "product:field-prix-bord-decalees" ],
"op" : "*",
"input_2" : [ "line-item:field-sc-sac-perso-nob-bord-dec" ]
},
"PROVIDE" : { "result" : { "val_to_add_to_price_bords_dec" : "val_to_add_to_price_bords_dec" } }
}
},
{ "commerce_line_item_unit_price_add" : {
"commerce_line_item" : [ "line-item" ],
"amount" : [ "val-to-add-to-price-bords-dec" ],
"component_name" : "base_price",
"round_mode" : "0"
}
}
],
"LABEL" : "sc sacs perso nob bord dec"
}
},
{ "RULE" : {
"IF" : [
{ "entity_has_field" : {
"entity" : [ "line-item" ],
"field" : "field_sc_rubans_sac_perso_noble"
}
},
{ "NOT data_is_empty" : { "data" : [ "line-item:field-sc-rubans-sac-perso-noble" ] } },
{ "entity_has_field" : { "entity" : [ "product" ], "field" : "field_prix_ruban_zx" } },
{ "NOT data_is_empty" : { "data" : [ "product:field-prix-ruban-zx" ] } }
],
"DO" : [
{ "commerce_line_item_unit_price_add" : {
"commerce_line_item" : [ "line-item" ],
"amount" : [ "product:field-prix-ruban-zx" ],
"component_name" : "base_price",
"round_mode" : "0"
}
}
],
"LABEL" : "sc sacs perso ruban zx"
}
}
]
}
}
Comment #13
georgemastro commentedCheck this new module http://drupal.org/project/commerce_pricing_attributes
It handles a lot of the missing features.
Comment #14
Nasferiti commentedYes, it could work, but How? I tried but I tried but I'm very confused....
Comment #15
adk228 commentedHi
I sell food products on my website. I created different variants of the same product with different names and prices. However, the product name is getting automatically derived by the selected variant name.
Example: Product Name Cashew Nuts
Variants: 500 gms and 1000 gms.
When I select 500 gms variant, the name of product is shown as 500 gms instead of cashew nuts.
How can I handle this?