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

How do I display price in user's currency using Price field from Commerce but NOT using Commerce Line Items

Hi

I have a product type node which is purely informational, i.e. there is no purchase, checkout, customers etc., which needs to have a price field. Most prices will be input in USD but some will be input in other currencies. What I wish to do is to input all currencies using the original price, in whatever currency this may be, but for the value to be output in whatever currency is appropriate to the user currently viewing the node (perhaps using SmartIP).

I followed the directions here - http://drupal.stackexchange.com/questions/38463/price-field-with-currenc... - which says that I can use a subset of Commerce, only implementing what I need. I have also enabled Commerce Multicurrency.

What I have got so far with this set up is:

1. I have a price field which allows information to be input in whatever currency is desired. And the current output is as per the input, complete with currency symbols. So, the raw data is in there. Yay!

2. A rule seems to have been created automatically - Display currency specific price, which sets the display price.

A block has also been created automatically, which has a dropdown box which allows the user to select which currency to display prices in. (Ultimately, I would like this to be done automatically, via SmartIP, but if I can get this working for now, this will suffice.) The snag is that selecting a currency currently does not do anything.

The problem is that when you go into the rule, into the action, the Data selector only has the options site: or commerce-line-item. As you cannot access the price field via either of these (the first doesn't drill down into the relevant content types where my field is stored and I don't use commerce-line-items), the field is blank, and so obviously the rule is not going to work, as it is not being applied to anything. I have been Googling, and I'm led to believe I should also have the node: option in here, which I would think is what I am after, to drill down to get at my field. So, I think the solution is to get this rule Data selector populated with node: but I don't know how to do this.

Any advice would be greatly appreciated.

Asked by: underaredsky
on April 27, 2014

2 Answers

Vote up!
0
Vote down!

Unfortunately, you cannot. The product pricing system that Commerce Multicurrency depends on always works through a product line item. This is to give the system as much contextual information as possible, such as order owner, shipping address, other products, etc. I understand you don't need all this for your desired rule (a simple currency switch), but we just don't have generic alteration support for price fields in general.

If I were developing a site with such a requirement, I'd create a new price formatter that could read the user's currently selected currency and convert the price field data to the required currency for display. That would make for a very fine feature in the Commerce Multicurrency module in my opinion.

Ryan Szrama
Answer by: Ryan Szrama
Posted: May 1, 2014
Vote up!
0
Vote down!

Thanks Ryan, I'll have a go at this tomorrow.

Answer by: underaredsky
Posted: May 1, 2014