Схема
public void
set (
string $currency )
Аргументы
Аргумент |
Возможный тип |
Описание |
$currency |
string |
— |
Описание
Устанавливает для текущего пользователя валюту на сайте. В качестве параметра $currency
выступает ISO код нужной валюты (например: USD, UAH)
Пример использования:
// пример вызова метода в контроллере catalog/controller/module/currency.php
if (isset($this->request->post['currency_code'])) {
$this->currency->set($this->request->post['currency_code']);
unset($this->session->data['shipping_method']);
unset($this->session->data['shipping_methods']);
if (isset($this->request->post['redirect'])) {
$this->redirect($this->request->post['redirect']);
} else {
$this->redirect($this->url->link('common/home'));
}
}
Исходный код
$this->code = $currency;
if (!isset($this->session->data['currency']) || ($this->session->data['currency'] != $currency)) {
$this->session->data['currency'] = $currency;
}
if (!isset($this->request->cookie['currency']) || ($this->request->cookie['currency'] != $currency)) {
setcookie('currency', $currency, time() + 60 * 60 * 24 * 30, '/', $this->request->server['HTTP_HOST']);
}