It's odd that I've run into this in three of four store CMS systems I've put online for clients. The first time was in a Zen Cart (a ways back) implementation. Now I've run into it twice in Drupal 6 and Drupal 7 implementations.

Here's the current scenario. I am working on a jewelry site that has core products (for illustration let's say a particular necklace).

I have the following modules working in addition to a current Drupal Commerce (installed from Kickstart):
Customizable Products
Product Attributes
Product Options
Product Option Set Reference

When a shopper views the necklace and decides to purchase it, there are some options. I'm using the Option Set to add the sets of options to the product.

1. The shopper can specify a word to be engraved onto the necklace (done... easy)
2. The shopper can specify a birthstone to be on the necklace (done... easy)
3. The shopper can add additional discs, each with engraving to the necklace and each disc adds $5 to the cost (stumped... difficult)

The problem is I can create a way for them to add the additional discs and even to specify letters for engraving the additional disc. What I cannot figure out is how to add to the cost of the item the $5 per additional disc added.

I tried adding a field to the option set with the type of price but that lets the shopper fill in a price value like a text field.

At this point I'm researching using rules to programmatically add the cost. This doesn't appear to be a very easy-to-configure method.

This is a consistent issue across ecommerce platforms I've worked with. Anyone have any suggestions for solving it on this site?

Comments

AJen’s picture

Using Rules seems like the logical answer

craigkendall’s picture

I was afraid you'd say that... can you point me to a good (make that great) resource for documentation on doing it that way?

AJen’s picture

AJen’s picture

And there's also this http://dev.nodeone.se/en/learn-the-rules-framework

I haven't watched this particular one yet, but what I have watched in the Node One Learning Drupal series has been fantastic

AJen’s picture

And there's also this http://dev.nodeone.se/en/learn-the-rules-framework

I haven't watched this particular one yet, but what I have watched in the Node One Learning Drupal series has been fantastic

dornea.nu’s picture

Does anybody has a working rule for this particular problem? My problem is very similar to the one above so any help would be appreciated.

Thanks.

kbrinner’s picture

I have this working on a commerce site now. Basically you create a custom module that allows rules to access commerce options. You then create a rule so when a commerce option is selected, the price of the line item changes. Here are the steps:

  1. Create a custom module based on http://drupal.org/node/1205628. I named mine 'commerce_option_rules', and within this module create the commerce_option_rules.info file, an empty commerce_option_rules.module file, and a file named commerce_option_rules.rules.inc. Take the text provided by orbface9 at http://drupal.org/files/issues/commerce_option.rules_.inc_.txt and place it in your commerce_option_rules.rules.inc file
  2. Enable your new commerce_option_rules module - this module allows you to access Commerce Options from a pricing rule condition
  3. Go to store -> config -> pricing rules and add a new rule - this will be your rule using your option set
  4. So you have your rule 'event' which is 'Calculating the sell price'. Now you can create your condition based on the user selecting something from your option set, so add a condition to make this happen
  5. In the 'select a condition' dropdown of your new rule, you should now have a 'Commerce Options - Compare Options' item - select this. If you don't have this option, the custom module isn't working right
  6. In the next screen, select commerce_line_item for your Data Selector, and below this there should be an 'Option' dropdown. Select your option set here
  7. In the value field, you need to enter something appropriate to your option set. If it is something simple like a yes or no, enter '1' so if someone checks a checkbox the rule will fire. If you had a list for your options set, enter the key in your key|value pair.
  8. Save
  9. Now add your action which is probably 'add an amount to the unit price'. I also add a 'show a message on the site' action as well while I'm working to make sure that the rule is firing when I want it to
  10. Now try it out - you'll need to add the item to your cart to check to see if the price is changing per your action. The price isn't updated dynamically on the page

I hope these instructions work for you - I'm using this setup on 2 sites and it's working great - now I just need to figure out how to update prices dynamically....

marcolam’s picture

Hi,kbrinner.
Does this only work for version 7.x-1.0-beta2 ?
I use 7.x-2.x-dev but don't see a 'Commerce Options - Compare Options' item.

junetellain626’s picture