R
R
Raz1el2015-09-28 13:20:35
PHP
Raz1el, 2015-09-28 13:20:35

Drupal7 + Ubercart3 Several currencies, enter the exchange rate in the admin panel?

Faced a small problem. You need to make several currencies in Ubercart, but do it a little tricky.

  1. The price of the goods is stored either in EUR or in Rub
  2. Most likely you need 2 fields for that and that price in the product card
  3. The price on the site itself is displayed in RUB only
  4. Do not offer commerce, because 3 thousand. I don’t really want to interrupt the goods, but the migration can’t stand everything, it’s all the same to climb there.
  5. I figured out the price display on the site itself by adding this code to the product code:
    function uc_product_load($nodes) {
    include_once("php.php");
    $a = $euro;
    $vids = array();
    foreach ($nodes as $node) {
    $vids[$node->nid] = $node->vid;
    }
    $result = db_query('SELECT nid, model, list_price, cost, sell_price, weight, weight_units, length, width, height, length_units, pkg_qty, default_qty, ordering, shippable FROM {uc_products} WHERE vid IN (:vids)', array(':vids' => $vids));
    foreach ($result as $node) {
    foreach ($node as $field => $value) {
    $nodes[$node->nid]->$field = $value;
    }
    $nodes[$node->nid]->price = round($nodes[$node->nid]->sell_price*$euro, -1);
    }
    }


Help is needed to create a rule (if the price is in rub, we output the node sell_price, -1; if in euro, then sell_price*euro), and output 2 fields in the product card, although I think this is not such a big problem, but php is not really I know.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question