There are several functions which you need to make this happen.
- commerce_default_currency - Obtains default currency for the site (http://api.drupalcommerce.org/api/Drupal%20Commerce/sites%21all%21modules%21commerce%21commerce.module/function/commerce_default_currency/DC). This is one of the required parameters which is to be passed to conversion function.
- commerce_currency_decimal_to_amount - Function to convert price amount to integer amount for DB storage (http://api.drupalcommerce.org/api/Drupal%20Commerce/sites%21all%21modules%21commerce%21commerce.module/function/commerce_currency_decimal_to_amount/DC). Using this function is straight forward. Assuming we want to store the value of 300 in the DB, we simply call it using the following params:
commerce_currency_decimal_to_amount(300, commerce_default_currency());
- commerce_currency_format - Formats currency value from DB for display on page (http://api.drupalcommerce.org/api/Drupal%20Commerce/sites%21all%21modules%21commerce%21commerce.module/function/commerce_currency_format/DC). This does the opposite of what the previous function does. Once we obtain the DB value, we call this function to get the displayable value e.g. USD300.00
No comments:
Post a Comment