I'm looking into the possibility of using Foxycart for a multilingual, multi currency site. Currently it is not possible to have multiple currencies in Foxycart so it would require having separate Foxycart accounts for each currency. I would therefore need to store the cart url and api keys for each Foxycart account within the foxycart plugin.

What would be the best way of going about this? Is it possible to store different plugin setting based on locale?

The other idea I had was to store the api key etc in the config file but not sure if that is best practice or not.


I haven't used foxycart plugin, but looking at the '_settings.html' file, it looks like it stores both the 'storedomain' and 'apikey' as part of the plugin settings. I would suspect that you would need to fork the plugin and modify it.

You could possibly add additional settings to the plugin for the different domains (i.e. storedomain-en, storedomain-es, apikey-en, apikey-es), and then add some logic in the plugins main 'init' method to pick up the different settings based on the current locale.

$settings = craft()->plugins->getPlugin('foxycart')->getSettings();
\FoxyCart_Helper::setCartUrl("https://" . $settings['storedomain-'.craft()->language] . "/cart");

Or, you could set the 'storedomain' and 'apikey' in your multi-environment config array:

return array( 
    '*' => array(
        'storedomain' => array(
            'en' => cart.en.domain.com,
            'es' => cart.es.domain.com',
        'apikey' => array(

and then retrieve them using something like:

$settings = craft()->plugins->getPlugin('foxycart')->getSettings();
$storedomain = craft()->config->get('storedomain');
$apikey = craft()->config->get('apikey');
\FoxyCart_Helper::setCartUrl("https://" . $storedomain[craft()->language] . "/cart");

You would probably also need to go and modify some the variable methods to return the localized versions, so that when you asked for 'storedomain', it returned the correct value. I.e. :

<form action="https://{{ craft.foxyCart.storedomain }}/cart" method="post" accept-charset="utf-8">

I have no idea what other integration points the foxycart plugin has with craft however. If it attempts to sync data in any way with foxycart, it might not like switching accounts like that.

Overall this sounds pretty messy. I would proceed with caution.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.