Customer Accounts dependent formatting

Automatic multi currency display on entire catalog.

Run your catalog in a main currency (or a main and alternate) with the customer having the option to turn on an additional currency throughout the Catalog, Cart and Checkout.
Post Reply
jont
Posts: 12
Joined: Sun Sep 07, 2008 10:18 am

Customer Accounts dependent formatting

Post by jont »

We have 2 customer groups on a trade site - UK and Europe - which requires log-in to access the price.

Depending on which group you are assigned to is it possible using this plug-in to show only their currency IE: if UK only show Sterling and if European only show Euro price

SellerDeck v11
norman
Site Admin
Posts: 1252
Joined: Sat Feb 07, 2004 9:55 pm

Re: Customer Accounts dependent formatting

Post by norman »

NorPrice may not be the best way of doing this. NorPrice doesn't have any alternative price available until someone chooses to select it. Plus it's designed to display the base currency and the additional one alongside it (once selected). Although it probably could be tweaked to do what you want (or close to it), significant custom work would be needed.

Since SD has a fixed second currency like the Euro built-in it may be possible to use that and some BlockIf's to display one or the other.
Norman
jont
Posts: 12
Joined: Sun Sep 07, 2008 10:18 am

Re: Customer Accounts dependent formatting

Post by jont »

Thanks Norman.

I have played around with the Actinic:ShowPriceSchedule but splitting the £/E display accordingly is proving troublesome. Will keep on playing.
norman
Site Admin
Posts: 1252
Joined: Sat Feb 07, 2004 9:55 pm

Re: Customer Accounts dependent formatting

Post by norman »

Here's a jQuery based way.

It assumes you've already got jQuery loaded and are using Euro prices with the format e.g. £1.00 / €1.23.

Add the following to the bottom of layout Standard JavaScript Header Functions:

Code: Select all

<script type="text/javascript">var showaltprice = false;</script>
<Actinic:SHOWFORPRICESCHEDULE Schedules="2" HTML="<script>showaltprice = true;</script>"/>   
<script type="text/javascript">
   var patterntoremove = showaltprice ? /£[\d\.,]+( \/ |&nbsp;\/&nbsp;)/g : /( \/ |&nbsp;\/&nbsp;)€[\d\.,]+/g;
   $(document).ready(function(){
      $('.product-price, .cart, .cartheading, .checkout-cartheading').each(function(){
            $(this).html($(this).html().replace(patterntoremove, ''));
         });
      });
</script>
The code above looks for all stuff with classes product-price, cart, cartheading, checkout-cartheading.
It then removes either all £n,nnn.nn / or \ €n,nnn.nn depending on whether whether Schedule Price 2 is set or not.

You can add other classes to the list but test carefully. Don't use sweeping classes that contain lots of HTML. Try to keep the code within such classes concise.

The Cart Summary code needs tweaked too.
Replace the contents of layout Regular Shopping Cart Summary with:

Code: Select all

		<div class="cart-summary">
			<!-- shopping cart summary -->
			<div>
				<script language="javascript" type="text/javascript">
				<!--
				var summarypatterntoremove = showaltprice ? /&#163;(&#46;|&#44;|\d)+&#32;&#47;&#32;/ : /&#32;&#47;&#32;&#128;(&#46;|&#44;|\d)+/;
				if (getCartItem(3) == 0) {
					document.write('No Items');
					}
				if (getCartItem(3) == 1) {
					document.write(getCartItem(3) + 'Item&nbsp;|&nbsp;' + getCartItem(1).replace(summarypatterntoremove, ''));
					}
				if (getCartItem(3) > 1) {
					document.write(getCartItem(3) + 'Items&nbsp;|&nbsp;' + getCartItem(1).replace(summarypatterntoremove, ''));
					}
				// -->
				</script>
			</div>
			<a href="<actinic:variable name="CartLinkText" />" onclick="AppendParentSection(this)"><actinic:variable name="CartText" /></a>&nbsp;|&nbsp;
			<a href="<actinic:variable name="OrderLinkText" />" onclick="AppendParentSection(this)"><actinic:variable name="CheckOutText" /></a>
		</div>
If you're using SD2013 and use Dynamic Prices, then you can fix these too.
Edit file dynamic.js (in your Site folder) and look for the line:

Code: Select all

	return Sprintf(g_oConfig.sPriceFmt, arrPrices[0], arrPrices[1]);
Replace it with:

Code: Select all

	return (showaltprice ? arrPrices[1] : arrPrices[0]);
Norman
norman
Site Admin
Posts: 1252
Joined: Sat Feb 07, 2004 9:55 pm

Re: Customer Accounts dependent formatting

Post by norman »

And here's a CSS way (no jQuery needed):
Replace layout Product Price Including Tax with:

Code: Select all

<span class="maincurr"><actinic:variable name="TaxInclusivePrice" selectable="false" /> <span class="altcurr"><actinic:variable name="TaxInclusivePriceAlt" selectable="false" /></span>
If using Tax Exclusive Prices, then replace layout Product Price Excluding Tax with:

Code: Select all

<span class="maincurr"><actinic:variable name="TaxExclusivePrice" selectable="false" /> <span class="altcurr"><actinic:variable name="TaxExclusivePriceAlt" selectable="false" /></span>
Add the following to the bottom of layout Standard JavaScript Header Functions:

Code: Select all

<style>.altcurr {display: none;}</style>
<Actinic:SHOWFORPRICESCHEDULE Schedules="2" HTML="<style>.maincurr {display: none;} .altcurr {display:block;}</style>" />	
The above hides code with class altcurr unless Schedule Price 2 is set. In which case it hides class maincurr instead.

Note that I've only tested this with normal customers as I don't have a B2B type site handy.
Norman
norman
Site Admin
Posts: 1252
Joined: Sat Feb 07, 2004 9:55 pm

Re: Customer Accounts dependent formatting

Post by norman »

UPDATE: Created a customer account and found that while the CSS route above does get rid of the Euro price on normal pages, it doesn't fix the logged-in ones. That looks much more complicated.
Norman
norman
Site Admin
Posts: 1252
Joined: Sat Feb 07, 2004 9:55 pm

Re: Customer Accounts dependent formatting

Post by norman »

I've re-done my Here's a jQuery based way... above. It now needs no Layout tweaks, just a bit of JavaScript.

Seems to work everywhere but the Cart Summary.

Use with caution.
Norman
Post Reply