Commit a9760405 authored by Batyr Mackenov's avatar Batyr Mackenov

#34

parent ad6a27e0
......@@ -38,7 +38,7 @@ if (iaView::REQUEST_HTML == $iaView->getRequestType()) {
$iaCore->factoryModule('notification', IA_CURRENT_MODULE, 'common')
->send('order_placed', (array)$order);
die;
$iaCart->cleanup();
$iaOrder->cleanup();
......
......@@ -13,7 +13,6 @@ class iaNotification extends abstractCore
];
$params = [];
$addressee = [];
$result = true;
$iaMailer = $this->iaCore->factory('mailer');
......@@ -25,23 +24,16 @@ class iaNotification extends abstractCore
switch ($notificationType)
{
case 'order_placed':
$addressee[$data['buyer_email']] = $data['buyer_name'];
$buyer = $this->iaCore->factory('users')->getById($data['member_id']);
$iaMailer->addAddress($data['buyer_email'], $data['buyer_name'],
$buyer ? $buyer['email_language'] : null);
$params['order'] = $data;
$params['products'] = $this->iaCore->factoryModule('order', self::$_moduleName)->getItemsByOrderId($data['id']);
}
if (!$addressee) {
return $result;
}
foreach ($addressee as $emailAddress => $title) {
$iaMailer->addAddress($emailAddress, $title);
}
foreach ($params as $param => $value) {
$iaMailer->setReplacements($param, $value);
}
$iaMailer->setReplacements($params);
$result = $iaMailer->send();
......
......@@ -89,6 +89,17 @@ class iaProduct extends abstractModuleFront
return $rows ? $rows[0] : false;
}
public function getById($id, $decorate = true)
{
if ($row = $this->_get('p.`id` = ' . (int)$id, 0, 1)) {
$row = $row[0];
}
$decorate && $this->_processValues($row, true);
return $row;
}
protected function _get($where = null, $start, $limit, $order = null)
{
$where || $where = iaDb::EMPTY_CONDITION;
......
$(function(){
$('.js-cmd-add-cart').on('click', function(e){
$('body').on('click', '.js-cmd-add-cart', function(e){
intelli.commerce.cart('add', $(this).data('id'), null, null,
function(){
......@@ -16,6 +16,25 @@ $(function(){
)
})
// TODO: wrap it into Commerce object
$('.js-cmd-quick-view').on('click', function(e){
e.preventDefault()
// the better place to activate backdrop animation is here
var url = intelli.config.packages.commerce.url + 'product/' + $(this).data('id') + '.json'
$.ajax({type: 'post', url: url, success: function(response){
var $modal = $(response.html)
$('body').append($modal)
$modal.modal('show')
$modal.on('hidden.bs.modal', function() {
$(this).remove()
})
}})
})
$('#js-sorting-selector').on('change', function(){
intelli.commerce.utils.insertUriParam('sorting', $('option:selected', this).val())
})
......
......@@ -8,6 +8,7 @@
<div class="card__body__snippet">{$item.snippet|truncate:50:'...':true}</div>
<div class="card__body__price">{$item.price|number_format} {$core.config.currency}</div>
<div class="card__body__actions">
<a href="#" class="js-cmd-quick-view" data-id="{$item.id}"><span class="fa fa-search"></span></a>
<button type="button" class="js-cmd-add-cart" data-id="{$item.id}">{lang key='add_to_cart'}</button>
{accountActions item=$item itemtype='products' classname='btn-info pull-left'}
</div>
......
<div class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title">{$item.title|escape}</h4>
</div>
<div class="modal-body">
<div class="clearfix">
<div class="pull-left">
{if $item.pictures}
<div class="well">
{foreach $item.pictures as $picture}
{ia_image file=$item.picture type='thumbnail' width=100}
{/foreach}
</div>
{/if}
<dl>
<dt>{lang key='category'}</dt>
<dd>{$item.category|escape}</dd>
<dt>{lang key='field_products_price'}</dt>
<dd>{$item.price|number_format}</dd>
</dl>
</div>
<div class="pull-right">
<p><button type="button" class="btn btn-sm btn-success js-cmd-add-cart" data-id="{$item.id}"><span class="fa fa-shopping-cart"></span> {lang key='add_to_cart'}</button></p>
<p><button type="button" class="btn btn-sm btn-default" onclick="window.location='{$item.link}'">{lang key='view_details'}</button></p>
</div>
</div>
<p>{$item.description|strip_tags|escape|truncate:100}</p>
</div>
<div class="modal-footer">
<button type="button" onclick="window.location='{$cartUrl}'" class="btn btn-info">{lang key='go_to_cart'}</button>
<button type="button" class="btn btn-default" data-dismiss="modal">{lang key='close'}</button>
</div>
</div>
</div>
</div>
\ No newline at end of file
<?php
//##copyright##
$iaProduct = $iaCore->factoryModule('product', IA_CURRENT_MODULE);
if (iaView::REQUEST_JSON == $iaView->getRequestType()) {
if (1 == count($iaCore->requestPath) && is_numeric($iaCore->requestPath[0])) {
$productId = $iaCore->requestPath[0];
$product = $iaProduct->getById($productId);
if (!$product) {
return iaView::errorPage(iaView::ERROR_NOT_FOUND);
}
$iaView->loadSmarty(true);
$iaSmarty = &$iaView->iaSmarty;
$iaPage = $iaCore->factory('page', iaCore::FRONT);
$iaSmarty->assign('item', $product);
$iaSmarty->assign('cartUrl', $iaPage->getUrlByName('cart'));
$iaSmarty->assign('checkoutUrl', $iaPage->getUrlByName('checkout'));
$output['html'] = $iaSmarty->fetch('extra:commerce/widget.popup');
$iaView->assign($output);
}
}
if (iaView::REQUEST_HTML == $iaView->getRequestType()) {
$iaProduct = $iaCore->factoryModule('product', IA_CURRENT_MODULE);
$iaCategory = $iaCore->factoryModule('category', IA_CURRENT_MODULE);
$categorySlug = $iaCore->requestPath;
......
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