i haven’t been able to find anything like this here, perhaps i didn’t search correctly, but i have gone through a fair amount of the posts before asking this
i have some prices on a few pages in my site, that are in a single currency right now as they are just static bits of text in various pages
is it possible, that if a user clicks on one of a number of "currency choice" links, i can have those bits of text switch to showing the value in the selected currency?
my initial thinking is to have a TV for each price listed on the page, in each currency, then if the user clicks on the link, the document loads using the tv(s) for that currency, (not sure if this is the right way to go about it)
i’m also not sure how to make that choice persist for the user’s entire session?
let’s say you have a price-TV for each product in your default-currency and you would list them with ditto.
One of 100 ways could be to create a phx-modifier ’conv_cur’ to convert from default-currency to custom-currency by actual values.
then you can convert your price in your ditto-chunk with [+price:conv_cur+]
you can of course store the customer-choice in a $_SESSION-var.
if you have fixed prices for different currencies you can store them in different price-tvs and let a new snippet ’myprice’ choose the right TV.
then you call your snippet with [[myprice? &id=`[+id+]`]]
what an amazing community, thanks for the fast response!
i like the 2nd option you presented, as my prices aren’t necessarily actual "conversions"
i’m a bit new to the whole create snippet thing, you wouldn’t happen to know of any that use sessions that i could base my snippet off of?
this is not tested, but its the idea:
<?php
//USD,EUR,CNY ISO 4217 Currency Code List see http://www.xe.com/iso4217.php
//price-tvs: priceEUR, priceUSD, priceCNY
//link-examples:<ul><li><a href="[~[*id*]~]¤cy=EUR">Euro</a></li><li><a href="[~[*id*]~]¤cy=USD">US-Dollar</a></li></ul>
//[!myprice? &id=`[+id+]`!]
//[!myprice? &id=`[+id+]`&defaultCur=`USD`!]
if ( isset ($_GET['currency']))
{
$_SESSION['currency'] = $_GET['currency'];
}
$defaultCur = isset ($defaultCur)?$defaultCur:'EUR';
$currency = isset ($_SESSION['currency'])?$_SESSION['currency']:$defaultCur;
$priceTv = 'price'.$currency;
$tvs = $modx->getTemplateVarOutput($priceTv, $id);
return $tvs[$priceTv].' '.$currency;
?>
wow,
i’ll give that a whirl, cheers mate!
ok well that’s working...
i have a bunch of tvs like this:
value1EUR value1USD, value2EUR, value2USD etc...
and then call them with &tv=`value1` etc...
thanks again for the help...