0

I would like to have a field that accepts U.S. dollar amount. I installed the module: https://www.drupal.org/project/currency. Structure > content type > I do not see a field type "Currency". I am not sure how I can add a field to accept USD amount.

How can I add the price field to the content type?

3
  • Hi, what do you need it for? If you just need to display some dollar amounts you can create a decimal field and then change display output to have $ prefixed. May 15, 2017 at 4:15
  • I need it for a real estate site. I like to add a price field for the house value. Currency module I installed might be for a bigger project. I will have to do some research on how to add a decimal field. Thanks.
    – autop
    May 16, 2017 at 4:56
  • Are you using drupal 7 or 8? Ill modify my answer based on which version youre on. May 16, 2017 at 11:09

1 Answer 1

-1

So to add a decimal field.

  • edit your content type.
  • manage fields
  • add new field
  • select Decimal from the Field Type dropdown.
  • Click the 'Save' button
  • Change 'Scale' to 2. These are the cents.
  • Click the 'Save field settings' button.
  • In the Prefix field add '$'.
  • Click the 'Save settings' button
6
  • Thanks. Drupal 7. I did not see number field. I see integer field. I added integer field then widget (decimal > text field) > saved it. Where do I specify 2 decimal places? I also did not understand this part "To prefix a $ to the display value you may need to add a template_preprocess_field and add a #prefix to the field."
    – autop
    May 19, 2017 at 1:11
  • Drupol, I've updated the instructions. I updated the step by step while actually creating my own field. May 19, 2017 at 3:56
  • I don't have decimal field type. I need to install another module to see decimal field type?
    – autop
    May 21, 2017 at 4:31
  • Nope. It's a default field. api.drupal.org/api/drupal/… Be sure to update drupal core. May 21, 2017 at 7:03
  • @JapoDomingo What if we want to show the currency symbol depending on the user country? Also, how to show /hr or fixed prices?
    – Umair
    May 4, 2018 at 6:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.