Firstly this isn't an e-commerce site, this is just for keeping prices on the site for advertising purposes. The fact I mention prices is arbitrary, just think of any old data format, this could be text or just a number in a field.

We need a central place where all prices/data can be kept, there needs to be translation capability for each price as they differ from country to country, we then need to be able to use these prices throughout the site, and for them to all update, to propagate when the central data of the prices is changed.

My first thought is that a content type might be the way to go, this content type would only ever have one instance which would contain all the prices.

Then maybe creating a token for each price that could be used around the site, this would need to show the correct translation of that field also. I imagine this would need to be a custom module to create the tokens.

Maybe there is a better way to achieve the above, I would love to hear suggestions. Thanks

Comments

drupalnesia’s picture

I think what you like to achieve a multi currency site like PrestaShop does. So its to complicated (as I know) to provide DIFFERENT PRICE for each country without e-commerce module.

Take a look at https://www.drupal.org/project/commerce_multicurrency. In short, I think easier to install commerce module rather than create a custom module, except you are an module developer.

joe huggans’s picture

Hi, thanks but this isn't an e-commerce site, I just want to store prices in integer fields centrally. The fact it is a price is arbitrary, just think of it as storing any old data in a field centrally and then being able to use this data around the site, similar to how you might add a phone number to the theme settings and then use that in a template, then you don't need to update the phone number on every template, you simply update it in the theme settings.

The issue with me using theme settings is that I need translations, so using nodes or entities is just more simple.

onejam’s picture

If you want to reuse a single price field for different currency, you would probably need to build a custom module to render this because it would be a dynamic price that needs to change depending on which translation page is being viewed as the price will not be the same as you need to convert the price for different currency rates. 

Alternatively, you can create a content type and add the price individually and use the core translation module to create different language (country) nodes/pages. You can then change the price on each individual translated page to match the currency conversion rate of the price.  

-----------------------------------------------------------------
We build engaging websites and intuitive designs that will benefit your business.
Duvien

joe huggans’s picture

Thanks yes this is what I was planning on doing, I do need to use these values throughout the site, I think tokens in the best way to go.

onejam’s picture

Say for example you need to display content for UK, Germany and France. You create a page for each and enter the price for each of these pages in your content type. You will not need token cos when a site visitor views one of the translated page, they will see the price for that country as they are separate content pages. You can use this module to allow users to switch language (translation): https://www.drupal.org/project/lang_dropdown 

There is a problem using a static field for the currency price because currency rates do change daily. So it's best to build something dynamic where you can pull in the currency rate to calculate the latest price to display in its own currency based on which translated page is being viewed.

Alternatively, an easy way is to embed a currency convertor app and just let user do it manually to find the price in different currency. This way you can do away with all the complicated config and setup, including and custom coding and just create a standard page to show your content with price.  

-----------------------------------------------------------------
We build engaging websites and intuitive designs that will benefit your business.
Duvien