Jump to content

Waluta dla kraju - domyślnie


tskalar

Recommended Posts

Nieprzetestowane ale powinno działać. Tylko dla 2 języków

 

Tools.php

    public static function setCurrency($cookie, $id_lang = null, Context $context = null)
    {
        if (Tools::isSubmit('SubmitCurrency'))
            if (isset($_POST['id_currency']) && is_numeric($_POST['id_currency']))
            {
                $currency = Currency::getCurrencyInstance($_POST['id_currency']);
                if (is_object($currency) && $currency->id && !$currency->deleted && $currency->isAssociatedToShop())
                    $cookie->id_currency = (int)$currency->id;
            }
            
          if (!$context)
            $context = Context::getContext();
          if (!$id_lang)
            $id_lang = $context->language->id;

		$currency = null;
        
        /*(int)$cookie->id_currency*/
        
        if($id_lang == 1 && (int)$cookie->id_currency)
			$currency = Currency::getCurrencyInstance(1);
        
        if ($id_lang == 2 && (int)$cookie->id_currency)
            $currency = Currency::getCurrencyInstance(2);
        
        
		if (!Validate::isLoadedObject($currency) || (bool)$currency->deleted || !(bool)$currency->active)
			$currency = Currency::getCurrencyInstance(Configuration::get('PS_CURRENCY_DEFAULT'));

		$cookie->id_currency = (int)$currency->id;
		if ($currency->isAssociatedToShop())
			return $currency;
		else
		{
			// get currency from context
			$currency = Shop::getEntityIds('currency', Context::getContext()->shop->id, true, true);
			if (isset($currency[0]) && $currency[0]['id_currency'])
			{
				$cookie->id_currency = $currency[0]['id_currency'];
				return Currency::getCurrencyInstance((int)$cookie->id_currency);
			}
		}
			
		return $currency;
	}
Link to comment
Share on other sites

  • 1 year later...

Witam,

 

Ja trochę z innym problemem, wystawiam produkty w złotówkach ale ich cena uzależniona jest od kursu euro w danym dniu. Czy jest jakiś moduł lub inna kombinacja "zasysająca" z zewnątrz aktualny kurs waluty (w tym przypadku euro) i przeliczająca na złotówki?

 

Z góry dziękuję za pomoc.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...