Commit 7f7fbc6b authored by Batyr Mackenov's avatar Batyr Mackenov

Multiple currencies support by shopping cart

parent fb27cb41
......@@ -170,6 +170,26 @@ class iaCart extends abstractModuleFront
return $rows;
}
protected function _processValues(&$rows, $singleRow = false, $fieldNames = [])
{
parent::_processValues($rows, $singleRow, $fieldNames);
if ($rows) {
$singleRow && $rows = [$rows];
$iaCurrency = $this->iaCore->factory('currency');
$currency = $iaCurrency->get();
foreach ($rows as &$row) {
$row['price_formatted'] = $iaCurrency->format($row['price']);
$row['currency'] = $currency;
}
$singleRow && $rows = array_shift($rows);
}
}
protected function _summarize($cartId)
{
$items = $this->_getItems($cartId);
......
......@@ -153,7 +153,7 @@ class iaProduct extends abstractModuleFront
if ($rows) {
$singleRow && $rows = [$rows];
$iaCurrency = $this->iaCore->factoryModule('currency', $this->getModuleName());
$iaCurrency = $this->iaCore->factory('currency');
$currency = $iaCurrency->get();
......
......@@ -263,6 +263,11 @@
<hooks>
<hook name="phpCoreUrlRewrite" page_type="front" filename="hook.url-rewrite"><![CDATA[]]></hook>
<hook name="phpCoreBeforePageDisplay" page_type="front" filename="hook.blocks-load"><![CDATA[]]></hook>
<hook name="phpFrontCurrencyChanged" page_type="front">
<![CDATA[
$iaCore->factoryModule('cart', 'commerce')->recount();
]]>
</hook>
<hook name="smartyAdminAfterHeadSection" type="smarty">
<![CDATA[
<style type="text/css">
......
......@@ -20,7 +20,7 @@
{lang key='update_cart'}
</button>
</p>
<p class="lead">{lang key='total'}: <span class="js-cart-placeholder-total">{$total}</span> {$core.config.currency}</p>
<p class="lead">{lang key='total'}: <span class="js-cart-placeholder-total">{$total|currency_format}</span></p>
</td>
</tr>
</table>
......
......@@ -15,7 +15,7 @@
</div>
</td>
<td class="text-right">
<strong>{($item.price*$item.qty)|number_format}</strong>
<strong>{($item.price*$item.qty)|currency_format}</strong>
</td>
<td class="text-center delete-item"><a href="#" class="js-cmd-remove-item" data-id="{$item.id}" data-item_id="{$item.item_id}"><i class="fa fa-remove"></i></a></td>
</tr>
\ No newline at end of file
......@@ -24,7 +24,6 @@
<span itemprop="priceCurrency">{$item.currency}</span>
</p>
</div>
</div>
<div>
<input type="hidden" id="input-id" value="{$item.id}">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment