1

I'm trying to extract the currency code for the current order, I printed the $order variable using print_r, but I'm not at all a PHP programmer and I don't really know how to extract the currency code, I can see it there, but I don't know how to extract it, can somebody point me to the right direction? I will be delighted if I will learn how to do this kind of actions.

Thanks for your time!

5

The currency data lives in the commerce_order_total field by default. You can extract that information easily using field_get_items(), though an entity_metadata_wrapper() is just more fun:

$order = commerce_order_load($order_id);
$order_wrapper = entity_metadata_wrapper('commerce_order', $order);

$currency_code = $order_wrapper->commerce_order_total->currency_code->value();
| improve this answer | |

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.