Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

E-Commerce Modules /

Discuss about the various e-commerce modules available:
Ecommerce, SS Shop, SilverCart and SwipeStripe
Alternatively, have a look the shared mailinglist.

Moderators: martimiz, Nicolaas, Sean, Ed, frankmullenger, biapar, Willr, Ingo, Jedateach, swaiba

Amount $ GBP


Go to End


3 Posts   3719 Views

Avatar
jmdweb

Community Member, 14 Posts

24 January 2009 at 7:35am

I would just like to document this, as I couldn't find any answer on the forum archive or else where.

On the Checkout page, I noticed at the bottom,

Amount
$ 15.00 GBP

As you can see it's not correct, so I tried to resolve the issue and found an easy way to temporary sort the problem.

in ecommerce/code/OrderForm.php
On (apprx) LINE 19

$total = '$' . number_format($sc->Total(), 2);

Just delete the $

I tried to use actually ampersand for £ or £ etc but didn't convert.

Hope this helps anyone.

Avatar
roterl

Community Member, 44 Posts

27 January 2009 at 2:23pm

Edited: 27/01/2009 2:27pm

There are some bugs with the currency and the ecommerce mosule. Sometimes it display the currency as defined in the Order class, sometimes it use the one from the Currency class and sometimes it display them both.

To fix this, do the following:
1. on mysite/_config.php add the following:

Currency::setCurrencySymbol('$'); //change this to the relevant symbol
Order::set_site_currency('USD'); //change this to the relevant currency code

2. on ecommerce/code/forms/OrderForm.php fix the line from

$total = '$' . number_format($currentOrder->Total(), 2);

into
$total = new Currency('MyField');
$total->setValue($currentOrder->Total());
$paymentFields = Payment::combined_form_fields($total->Nice()  ." ", $currentOrder->Total());

(this is line #70 on ecommerce trunk-r70743)

3. on ecommerce/templates/Includes/OrderInformation_Editable.ss fix the line from

<td class="right" id="$TableTotalID">$Total.Nice $Currency</td>

into
<td class="right" id="$TableTotalID">$Total.Nice</td>

(this is line #89 on ecommerce trunk-r70743)

<td id="$TableTotalID" class="price">$Total.Nice $Currency</td>

into
<td id="$TableTotalID" class="price">$Total.Nice</td>

(this is line #51 on ecommerce trunk-r70743)

4. on ecommerce/templates/Includes/Order_Content.ss fix the line from

<td class="price">$TotalOutstanding.Nice $Currency</td>

into
<td class="price">$TotalOutstanding.Nice</td>

(this is line #59 on ecommerce trunk-r70743)

4. on ecommerce/templates/Includes/ProductGroupItem.ss fix the line from

<% if Price %><span class="price_display">$Price.Nice $Currency $TaxInfo.PriceSuffix</span><% end_if %>

into
<% if Price %><span class="price_display">$Price.Nice $TaxInfo.PriceSuffix</span><% end_if %>

(this is line #12 on ecommerce trunk-r70743)

5. on ecommerce/templates/Includes/Cart.ss fix the line from

<li class="total"><% _t("TOTAL","Total") %>: <strong id="$CartTotalID">$Total.Nice $Currency</strong></li>

into
<li class="total"><% _t("TOTAL","Total") %>: <strong id="$CartTotalID">$Total.Nice</strong></li>

(this is line #76 on ecommerce trunk-r70743)

6. on ecommerce/templates/Layout/Product.ss fix the line from

<% if Price %><p class="price_display">$Price.Nice $Currency $TaxInfo.PriceSuffix</p><% end_if %>

into
<% if Price %><p class="price_display">$Price.Nice $TaxInfo.PriceSuffix</p><% end_if %>

(this is line #59 on ecommerce trunk-r70743)

6. on ecommerce/templates/Layout/AccountPage_order.ss fix the line from

<td scope="col">$Amount.Nice $Currency</td>

into
<td scope="col">$Amount.Nice</td>

(this is line #89 on ecommerce trunk-r70743)

I hope I didn't miss anything...

Rotem.

Avatar
Kalileo

Community Member, 127 Posts

13 April 2009 at 5:57pm

Edited: 13/04/2009 6:00pm

Running into this same issue, I added this quick fix, which seems to work for me. It is based on both your ideas, jmdweb and roterl.

Having had to touch multicurrency situations before, I think the order currency is something which should be defined with the order. Thus the first step is to add this information.
ecommerce/code/Order.php has already a field for the "site_currency" (which roterl sets in mysite/_config.php). Let's extend that and add a field for the site_currency_symbol.

In ecommerce/code/Order.php right at the definition of site_currency, around line 102, change this:

	/**
	 * Currency used in orders
	 */
	protected static $site_currency = "USD";
	
	static function set_site_currency($currency) {
		self::$site_currency = $currency;
	}
	static function site_currency() {
		return self::$site_currency;
	}

into this
	/**
	 * Currency used in orders
	 */
	protected static $site_currency = "USD";
	
	static function set_site_currency($currency) {
		self::$site_currency = $currency;
	}
	static function site_currency() {
		return self::$site_currency;
	}
	/* added by Kalileo 2009-04-12 - START */
	protected static $site_currency_symbol = "$";
	static function set_site_currency_symbol($currency_symbol) {
		self::$site_currency_symbol = $currency_symbol;
	}
	static function site_currency_symbol() {
		return self::$site_currency_symbol;
	}
	/* added by Kalileo - END */

Next, set this in mysite/_config.php as needed. Add a line to the code proposed by roterl, as shown below:

Currency::setCurrencySymbol('฿');      //change this to the relevant symbol
Order::set_site_currency('THB');         //change this to the relevant currency code
Order::set_site_currency_symbol('฿'); //change this to the relevant symbol

The Currency::setCurrencySymbol is there because it is needed with the ecommerce code now. However I use the Order::site_currency_symbol for the remaining changes, as it seems to be more logical to me.

Last change, which fixes the problem as originally described by jmdweb. For me it does also display the correct currency symbol (jmdweb, I dunno why it did not work for you with £ instead of $ there, here it works fine if I replace $ by ฿ or any other symbol):

In ecommerce/code/OrderForm.php around line 19 change

		$total = '$' . number_format($sc->Total(), 2);

into

		$total = $sc->site_currency_symbol() . ' ' . number_format($sc->Total(), 2);

$sc was set right above there as $sc = Order::ShoppingCart(); which is why site_currency_symbol, with the value which we had set in mysite/_config.php, is available there.

I'm not through yet with the project, so more might be needed later, but so far the checkout form displays now the correct currency code and currency symbol for me.

Kalileo