Let think you want show 10000 USD in your site with 10 K$, I did it with hook_commerce_currency_info_alter and work correctly, ( I enter price in scale Thoundans, this mean when my product price is 20000, I enter 20 in price field ),everything in view is fine but my problem is in payment gateways, I want when user go to payment gateways multiple total price to 1000.

Is there any hook or clean to I achieve it in my module?

Or another way is achieve this job only in display, in all displays division to 1000 ( price /1000) and when go to payment gateway use origin price.

  • Interesting question, even if I think you are doing things from the wrong side. For sure there are hooks on display, so why don't you store your prices in regular dollars and only display them in your strange units? Also, why TUSD and not k$? For units, it is customary and internationally understandable to use k (kilo) for thousand. I see one use for what you are asking: "All prices include 1% discount for cash payment, discount will not be included for other payment methods" thing.
    – Mołot
    Sep 23 '14 at 6:51
  • :) .@Mołot ,tnx, yes you right K$ is better,what is your idea how implement it in display only ? it is not difference for me, I just want create a good module to do this, everything in display be Kilo but when go to payment be original price. Do you have any solution or suggestion?
    – Yuseferi
    Sep 23 '14 at 6:55
  • hook_commerce_price_field_formatter_prepare_view would help?
    – Mołot
    Sep 23 '14 at 6:58
  • your solution is good I did it ,but in this project I need use K$ in every where(specially in data entry) and only in redirecting to bank covert to $.
    – Yuseferi
    Sep 23 '14 at 8:35

Personally I would rather use hook_commerce_price_field_formatter_prepare_view.

This hook is used by modules like the Product Pricing module that implement ways to alter prices prior to display.

That way you could keep your prices as regular dollars internally, and only display them as kilodollars for your customers. Regular storage will make it easier to interact with gateways.

Other way, although I'm not sure about it's specific implementation, would be to define second currency. You can have a shop that sells in Euro and USD, and internally re-calculates prices to meet client's payment method, right? Maybe you could define kilodollars just he same way, with exchange ratio 1000:1 to regular dollars?

  • your idea for do it is nice,but are you sure "hook_commerce_price_field_formatter_prepare_view." is hook or [commerce_price_field_formatter_prepare_view]) is just a implement of hook_field_formatter_prepare_view ?
    – Yuseferi
    Sep 23 '14 at 7:18
  • Functions as a secondary hook_field_formatter_prepare_view() - so no, it is not an implementation of, it is a second hook with the same idea, but more specific. Or at least that's how it is defined.
    – Mołot
    Sep 23 '14 at 7:24
  • thanks you right,the link did not open for me first, I try to see it in another browser and see your link, yes, it is hook :)
    – Yuseferi
    Sep 23 '14 at 7:26
  • can you put more details about how can I change it in dipslay with hook_commerce_price_field_formatter_prepare_view ?
    – Yuseferi
    Sep 23 '14 at 8:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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