Tags/topics: 
3
Answers
Vote up!
0
Vote down!

Set Price to less than $.01?

I am setting up a book editing site and need to set the price per word at $.005.

Customers will set the quantity (word count) and we will have a minimum purchase of 2500 words, but I can't figure out how to calculate the price after that at a rate of $.005 per word.

Any ideas?

Asked by: vjorden
on May 28, 2013

3 Answers

Vote up!
0
Vote down!

If I understood correctly, 2500 words would be $12.50

If you add a custom field to the Product line item type, say "Word Count" (field_word_count). You could use the rule attached at the end to give you ideas on how to accomplish what you want.

Initially, I struggled to get the correct pricing. In the "Calculate a Value" action, I was using .005 as the multiplication factor, but the correct value is .005 x 100 = .5

I expected the data type conversion to be handled on the backend, but doesn't seem to be the case. (The price 1 dollar is really stored as integer 100 to prevent floating point issues, so .005 dollars is actually .5 integer, which makes things more confusing :D, any hints appreciated!)

{ "rules_word_count" : {
    "LABEL" : "Word Count",
    "PLUGIN" : "reaction rule",
    "WEIGHT" : "10",
    "REQUIRES" : [ "rules", "commerce_line_item", "commerce_product_reference" ],
    "ON" : [ "commerce_product_calculate_sell_price" ],
    "IF" : [
      { "entity_has_field" : { "entity" : [ "commerce-line-item" ], "field" : "field_word_count" } }
    ],
    "DO" : [
      { "data_calc" : {
          "USING" : {
            "input_1" : [ "commerce-line-item:field-word-count" ],
            "op" : "*",
            "input_2" : ".5"
          },
          "PROVIDE" : { "result" : { "word_count_price" : "Calculation result" } }
        }
      },
      { "commerce_line_item_unit_price_amount" : {
          "commerce_line_item" : [ "commerce_line_item" ],
          "amount" : [ "word-count-price" ],
          "component_name" : "base_price",
          "round_mode" : "0"
        }
      }
    ]
  }
}
Answer by: Favio Manriquez
Posted: May 29, 2013
Vote up!
0
Vote down!

This worked brilliantly! Thank you!

VJ

Answer by: vjorden
Posted: May 29, 2013
Vote up!
0
Vote down!

I originally thought this worked, right off the bat, but then realized didn't quite do what I wanted, but I have used this as a start to figure out the solution.

So, I did add a field to line item type called 'word count'

Then created a product called Editing services and set the price to the cost per 250 words, in this case $1.25.

Then created a price rule, setting the conditions to Entity has field: Word Count

Actions: Set a Data Value: Set the line-item quantity = Word Count
Divide the Unit Price by Some Amount: /250.

I then hid the quantity and unit price fields in the shopping cart and added the Word Count field, so all of this is transparent to the customer. Now the shopping cart shows the word count and the calculated price.

Thanks for the help!

VJ

Answer by: vjorden
Posted: Jun 17, 2013