4
Answers
Vote up!
0
Vote down!

Add a second Price/m2 working with multicurrency

I need to display for my products(tiles) 2 prices.
One is the price for the complete box(the one which is used in the cart)
And the second one is just a display, which outputs price per m2 according to my field "surface per box" ex: 1.52m2 / box.

I have used the module computed field to compute my second price :

<?php
$surface
= $entity->field_surface_in_one_box['und'][0]['value'];
$price = $entity->commerce_price['und'][0]['amount'];
$entity_field[0]['value'] = $price / 100 / $surface;
?>

and display:

<?php
$display_output
= $entity->commerce_price['und'][0]['currency_code'] . " " . number_format($entity_field_item['value'], 2, '.', '') . "/m2";
?>

It's working great, but now I have to make it work with multicurrency module.

The symbol is switching correctly, but I have no clue howto convert the value itself according to the currency chosen in the block currency.

Asked by: heyyo
on March 20, 2013

4 Answers

Vote up!
3
Vote down!

I finally changed my way of doing it.
I'm not using the computed field module anymore, I have just declared a second price field in my variation type. And I'm calculating its value with a pricing rule.

And I'm using the display settings provided by currency module:
Commerce Multicurrency: Display the price in a specific currency.

Now I have to test the discount part.

Answer by: heyyo
Posted: Mar 20, 2013
Vote up!
0
Vote down!

Yes i'm using it for my regular price, and works pretty well.
But I have no idea to make it work with my second displayed price.

Answer by: heyyo
Posted: Mar 20, 2013
Vote up!
0
Vote down!

I saw in this module that there is a special display for additionnal price which supports multicurrency correctly,
The only problem is my second price field doesn't have a Price type, because it is computed with computed field module.
I'm not an expert on this module, but I don't see any field type: price, only regular stuff: integer, decimal, float, varchar...

Answer by: heyyo
Posted: Mar 20, 2013