Commit fb27cb41 authored by Batyr Mackenov's avatar Batyr Mackenov

Remove products from cart

parent d41f936c
......@@ -385,7 +385,6 @@ CREATE TABLE `{prefix}orders_items` (
<code>
<![CDATA[
$iaCore->factoryModule('category', 'commerce', iaCore::ADMIN)->setupDbStructure();
$iaCore->factoryModule('currency', 'commerce')->refreshRates();
]]>
</code>
</install>
......@@ -393,8 +392,8 @@ $iaCore->factoryModule('currency', 'commerce')->refreshRates();
<uninstall>
<sql>
<![CDATA[
DROP TABLE IF EXISTS `{prefix}products`, `{prefix}categories`, `{prefix}categories_flat`,
`{prefix}cart`, `{prefix}cart_items`, `{prefix}orders`, `{prefix}orders_items`;
DROP TABLE IF EXISTS `{prefix}products`, `{prefix}categories`, `{prefix}categories_flat`,
`{prefix}cart`, `{prefix}cart_items`, `{prefix}orders`, `{prefix}orders_items`;
]]>
</sql>
</uninstall>
......
$(function(){
$('body').on('click', '.js-cmd-add-cart', function(e){
intelli.commerce.cart('add', $(this).data('id'), null, null,
e.preventDefault();
intelli.commerce.cart('add', $(this).data('id'), null,
function(){
},
......
$(function() {
$('.plus, .minus').on('click', function(){
var $input = $(this).closest('.quantity').find('.qty'),
value = parseFloat($input.val()),
max = parseFloat($input.data('max')),
min = parseFloat($input.data('min')),
step = $input.attr('step')
$('.spin-up, .spin-down').on('click', function() {
$('#js-cmd-update-cart').removeClass('disabled').prop('disabled', '');
});
value && '' !== value && 'NaN' !== value || (value = 0), ('' === max || 'NaN' === max) && (max = ''), ('' === min || 'NaN' === min) && (min = 0), ('any' === step || '' === step || void 0 === step || 'NaN' === parseFloat(step)) && (step = 1),
$(this).is('.plus') ? $input.val(max && (max == value || value > max) ? max : value + parseFloat(step)) : min && (min == value || min > value) ? $input.val(min) : value > 0 && $input.val(value - parseFloat(step))
$('input[name="quantity"]').on('keyup', function() {
$('#js-cmd-update-cart').removeClass('disabled').prop('disabled', '');
});
$('.js-quantity-input').trigger('change')
})
$('.js-cmd-remove-item').on('click', function(e) {
e.preventDefault()
$('.js-quantity-input').on('change', function(){
$('#js-cmd-update-cart').removeClass('disabled').prop('disabled', false)
})
})
\ No newline at end of file
var $e = $(this)
intelli.commerce.cart('delete', $e.data('id'), {item_id: $e.data('item_id')}, null, function(response){
if (response.result){
if (!response.count) {
window.location.reload();
return;
}
$('.js-cart-placeholder-count').html(response.count)
$('.js-cart-placeholder-total').html(response.total)
$('#js-cart-contents').html(response.html)
} else {
intelli.notifFloatBox({msg: response.message, type: 'error'})
}
$e.closest('.js-product-entry').slideUp('slow', function(){$(this).remove()})
});
});
});
\ No newline at end of file
(function(o){
'use strict'
var events = ['add', 'delete']
var baseUrl = intelli.config.packages.commerce.url
var Commerce = function(){}
Commerce.prototype = {
cart: function(event, id, item_id, e, fn1, fn2){
if (-1 === events.indexOf(event)){
return false
}
if ('function' === typeof fn1){
fn1()
}
var data = $.extend({}, e, {product: id})
var url = baseUrl + 'cart/' + event + '.json'
$.ajax({type: 'post', url: url, data: data, success: function(response){
if ('function' === typeof fn2){
fn2(response)
}
}})
},
utils: {
insertUriParam: function(key, value){
key = encodeURIComponent(key)
value = encodeURIComponent(value)
var kvp = document.location.search.substr(1).split('&')
if (!kvp){
document.location.search = '?' + key + '=' + value
}
else{
var i = kvp.length; var x
while (i--){
x = kvp[i].split('=')
if (x[0] == key){
x[1] = value
kvp[i] = x.join('=')
break
}
}
if (i < 0) {kvp[kvp.length] = [key, value].join('=')}
document.location.search = kvp.join('&')
}
}
}
}
o.commerce = new Commerce()
'use strict'
var events = ['add', 'delete']
var baseUrl = intelli.config.packages.commerce.url
var Commerce = function(){}
Commerce.prototype = {
cart: function(event, id, e, fn1, fn2){
if (-1 === events.indexOf(event)){
return false
}
if ('function' === typeof fn1){
fn1()
}
var data = $.extend({}, e, {product: id})
var url = baseUrl + 'cart/' + event + '.json'
$.ajax({type: 'post', url: url, data: data, success: function(response){
if ('function' === typeof fn2){
fn2(response)
}
}})
},
utils: {
insertUriParam: function(key, value){
key = encodeURIComponent(key)
value = encodeURIComponent(value)
var kvp = document.location.search.substr(1).split('&')
if (!kvp){
document.location.search = '?' + key + '=' + value
}
else{
var i = kvp.length; var x
while (i--){
x = kvp[i].split('=')
if (x[0] == key){
x[1] = value
kvp[i] = x.join('=')
break
}
}
if (i < 0) {kvp[kvp.length] = [key, value].join('=')}
document.location.search = kvp.join('&')
}
}
}
}
o.commerce = new Commerce()
}(intelli))
\ No newline at end of file
......@@ -35,17 +35,7 @@
{lang key='go_to_checkout'}
</a>
</p>
{ia_add_js}
$(function() {
$('.spin-up, .spin-down').on('click', function() {
$('#js-cmd-update-cart').removeClass('disabled').prop('disabled', '');
});
$('input[name="quantity"]').on('keyup', function() {
$('#js-cmd-update-cart').removeClass('disabled').prop('disabled', '');
})
});
{/ia_add_js}
{ia_print_js files='_IA_URL_modules/commerce/js/cart'}
{else}
<div class="alert alert-info">{lang key='cart_is_empty'}</div>
{/if}
\ No newline at end of file
<tr class='js-product-entry'>
<tr class="js-product-entry">
<td>
{ia_image file=$item.pictures[0] type='thumbnail' title=$item.title width=100 height=auto}
</td>
<td>{ia_url item=$commerce.itemName type='link' data=$item text=$item.title}</td>
<td>{$item.price|number_format} {$core.config.currency}</td>
<td>{$item.price_formatted}</td>
<td>
<div class="input-append spinner" data-trigger="spinner">
<input type="hidden" name="q[{$item.item_id}]" value="{$item.qty}">
......@@ -15,7 +15,7 @@
</div>
</td>
<td class="text-right">
<strong>{($item.price*$item.qty)|number_format} {$core.config.currency}</strong>
<strong>{($item.price*$item.qty)|number_format}</strong>
</td>
<td class="text-center delete-item"><span class="js-cmd-remove-item" data-id="{$item.id}" data-item_id="{$item.item_id}"><i class='fa fa-remove'></i></span></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
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