Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,399
    Plugin Contributions
    87

    Default Admin: Incorrect order totals display for non-default currency order

    Running an unmodified Zen Cart v1.5.1 installation with the demo products installed. If an order is placed in a currency other than the default (USD), when that order's details are displayed using the admin's Customers->Orders, the order-total values are always displayed using the default currency.
    Name:  muli_currency_issue_admin_orders.jpg
Views: 356
Size:  4.9 KB
    (My apologies for the teeny screenshot, but I don't know how to get the image uploader to stop shrinking it)

    To reproduce the issue:
    1. Change the currency to EUR
    2. Add an item to your cart; I chose 'Test Seven' (products_id=120)
    3. Checkout via the Check/Money Order payment method
    4. Go to the admin and view the order's details. While the product prices are shown in EUR, the order total values are shown in USD (the default currency).

    The issue lies in /YOUR_ADMIN/orders.php, lines 596-603:
    Code:
    <?php
        for ($i = 0, $n = sizeof($order->totals); $i < $n; $i++) {
          echo '              <tr>' . "\n" .
               '                <td align="right" class="'. str_replace('_', '-', $order->totals[$i]['class']) . '-Text">' . $order->totals[$i]['title'] . '</td>' . "\n" .
               '                <td align="right" class="'. str_replace('_', '-', $order->totals[$i]['class']) . '-Amount">' . $currencies->format($order->totals[$i]['value'], false) . '</td>' . "\n" .
               '              </tr>' . "\n";
        }
    ?>
    ... as the default currency is being used to format the total value. To correct the issue, make the highlighted change:
    Code:
    <?php
        for ($i = 0, $n = sizeof($order->totals); $i < $n; $i++) {
          echo '              <tr>' . "\n" .
               '                <td align="right" class="'. str_replace('_', '-', $order->totals[$i]['class']) . '-Text">' . $order->totals[$i]['title'] . '</td>' . "\n" .
               '                <td align="right" class="'. str_replace('_', '-', $order->totals[$i]['class']) . '-Amount">' . /*-bof-c-lat9 $currencies->format($order->totals[$i]['value'], false)*/ $order->totals[$i]['text'] /*-eof-c-lat9*/ . '</td>' . "\n" .
               '              </tr>' . "\n";
        }
    ?>

  2. #2
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Admin: Incorrect order totals display for non-default currency order

    This is possibly a better fix ...

    I have both values displaying in this example, for testing purposes, the calculated amount vs the text amount ... the calculated amount is using the exchange rate stored in the orders table:
    Code:
    <?php
        for ($i = 0, $n = sizeof($order->totals); $i < $n; $i++) {
          echo '              <tr>' . "\n" .
               '                <td align="right" class="'. str_replace('_', '-', $order->totals[$i]['class']) . '-Text">' . $order->totals[$i]['title'] . '</td>' . "\n" .
               '                <td align="right" class="'. str_replace('_', '-', $order->totals[$i]['class']) . '-Amount">' . $currencies->format($order->totals[$i]['value'], true, $order->info['currency'], $order->info['currency_value']) . ' vs ' . $order->totals[$i]['text'] . '</td>' . "\n" .
               '              </tr>' . "\n";
        }
    ?>
    While either can work, do you have an opinion on which is the better one?

    I lean towards the calculated one, as it keeps in line with the other code in the orders.php class ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  3. #3
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,399
    Plugin Contributions
    87

    Default Re: Admin: Incorrect order totals display for non-default currency order

    Ajeh, I'd lean towards the 'text' value for the following reasons:
    1. The 'text' rather than the calculated value is what is shown to the customer on the account_history_info page (consistency in display).
    2. If, for some unseen reason, a shop owner decides that they are no longer going to use a currency (like when the Euro came into being and many of the extant European currencies became obsolete) and they remove that currency, then the calculated method will fail because the currency no longer exists in the store's database.

  4. #4
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Admin: Incorrect order totals display for non-default currency order

    There is the rub ...

    If you delete the currency in the admin, because you no longer use it, you loose the layout of the currency and that breaks many other things for both the Store and the Admin as now the Product details cannot be displayed correctly ...

    The better option is to customize the currency sidebox to skip the currency to be removed from the store, but leave it in the Currency definitions in the Admin so that everything can still look correct for both Store and Admin on Customer History and existing Orders from the past, before the Currency was determined not to be used any longer ... even when the value for the currency is set to 0, it still functions correctly as the exchange rate is in the orders table ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  5. #5
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,399
    Plugin Contributions
    87

    Default Re: Admin: Incorrect order totals display for non-default currency order

    Ajeh, sounds like you've (as always) thought this out. I defer to your judgement.

  6. #6
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Admin: Incorrect order totals display for non-default currency order

    Thought it out then tested it out, as you did have sound reasoning ... but I found way too much broken to just delete a currency rather than exclude it on the currency choices on the Store ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

 

 

Similar Threads

  1. v154 Display by default non-default currency
    By sapir39 in forum General Questions
    Replies: 5
    Last Post: 20 May 2015, 07:22 AM
  2. Replies: 0
    Last Post: 10 Jun 2013, 05:24 PM
  3. Replies: 1
    Last Post: 5 Sep 2012, 11:57 AM
  4. I changed My Currency and now order totals are zero
    By solotripper in forum Built-in Shipping and Payment Modules
    Replies: 4
    Last Post: 19 Nov 2010, 04:48 AM
  5. Display non default Currency on Front
    By wayunee in forum Currencies & Sales Taxes, VAT, GST, etc.
    Replies: 0
    Last Post: 25 Oct 2010, 08:46 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR