[*] BO : new dimension added to the product filter in the cart rules
This commit is contained in:
@@ -1,28 +1,3 @@
|
|||||||
{*
|
|
||||||
* 2007-2011 PrestaShop
|
|
||||||
*
|
|
||||||
* NOTICE OF LICENSE
|
|
||||||
*
|
|
||||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
|
||||||
* that is bundled with this package in the file LICENSE.txt.
|
|
||||||
* It is also available through the world-wide-web at this URL:
|
|
||||||
* http://opensource.org/licenses/afl-3.0.php
|
|
||||||
* If you did not receive a copy of the license and are unable to
|
|
||||||
* obtain it through the world-wide-web, please send an email
|
|
||||||
* to license@prestashop.com so we can send you a copy immediately.
|
|
||||||
*
|
|
||||||
* DISCLAIMER
|
|
||||||
*
|
|
||||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
|
||||||
* versions in the future. If you wish to customize PrestaShop for your
|
|
||||||
* needs please refer to http://www.prestashop.com for more information.
|
|
||||||
*
|
|
||||||
* @author PrestaShop SA <contact@prestashop.com>
|
|
||||||
* @copyright 2007-2011 PrestaShop SA
|
|
||||||
* @version Release: $Revision: 8971 $
|
|
||||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
|
||||||
* International Registered Trademark & Property of PrestaShop SA
|
|
||||||
*}
|
|
||||||
<label>{l s='Free shipping'}</label>
|
<label>{l s='Free shipping'}</label>
|
||||||
<div class="margin-form">
|
<div class="margin-form">
|
||||||
|
|
||||||
@@ -40,7 +15,7 @@
|
|||||||
<label class="t" for="apply_discount_percent"> <img src="../img/admin/enabled.gif" alt="{l s='Enabled'}" title="{l s='Enabled'}" style="cursor:pointer" /> {l s='Percent (%)'}</label>
|
<label class="t" for="apply_discount_percent"> <img src="../img/admin/enabled.gif" alt="{l s='Enabled'}" title="{l s='Enabled'}" style="cursor:pointer" /> {l s='Percent (%)'}</label>
|
||||||
|
|
||||||
<input type="radio" name="apply_discount" id="apply_discount_amount" value="amount" {if $currentTab->getFieldValue($currentObject, 'reduction_amount')|intval}checked="checked"{/if} />
|
<input type="radio" name="apply_discount" id="apply_discount_amount" value="amount" {if $currentTab->getFieldValue($currentObject, 'reduction_amount')|intval}checked="checked"{/if} />
|
||||||
<label class="t" for="apply_discount_amount"> <img src="../img/admin/enabled.gif" alt="{l s='Enabled'}" title="{l s='Enabled'}" style="cursor:pointer" /> {l s='Amount'}</label>
|
<label class="t" for="apply_discount_amount"> <img src="../img/admin/enabled.gif" alt="{l s='Enabled'}" title="{l s='Enabled'}" style="cursor:pointer" /> {l s='Amount (¤)'}</label>
|
||||||
|
|
||||||
<input type="radio" name="apply_discount" id="apply_discount_off" value="off" {if !$currentTab->getFieldValue($currentObject, 'reduction_amount')|intval && !$currentTab->getFieldValue($currentObject, 'reduction_percent')|intval}checked="checked"{/if} />
|
<input type="radio" name="apply_discount" id="apply_discount_off" value="off" {if !$currentTab->getFieldValue($currentObject, 'reduction_amount')|intval && !$currentTab->getFieldValue($currentObject, 'reduction_percent')|intval}checked="checked"{/if} />
|
||||||
<label class="t" for="apply_discount_off"> <img src="../img/admin/disabled.gif" alt="{l s='Disabled'}" title="{l s='Disabled'}" style="cursor:pointer" /> {l s='None'}</label>
|
<label class="t" for="apply_discount_off"> <img src="../img/admin/disabled.gif" alt="{l s='Disabled'}" title="{l s='Disabled'}" style="cursor:pointer" /> {l s='None'}</label>
|
||||||
@@ -53,7 +28,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="apply_discount_amount_div">
|
<div id="apply_discount_amount_div">
|
||||||
<label>{l s='Value'}</label>
|
<label>{l s='Value (¤)'}</label>
|
||||||
<div class="margin-form">
|
<div class="margin-form">
|
||||||
<input type="text" id="reduction_amount" name="reduction_amount" value="{$currentTab->getFieldValue($currentObject, 'reduction_amount')|floatval}" />
|
<input type="text" id="reduction_amount" name="reduction_amount" value="{$currentTab->getFieldValue($currentObject, 'reduction_amount')|floatval}" />
|
||||||
<select name="reduction_currency">
|
<select name="reduction_currency">
|
||||||
|
|||||||
@@ -1,28 +1,3 @@
|
|||||||
{*
|
|
||||||
* 2007-2011 PrestaShop
|
|
||||||
*
|
|
||||||
* NOTICE OF LICENSE
|
|
||||||
*
|
|
||||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
|
||||||
* that is bundled with this package in the file LICENSE.txt.
|
|
||||||
* It is also available through the world-wide-web at this URL:
|
|
||||||
* http://opensource.org/licenses/afl-3.0.php
|
|
||||||
* If you did not receive a copy of the license and are unable to
|
|
||||||
* obtain it through the world-wide-web, please send an email
|
|
||||||
* to license@prestashop.com so we can send you a copy immediately.
|
|
||||||
*
|
|
||||||
* DISCLAIMER
|
|
||||||
*
|
|
||||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
|
||||||
* versions in the future. If you wish to customize PrestaShop for your
|
|
||||||
* needs please refer to http://www.prestashop.com for more information.
|
|
||||||
*
|
|
||||||
* @author PrestaShop SA <contact@prestashop.com>
|
|
||||||
* @copyright 2007-2011 PrestaShop SA
|
|
||||||
* @version Release: $Revision: 8971 $
|
|
||||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
|
||||||
* International Registered Trademark & Property of PrestaShop SA
|
|
||||||
*}
|
|
||||||
<label>{l s='Limit to a single customer'}</label>
|
<label>{l s='Limit to a single customer'}</label>
|
||||||
<div class="margin-form">
|
<div class="margin-form">
|
||||||
<input type="hidden" id="id_customer" name="id_customer" value="{$currentTab->getFieldValue($currentObject, 'id_customer')|intval}" />
|
<input type="hidden" id="id_customer" name="id_customer" value="{$currentTab->getFieldValue($currentObject, 'id_customer')|intval}" />
|
||||||
@@ -58,10 +33,12 @@
|
|||||||
<label>{l s='Total available'}</label>
|
<label>{l s='Total available'}</label>
|
||||||
<div class="margin-form">
|
<div class="margin-form">
|
||||||
<input type="text" name="quantity" value="{$currentTab->getFieldValue($currentObject, 'quantity')|intval}" />
|
<input type="text" name="quantity" value="{$currentTab->getFieldValue($currentObject, 'quantity')|intval}" />
|
||||||
|
<p>{l s='The cart rule will be applied to the X first customers only.'}</p>
|
||||||
</div>
|
</div>
|
||||||
<label>{l s='Total available for each user'}</label>
|
<label>{l s='Total available for each user'}</label>
|
||||||
<div class="margin-form">
|
<div class="margin-form">
|
||||||
<input type="text" name="quantity_per_user" value="{$currentTab->getFieldValue($currentObject, 'quantity_per_user')|intval}" />
|
<input type="text" name="quantity_per_user" value="{$currentTab->getFieldValue($currentObject, 'quantity_per_user')|intval}" />
|
||||||
|
<p>{l s='A customer will only be able to use the cart rule X time(s).'}</p>
|
||||||
</div>
|
</div>
|
||||||
{if $countries.unselected|@count + $countries.selected|@count > 1}
|
{if $countries.unselected|@count + $countries.selected|@count > 1}
|
||||||
<br />
|
<br />
|
||||||
@@ -192,22 +169,14 @@
|
|||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
<br />
|
<br />
|
||||||
<input type="checkbox" id="product_restriction" name="product_restriction" value="1" {if $product_rules|@count}checked="checked"{/if} /> <strong>{l s='Product selection'}</strong>
|
<input type="checkbox" id="product_restriction" name="product_restriction" value="1" {if $product_rule_groups|@count}checked="checked"{/if} /> <strong>{l s='Product selection'}</strong>
|
||||||
<div id="product_restriction_div" style="border:1px solid #AAAAAA;margin-top:10px;padding:10px 10px 10px 10px;background-color:#FFF5D3">
|
<div id="product_restriction_div">
|
||||||
{l s='Add a filter on'}
|
<table id="product_rule_group_table" style="border:1px solid #AAAAAA;margin:10px 0 10px 0;padding:10px 10px 10px 10px;background-color:#FFF5D3;width:600px" cellpadding="0" cellspacing="0">
|
||||||
<select id="product_rule_type">
|
{foreach from=$product_rule_groups item='product_rule_group'}
|
||||||
<option value="">{l s='-- Choose --'}</option>
|
{$product_rule_group}
|
||||||
<option value="products">{l s='Products'}</option>
|
|
||||||
<option value="attributes">{l s='Attributes'}</option>
|
|
||||||
<option value="categories">{l s='Categories'}</option>
|
|
||||||
</select>
|
|
||||||
<a href="javascript:addProductRule();">
|
|
||||||
<img src="../img/admin/add.gif" alt="{l s='Add'}" title="{l s='Add'}" /> {l s='Add'}
|
|
||||||
</a>
|
|
||||||
<hr />
|
|
||||||
<table id="product_rule_table" class="table" cellpadding="0" cellspacing="0">
|
|
||||||
{foreach from=$product_rules item='product_rule'}
|
|
||||||
{$product_rule}
|
|
||||||
{/foreach}
|
{/foreach}
|
||||||
</table>
|
</table>
|
||||||
|
<a href="javascript:addProductRuleGroup();">
|
||||||
|
<img src="../img/admin/add.gif" alt="{l s='Add'}" title="{l s='Add'}" /> {l s='Add a new rule group'}
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
@@ -0,0 +1,349 @@
|
|||||||
|
/*
|
||||||
|
* 2007-2011 PrestaShop
|
||||||
|
*
|
||||||
|
* NOTICE OF LICENSE
|
||||||
|
*
|
||||||
|
* This source file is subject to the Open Software License (OSL 3.0)
|
||||||
|
* that is bundled with this package in the file LICENSE.txt.
|
||||||
|
* It is also available through the world-wide-web at this URL:
|
||||||
|
* http://opensource.org/licenses/osl-3.0.php
|
||||||
|
* If you did not receive a copy of the license and are unable to
|
||||||
|
* obtain it through the world-wide-web, please send an email
|
||||||
|
* to license@prestashop.com so we can send you a copy immediately.
|
||||||
|
*
|
||||||
|
* DISCLAIMER
|
||||||
|
*
|
||||||
|
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||||
|
* versions in the future. If you wish to customize PrestaShop for your
|
||||||
|
* needs please refer to http://www.prestashop.com for more information.
|
||||||
|
*
|
||||||
|
* @author PrestaShop SA <contact@prestashop.com>
|
||||||
|
* @copyright 2007-2011 PrestaShop SA
|
||||||
|
* @version Release: $Revision: 6844 $
|
||||||
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||||
|
* International Registered Trademark & Property of PrestaShop SA
|
||||||
|
*/
|
||||||
|
|
||||||
|
function addProductRuleGroup()
|
||||||
|
{
|
||||||
|
product_rule_groups_counter += 1;
|
||||||
|
product_rule_counters[product_rule_groups_counter] = 0;
|
||||||
|
$.get(
|
||||||
|
'ajax-tab.php',
|
||||||
|
{controller:'AdminCartRules',token:currentToken,newProductRuleGroup:1,product_rule_group_id:product_rule_groups_counter},
|
||||||
|
function(content) {
|
||||||
|
if (content != "")
|
||||||
|
$('#product_rule_group_table').append(content);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeProductRuleGroup(id)
|
||||||
|
{
|
||||||
|
$('#product_rule_group_' + id + '_tr').remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
function addProductRule(product_rule_group_id)
|
||||||
|
{
|
||||||
|
product_rule_counters[product_rule_group_id] += 1;
|
||||||
|
if ($('#product_rule_type_' + product_rule_group_id).val() != 0)
|
||||||
|
$.get(
|
||||||
|
'ajax-tab.php',
|
||||||
|
{controller:'AdminCartRules',token:currentToken,newProductRule:1,product_rule_type:$('#product_rule_type_' + product_rule_group_id).val(),product_rule_group_id:product_rule_group_id,product_rule_id:product_rule_counters[product_rule_group_id]},
|
||||||
|
function(content) {
|
||||||
|
if (content != "")
|
||||||
|
$('#product_rule_table_' + product_rule_group_id).append(content);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeProductRule(product_rule_group_id, product_rule_id)
|
||||||
|
{
|
||||||
|
$('#product_rule_' + product_rule_group_id + '_' + product_rule_id + '_tr').remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleCartRuleFilter(id)
|
||||||
|
{
|
||||||
|
if ($(id).attr('checked'))
|
||||||
|
$('#' + $(id).attr('id') + '_div').show(400);
|
||||||
|
else
|
||||||
|
$('#' + $(id).attr('id') + '_div').hide(200);
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeCartRuleOption(item)
|
||||||
|
{
|
||||||
|
var id = $(item).attr('id').replace('_remove', '');
|
||||||
|
$('#' + id + '_2 option:selected').remove().appendTo('#' + id + '_1');
|
||||||
|
}
|
||||||
|
|
||||||
|
function addCartRuleOption(item)
|
||||||
|
{
|
||||||
|
var id = $(item).attr('id').replace('_add', '');
|
||||||
|
$('#' + id + '_1 option:selected').remove().appendTo('#' + id + '_2');
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateProductRuleShortDescription(item)
|
||||||
|
{
|
||||||
|
var id1 = $(item).attr('id').replace('_add', '').replace('_remove', '');
|
||||||
|
var id2 = id1.replace('_select', '');
|
||||||
|
var length = $('#' + id1 + '_2 option').length;
|
||||||
|
if (length == 1)
|
||||||
|
$('#' + id2 + '_match').val($('#' + id1 + '_2 option').first().text().trim());
|
||||||
|
else
|
||||||
|
$('#' + id2 + '_match').val(length);
|
||||||
|
}
|
||||||
|
|
||||||
|
var restrictions = new Array('country', 'carrier', 'group', 'cart_rule');
|
||||||
|
for (i in restrictions)
|
||||||
|
{
|
||||||
|
toggleCartRuleFilter($('#' + restrictions[i] + '_restriction'));
|
||||||
|
$('#' + restrictions[i] + '_restriction').click(function() {toggleCartRuleFilter(this);});
|
||||||
|
$('#' + restrictions[i] + '_select_remove').click(function() {removeCartRuleOption(this);});
|
||||||
|
$('#' + restrictions[i] + '_select_add').click(function() {addCartRuleOption(this);});
|
||||||
|
}
|
||||||
|
toggleCartRuleFilter($('#product_restriction'));
|
||||||
|
$('#product_restriction').click(function() {toggleCartRuleFilter(this);});
|
||||||
|
|
||||||
|
function toggleApplyDiscount(percent, amount, apply_to)
|
||||||
|
{
|
||||||
|
if (percent)
|
||||||
|
{
|
||||||
|
$('#apply_discount_percent_div').show(400);
|
||||||
|
if ($('#apply_discount_to_product').attr('checked'))
|
||||||
|
toggleApplyDiscountTo();
|
||||||
|
$('#apply_discount_to_cheapest').removeAttr('disabled');
|
||||||
|
$('#apply_discount_to_cheapest').removeAttr('checked');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$('#apply_discount_percent_div').hide(200);
|
||||||
|
$('#reduction_percent').val('0');
|
||||||
|
$('#apply_discount_to_cheapest').attr('disabled', 'disabled');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (amount)
|
||||||
|
{
|
||||||
|
$('#apply_discount_amount_div').show(400);
|
||||||
|
if ($('#apply_discount_to_product').attr('checked'))
|
||||||
|
toggleApplyDiscountTo();
|
||||||
|
$('#apply_discount_to_cheapest').attr('disabled', 'disabled');
|
||||||
|
$('#apply_discount_to_cheapest').removeAttr('checked');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$('#apply_discount_amount_div').hide(200);
|
||||||
|
$('#reduction_amount').val('0');
|
||||||
|
$('#apply_discount_to_cheapest').removeAttr('disabled');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (apply_to)
|
||||||
|
$('#apply_discount_to_div').show(400);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
toggleApplyDiscountTo();
|
||||||
|
$('#apply_discount_to_div').hide(200);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleApplyDiscountTo()
|
||||||
|
{
|
||||||
|
if ($('#apply_discount_to_product').attr('checked'))
|
||||||
|
$('#apply_discount_to_product_div').show(400);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$('#apply_discount_to_product_div').hide(200);
|
||||||
|
$('#reductionProductFilter').val('');
|
||||||
|
if ($('#apply_discount_to_order').attr('checked'))
|
||||||
|
$('#reduction_product').val('0');
|
||||||
|
if ($('#apply_discount_to_cheapest').attr('checked'))
|
||||||
|
$('#reduction_product').val('-1');
|
||||||
|
if ($('#apply_discount_to_selection').attr('checked'))
|
||||||
|
$('#reduction_product').val('-2');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleGiftProduct()
|
||||||
|
{
|
||||||
|
if ($('#free_gift_on').attr('checked'))
|
||||||
|
$('#free_gift_div').show(400);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$('#gift_product').val('0');
|
||||||
|
$('#giftProductFilter').val('');
|
||||||
|
$('#free_gift_div').hide(200);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#apply_discount_percent').click(function() {toggleApplyDiscount(true, false, true);});
|
||||||
|
if ($('#apply_discount_percent').attr('checked'))
|
||||||
|
toggleApplyDiscount(true, false, true);
|
||||||
|
|
||||||
|
$('#apply_discount_amount').click(function() {toggleApplyDiscount(false, true, true);});
|
||||||
|
if ($('#apply_discount_amount').attr('checked'))
|
||||||
|
toggleApplyDiscount(false, true, true);
|
||||||
|
|
||||||
|
$('#apply_discount_off').click(function() {toggleApplyDiscount(false, false, false);});
|
||||||
|
if ($('#apply_discount_off').attr('checked'))
|
||||||
|
toggleApplyDiscount(false, false, false);
|
||||||
|
|
||||||
|
$('#apply_discount_to_order').click(function() {toggleApplyDiscountTo();});
|
||||||
|
if ($('#apply_discount_to_order').attr('checked'))
|
||||||
|
toggleApplyDiscountTo();
|
||||||
|
|
||||||
|
$('#apply_discount_to_product').click(function() {toggleApplyDiscountTo();});
|
||||||
|
if ($('#apply_discount_to_product').attr('checked'))
|
||||||
|
toggleApplyDiscountTo();
|
||||||
|
|
||||||
|
$('#apply_discount_to_cheapest').click(function() {toggleApplyDiscountTo();});
|
||||||
|
if ($('#apply_discount_to_cheapest').attr('checked'))
|
||||||
|
toggleApplyDiscountTo();
|
||||||
|
|
||||||
|
$('#apply_discount_to_selection').click(function() {toggleApplyDiscountTo();});
|
||||||
|
if ($('#apply_discount_to_selection').attr('checked'))
|
||||||
|
toggleApplyDiscountTo();
|
||||||
|
|
||||||
|
$('#free_gift_on').click(function() {toggleGiftProduct();});
|
||||||
|
$('#free_gift_off').click(function() {toggleGiftProduct();});
|
||||||
|
toggleGiftProduct();
|
||||||
|
|
||||||
|
// Main form submit
|
||||||
|
$('#cart_rule_form').submit(function() {
|
||||||
|
if ($('#customerFilter').val() == '')
|
||||||
|
$('#id_customer').val('0');
|
||||||
|
|
||||||
|
for (i in restrictions)
|
||||||
|
{
|
||||||
|
if ($('#' + restrictions[i] + '_select_1 option').length == 0)
|
||||||
|
$('#' + restrictions[i] + '_restriction').removeAttr('checked');
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$('#' + restrictions[i] + '_select_2 option').each(function(i) {
|
||||||
|
$(this).attr('selected', 'selected');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$('.product_rule_toselect option').each(function(i) {
|
||||||
|
$(this).attr('selected', 'selected');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#giftProductFilter')
|
||||||
|
.autocomplete(
|
||||||
|
'ajax-tab.php', {
|
||||||
|
minChars: 2,
|
||||||
|
max: 50,
|
||||||
|
width: 500,
|
||||||
|
selectFirst: false,
|
||||||
|
scroll: false,
|
||||||
|
dataType: 'json',
|
||||||
|
formatItem: function(data, i, max, value, term) {
|
||||||
|
return value;
|
||||||
|
},
|
||||||
|
parse: function(data) {
|
||||||
|
var mytab = new Array();
|
||||||
|
for (var i = 0; i < data.length; i++)
|
||||||
|
mytab[mytab.length] = { data: data[i], value: (data[i].reference + ' ' + data[i].name).trim() };
|
||||||
|
return mytab;
|
||||||
|
},
|
||||||
|
extraParams: {
|
||||||
|
controller: 'AdminCartRules',
|
||||||
|
token: currentToken,
|
||||||
|
giftProductFilter: 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.result(function(event, data, formatted) {
|
||||||
|
$('#gift_product').val(data.id_product);
|
||||||
|
$('#giftProductFilter').val((data.reference + ' ' + data.name).trim());
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#reductionProductFilter')
|
||||||
|
.autocomplete(
|
||||||
|
'ajax-tab.php', {
|
||||||
|
minChars: 2,
|
||||||
|
max: 50,
|
||||||
|
width: 500,
|
||||||
|
selectFirst: false,
|
||||||
|
scroll: false,
|
||||||
|
dataType: 'json',
|
||||||
|
formatItem: function(data, i, max, value, term) {
|
||||||
|
return value;
|
||||||
|
},
|
||||||
|
parse: function(data) {
|
||||||
|
var mytab = new Array();
|
||||||
|
for (var i = 0; i < data.length; i++)
|
||||||
|
mytab[mytab.length] = { data: data[i], value: (data[i].reference + ' ' + data[i].name).trim() };
|
||||||
|
return mytab;
|
||||||
|
},
|
||||||
|
extraParams: {
|
||||||
|
controller: 'AdminCartRules',
|
||||||
|
token: currentToken,
|
||||||
|
reductionProductFilter: 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.result(function(event, data, formatted) {
|
||||||
|
$('#reduction_product').val(data.id_product);
|
||||||
|
$('#reductionProductFilter').val((data.reference + ' ' + data.name).trim());
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#customerFilter')
|
||||||
|
.autocomplete(
|
||||||
|
'ajax-tab.php', {
|
||||||
|
minChars: 2,
|
||||||
|
max: 50,
|
||||||
|
width: 500,
|
||||||
|
selectFirst: false,
|
||||||
|
scroll: false,
|
||||||
|
dataType: 'json',
|
||||||
|
formatItem: function(data, i, max, value, term) {
|
||||||
|
return value;
|
||||||
|
},
|
||||||
|
parse: function(data) {
|
||||||
|
var mytab = new Array();
|
||||||
|
for (var i = 0; i < data.length; i++)
|
||||||
|
mytab[mytab.length] = { data: data[i], value: data[i].cname + ' (' + data[i].email + ')' };
|
||||||
|
return mytab;
|
||||||
|
},
|
||||||
|
extraParams: {
|
||||||
|
controller: 'AdminCartRules',
|
||||||
|
token: currentToken,
|
||||||
|
customerFilter: 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.result(function(event, data, formatted) {
|
||||||
|
$('#id_customer').val(data.id_customer);
|
||||||
|
$('#customerFilter').val(data.cname + ' (' + data.email + ')');
|
||||||
|
});
|
||||||
|
|
||||||
|
function displayCartRuleTab(tab)
|
||||||
|
{
|
||||||
|
$('.cart_rule_tab').hide();
|
||||||
|
$('.tab-page').removeClass('selected');
|
||||||
|
$('#cart_rule_' + tab).show();
|
||||||
|
$('#cart_rule_link_' + tab).addClass('selected');
|
||||||
|
$('#currentFormTab').val(tab);
|
||||||
|
}
|
||||||
|
|
||||||
|
$('.cart_rule_tab').hide();
|
||||||
|
$('.tab-page').removeClass('selected');
|
||||||
|
$('#cart_rule_' + currentFormTab).show();
|
||||||
|
$('#cart_rule_link_' + currentFormTab).addClass('selected');
|
||||||
|
|
||||||
|
var date = new Date();
|
||||||
|
var hours = date.getHours();
|
||||||
|
if (hours < 10)
|
||||||
|
hours = "0" + hours;
|
||||||
|
var mins = date.getMinutes();
|
||||||
|
if (mins < 10)
|
||||||
|
mins = "0" + mins;
|
||||||
|
var secs = date.getSeconds();
|
||||||
|
if (secs < 10)
|
||||||
|
secs = "0" + secs;
|
||||||
|
$('.datepicker').datepicker({
|
||||||
|
prevText: '',
|
||||||
|
nextText: '',
|
||||||
|
dateFormat: 'yy-mm-dd ' + hours + ':' + mins + ':' + secs
|
||||||
|
});
|
||||||
@@ -1,28 +1,3 @@
|
|||||||
{*
|
|
||||||
* 2007-2011 PrestaShop
|
|
||||||
*
|
|
||||||
* NOTICE OF LICENSE
|
|
||||||
*
|
|
||||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
|
||||||
* that is bundled with this package in the file LICENSE.txt.
|
|
||||||
* It is also available through the world-wide-web at this URL:
|
|
||||||
* http://opensource.org/licenses/afl-3.0.php
|
|
||||||
* If you did not receive a copy of the license and are unable to
|
|
||||||
* obtain it through the world-wide-web, please send an email
|
|
||||||
* to license@prestashop.com so we can send you a copy immediately.
|
|
||||||
*
|
|
||||||
* DISCLAIMER
|
|
||||||
*
|
|
||||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
|
||||||
* versions in the future. If you wish to customize PrestaShop for your
|
|
||||||
* needs please refer to http://www.prestashop.com for more information.
|
|
||||||
*
|
|
||||||
* @author PrestaShop SA <contact@prestashop.com>
|
|
||||||
* @copyright 2007-2011 PrestaShop SA
|
|
||||||
* @version Release: $Revision: 8971 $
|
|
||||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
|
||||||
* International Registered Trademark & Property of PrestaShop SA
|
|
||||||
*}
|
|
||||||
{if $show_toolbar}
|
{if $show_toolbar}
|
||||||
<div class="toolbar-placeholder">
|
<div class="toolbar-placeholder">
|
||||||
<div class="toolbarBox {if $toolbar_fix}toolbarHead{/if}">
|
<div class="toolbarBox {if $toolbar_fix}toolbarHead{/if}">
|
||||||
@@ -79,7 +54,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var product_rules_counter = {if isset($product_rules_counter)}{$product_rules_counter}{else}0{/if};
|
var product_rule_groups_counter = {if isset($product_rule_groups_counter)}{$product_rule_groups_counter}{else}0{/if};
|
||||||
|
var product_rule_counters = new Array();
|
||||||
var currentToken = '{$currentToken}';
|
var currentToken = '{$currentToken}';
|
||||||
var currentFormTab = '{if isset($smarty.post.currentFormTab)}{$smarty.post.currentFormTab|escape}{else}informations{/if}';
|
var currentFormTab = '{if isset($smarty.post.currentFormTab)}{$smarty.post.currentFormTab|escape}{else}informations{/if}';
|
||||||
|
|
||||||
@@ -93,5 +69,4 @@
|
|||||||
{/foreach}
|
{/foreach}
|
||||||
displayFlags(languages, {$defaultLanguage});
|
displayFlags(languages, {$defaultLanguage});
|
||||||
</script>
|
</script>
|
||||||
|
<script type="text/javascript" src="themes/default/template/controllers/cart_rules/form.js"></script>
|
||||||
<script src="../js/admin_cart_rules.js" type="text/javascript"></script>
|
|
||||||
@@ -1,28 +1,3 @@
|
|||||||
{*
|
|
||||||
* 2007-2011 PrestaShop
|
|
||||||
*
|
|
||||||
* NOTICE OF LICENSE
|
|
||||||
*
|
|
||||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
|
||||||
* that is bundled with this package in the file LICENSE.txt.
|
|
||||||
* It is also available through the world-wide-web at this URL:
|
|
||||||
* http://opensource.org/licenses/afl-3.0.php
|
|
||||||
* If you did not receive a copy of the license and are unable to
|
|
||||||
* obtain it through the world-wide-web, please send an email
|
|
||||||
* to license@prestashop.com so we can send you a copy immediately.
|
|
||||||
*
|
|
||||||
* DISCLAIMER
|
|
||||||
*
|
|
||||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
|
||||||
* versions in the future. If you wish to customize PrestaShop for your
|
|
||||||
* needs please refer to http://www.prestashop.com for more information.
|
|
||||||
*
|
|
||||||
* @author PrestaShop SA <contact@prestashop.com>
|
|
||||||
* @copyright 2007-2011 PrestaShop SA
|
|
||||||
* @version Release: $Revision: 8971 $
|
|
||||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
|
||||||
* International Registered Trademark & Property of PrestaShop SA
|
|
||||||
*}
|
|
||||||
<table cellpadding="0" cellspacing="0">
|
<table cellpadding="0" cellspacing="0">
|
||||||
<tr>
|
<tr>
|
||||||
<td style="width:50%">
|
<td style="width:50%">
|
||||||
@@ -31,7 +6,7 @@
|
|||||||
<div class="translatable">
|
<div class="translatable">
|
||||||
{foreach from=$languages item=language}
|
{foreach from=$languages item=language}
|
||||||
<div class="lang_{$language.id_lang}" style="display:{if $language.id_lang == $defaultLanguage}block{else}none{/if};float:left">
|
<div class="lang_{$language.id_lang}" style="display:{if $language.id_lang == $defaultLanguage}block{else}none{/if};float:left">
|
||||||
<input type="text" id="name_{$language.id_lang}" name="name_{$language.id_lang}" value="{$currentTab->getFieldValue($currentObject, 'name', $language.id_lang)}" style="width:300px" />
|
<input type="text" id="name_{$language.id_lang}" name="name_{$language.id_lang}" value="{$currentTab->getFieldValue($currentObject, 'name', $language.id_lang)}" style="width:500px" />
|
||||||
</div>
|
</div>
|
||||||
{/foreach}
|
{/foreach}
|
||||||
</div>
|
</div>
|
||||||
@@ -40,8 +15,8 @@
|
|||||||
<label>{l s='Code'}</label>
|
<label>{l s='Code'}</label>
|
||||||
<div class="margin-form">
|
<div class="margin-form">
|
||||||
<input type="text" id="code" name="code" value="{$currentTab->getFieldValue($currentObject, 'code')}" />
|
<input type="text" id="code" name="code" value="{$currentTab->getFieldValue($currentObject, 'code')}" />
|
||||||
<img src="../img/admin/news-new.gif" onclick="gencode(8);" style="cursor:pointer" />
|
<a href="javascript:gencode(8);" style="cursor:pointer">{l s='(Click to generate random code)'}</a>
|
||||||
<p>{l s='Optional, the rule will automatically be applied if you leave this field blank.'}</p>
|
<p>{l s='Caution! The rule will automatically be applied if you leave this field blank.'}</p>
|
||||||
</div>
|
</div>
|
||||||
<label>{l s='Partial use'}</label>
|
<label>{l s='Partial use'}</label>
|
||||||
<div class="margin-form">
|
<div class="margin-form">
|
||||||
|
|||||||
@@ -1,54 +1,26 @@
|
|||||||
{*
|
<tr id="product_rule_{$product_rule_group_id}_{$product_rule_id}_tr">
|
||||||
* 2007-2011 PrestaShop
|
|
||||||
*
|
|
||||||
* NOTICE OF LICENSE
|
|
||||||
*
|
|
||||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
|
||||||
* that is bundled with this package in the file LICENSE.txt.
|
|
||||||
* It is also available through the world-wide-web at this URL:
|
|
||||||
* http://opensource.org/licenses/afl-3.0.php
|
|
||||||
* If you did not receive a copy of the license and are unable to
|
|
||||||
* obtain it through the world-wide-web, please send an email
|
|
||||||
* to license@prestashop.com so we can send you a copy immediately.
|
|
||||||
*
|
|
||||||
* DISCLAIMER
|
|
||||||
*
|
|
||||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
|
||||||
* versions in the future. If you wish to customize PrestaShop for your
|
|
||||||
* needs please refer to http://www.prestashop.com for more information.
|
|
||||||
*
|
|
||||||
* @author PrestaShop SA <contact@prestashop.com>
|
|
||||||
* @copyright 2007-2011 PrestaShop SA
|
|
||||||
* @version Release: $Revision: 8971 $
|
|
||||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
|
||||||
* International Registered Trademark & Property of PrestaShop SA
|
|
||||||
*}
|
|
||||||
<tr id="product_rule_{$product_rule_id}_tr">
|
|
||||||
<td>
|
<td>
|
||||||
<a href="javascript:removeProductRule({$product_rule_id});">
|
<a href="javascript:removeProductRule({$product_rule_group_id}, {$product_rule_id});">
|
||||||
<img src="../img/admin/disabled.gif" alt="{l s='Remove'}" title="{l s='Remove'}" />
|
<img src="../img/admin/disabled.gif" alt="{l s='Remove'}" title="{l s='Remove'}" />
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input type="hidden" name="product_rule[]" value="{$product_rule_id}" />
|
<input type="hidden" name="product_rule_{$product_rule_group_id}[]" value="{$product_rule_id}" />
|
||||||
<input type="hidden" name="product_rule_{$product_rule_id}_type" value="{$product_rule_type}" />
|
<input type="hidden" name="product_rule_{$product_rule_group_id}_{$product_rule_id}_type" value="{$product_rule_type}" />
|
||||||
[{$product_rule_type}] {l s='The cart must contain at least'}
|
[{$product_rule_type}]
|
||||||
</td>
|
|
||||||
<td style="padding:5px">
|
|
||||||
<input type="text" name="product_rule_{$product_rule_id}_quantity" value="{$product_rule_quantity|intval}" style="width:30px" />
|
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{l s='product(s) matching'}
|
{l s='The product(s) are matching on of these'}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input type="text" id="product_rule_{$product_rule_id}_match" value="" disabled="disabled" />
|
<input type="text" id="product_rule_{$product_rule_group_id}_{$product_rule_id}_match" value="" disabled="disabled" />
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a id="product_rule_{$product_rule_id}_choose_link" href="#product_rule_{$product_rule_id}_choose_content">
|
<a id="product_rule_{$product_rule_group_id}_{$product_rule_id}_choose_link" href="#product_rule_{$product_rule_group_id}_{$product_rule_id}_choose_content">
|
||||||
<img src="../img/admin/choose.gif" alt="{l s='Choose'}" title="{l s='Choose'}" /> {l s='Choose'}
|
<img src="../img/admin/choose.gif" alt="{l s='Choose'}" title="{l s='Choose'}" /> {l s='Choose'}
|
||||||
</a>
|
</a>
|
||||||
<div>
|
<div>
|
||||||
<div id="product_rule_{$product_rule_id}_choose_content">
|
<div id="product_rule_{$product_rule_group_id}_{$product_rule_id}_choose_content">
|
||||||
{$product_rule_choose_content}
|
{$product_rule_choose_content}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -56,6 +28,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$('#product_rule_{$product_rule_id}_choose_content').parent().hide();
|
$('#product_rule_{$product_rule_group_id}_{$product_rule_id}_choose_content').parent().hide();
|
||||||
$("#product_rule_{$product_rule_id}_choose_link").fancybox();
|
$("#product_rule_{$product_rule_group_id}_{$product_rule_id}_choose_link").fancybox();
|
||||||
|
$(document).ready(function() { updateProductRuleShortDescription($('#product_rule_select_{$product_rule_group_id}_{$product_rule_id}_add')); });
|
||||||
</script>
|
</script>
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
<tr id="product_rule_group_{$product_rule_group_id}_tr">
|
||||||
|
<td style="vertical-align:top">
|
||||||
|
<a href="javascript:removeProductRuleGroup({$product_rule_group_id});">
|
||||||
|
<img src="../img/admin/disabled.gif" alt="{l s='Remove'}" title="{l s='Remove'}" />
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input type="hidden" name="product_rule_group[]" value="{$product_rule_group_id}" />
|
||||||
|
{l s='The cart must contain at least'}
|
||||||
|
<input type="text" name="product_rule_group_{$product_rule_group_id}_quantity" value="{$product_rule_group_quantity|intval}" style="width:30px" />
|
||||||
|
{l s='product(s) matching the following rules:'}
|
||||||
|
<br />
|
||||||
|
<a href="javascript:addProductRule({$product_rule_group_id});">
|
||||||
|
<img src="../img/admin/add.gif" alt="{l s='Add'}" title="{l s='Add'}" />
|
||||||
|
{l s='Add a rule concerning'}
|
||||||
|
</a>
|
||||||
|
<select id="product_rule_type_{$product_rule_group_id}">
|
||||||
|
<option value="">{l s='-- Choose --'}</option>
|
||||||
|
<option value="products">{l s='Products'}</option>
|
||||||
|
<option value="attributes">{l s='Attributes'}</option>
|
||||||
|
<option value="categories">{l s='Categories'}</option>
|
||||||
|
<option value="manufacturers">{l s='Manufacturers'}</option>
|
||||||
|
<option value="suppliers">{l s='Suppliers'}</option>
|
||||||
|
</select>
|
||||||
|
<a href="javascript:addProductRule({$product_rule_group_id});">
|
||||||
|
<input type="button" class="button" value="OK" />
|
||||||
|
</a>
|
||||||
|
<table id="product_rule_table_{$product_rule_group_id}" class="table" cellpadding="0" cellspacing="0">
|
||||||
|
{if isset($product_rules) && $product_rules|@count}
|
||||||
|
{foreach from=$product_rules item='product_rule'}
|
||||||
|
{$product_rule}
|
||||||
|
{/foreach}
|
||||||
|
{/if}
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
@@ -1,49 +1,24 @@
|
|||||||
{*
|
|
||||||
* 2007-2011 PrestaShop
|
|
||||||
*
|
|
||||||
* NOTICE OF LICENSE
|
|
||||||
*
|
|
||||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
|
||||||
* that is bundled with this package in the file LICENSE.txt.
|
|
||||||
* It is also available through the world-wide-web at this URL:
|
|
||||||
* http://opensource.org/licenses/afl-3.0.php
|
|
||||||
* If you did not receive a copy of the license and are unable to
|
|
||||||
* obtain it through the world-wide-web, please send an email
|
|
||||||
* to license@prestashop.com so we can send you a copy immediately.
|
|
||||||
*
|
|
||||||
* DISCLAIMER
|
|
||||||
*
|
|
||||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
|
||||||
* versions in the future. If you wish to customize PrestaShop for your
|
|
||||||
* needs please refer to http://www.prestashop.com for more information.
|
|
||||||
*
|
|
||||||
* @author PrestaShop SA <contact@prestashop.com>
|
|
||||||
* @copyright 2007-2011 PrestaShop SA
|
|
||||||
* @version Release: $Revision: 8971 $
|
|
||||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
|
||||||
* International Registered Trademark & Property of PrestaShop SA
|
|
||||||
*}
|
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<p><strong>{l s='Selected'}</strong></p>
|
<p><strong>{l s='Selected'}</strong></p>
|
||||||
<select name="product_rule_select_{$product_rule_id}[]" class="product_rule_toselect" id="product_rule_select_{$product_rule_id}_2" style="border:1px solid #AAAAAA;width:400px;height:160px" multiple>
|
<select name="product_rule_select_{$product_rule_group_id}_{$product_rule_id}[]" class="product_rule_toselect" id="product_rule_select_{$product_rule_group_id}_{$product_rule_id}_2" style="border:1px solid #AAAAAA;width:400px;height:160px" multiple>
|
||||||
{foreach from=$product_rule_itemlist.selected item='item'}
|
{foreach from=$product_rule_itemlist.selected item='item'}
|
||||||
<option value="{$item.id|intval}"> {$item.name}</option>
|
<option value="{$item.id|intval}"> {$item.name}</option>
|
||||||
{/foreach}
|
{/foreach}
|
||||||
</select><br /><br />
|
</select><br /><br />
|
||||||
<a style="cursor:pointer;text-align:center;display:block;border:1px solid #aaa;text-decoration:none;background-color:#fafafa;color:#123456;margin:2px;padding:2px" id="product_rule_select_{$product_rule_id}_remove">
|
<a style="cursor:pointer;text-align:center;display:block;border:1px solid #aaa;text-decoration:none;background-color:#fafafa;color:#123456;margin:2px;padding:2px" id="product_rule_select_{$product_rule_group_id}_{$product_rule_id}_remove">
|
||||||
{l s='Remove'} >>
|
{l s='Remove'} >>
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
<td style="padding-left:20px;">
|
<td style="padding-left:20px;">
|
||||||
<p><strong>{l s='Unselected'}</strong></p>
|
<p><strong>{l s='Unselected'}</strong></p>
|
||||||
<select id="product_rule_select_{$product_rule_id}_1" style="border:1px solid #AAAAAA;width:400px;height:160px" multiple>
|
<select id="product_rule_select_{$product_rule_group_id}_{$product_rule_id}_1" style="border:1px solid #AAAAAA;width:400px;height:160px" multiple>
|
||||||
{foreach from=$product_rule_itemlist.unselected item='item'}
|
{foreach from=$product_rule_itemlist.unselected item='item'}
|
||||||
<option value="{$item.id|intval}"> {$item.name}</option>
|
<option value="{$item.id|intval}"> {$item.name}</option>
|
||||||
{/foreach}
|
{/foreach}
|
||||||
</select><br /><br />
|
</select><br /><br />
|
||||||
<a style="cursor:pointer;text-align:center;display:block;border:1px solid #aaa;text-decoration:none;background-color:#fafafa;color:#123456;margin:2px;padding:2px" id="product_rule_select_{$product_rule_id}_add">
|
<a style="cursor:pointer;text-align:center;display:block;border:1px solid #aaa;text-decoration:none;background-color:#fafafa;color:#123456;margin:2px;padding:2px" id="product_rule_select_{$product_rule_group_id}_{$product_rule_id}_add">
|
||||||
<< {l s='Add'}
|
<< {l s='Add'}
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
@@ -51,7 +26,7 @@
|
|||||||
</table>
|
</table>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$('#product_rule_select_{$product_rule_id}_remove').click(function() { removeCartRuleOption(this); updateProductRuleShortDescription(this); });
|
$('#product_rule_select_{$product_rule_group_id}_{$product_rule_id}_remove').click(function() { removeCartRuleOption(this); updateProductRuleShortDescription(this); });
|
||||||
$('#product_rule_select_{$product_rule_id}_add').click(function() { addCartRuleOption(this); updateProductRuleShortDescription(this); });
|
$('#product_rule_select_{$product_rule_group_id}_{$product_rule_id}_add').click(function() { addCartRuleOption(this); updateProductRuleShortDescription(this); });
|
||||||
$(document).ready(function() { updateProductRuleShortDescription($('#product_rule_select_{$product_rule_id}_add')); });
|
$(document).ready(function() { updateProductRuleShortDescription($('#product_rule_select_{$product_rule_group_id}_{$product_rule_id}_add')); });
|
||||||
</script>
|
</script>
|
||||||
+135
-48
@@ -118,7 +118,8 @@ class CartRuleCore extends ObjectModel
|
|||||||
Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'cart_rule_group` WHERE `id_cart_rule` = '.(int)$this->id);
|
Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'cart_rule_group` WHERE `id_cart_rule` = '.(int)$this->id);
|
||||||
Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'cart_rule_country` WHERE `id_cart_rule` = '.(int)$this->id);
|
Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'cart_rule_country` WHERE `id_cart_rule` = '.(int)$this->id);
|
||||||
Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'cart_rule_combination` WHERE `id_cart_rule_1` = '.(int)$this->id.' OR `id_cart_rule_2` = '.(int)$this->id);
|
Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'cart_rule_combination` WHERE `id_cart_rule_1` = '.(int)$this->id.' OR `id_cart_rule_2` = '.(int)$this->id);
|
||||||
Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'cart_rule_product_rule` WHERE `id_cart_rule` = '.(int)$this->id);
|
Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'cart_rule_product_rule_group` WHERE `id_cart_rule` = '.(int)$this->id);
|
||||||
|
Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'cart_rule_product_rule` WHERE `id_product_rule_group` NOT IN (SELECT `id_product_rule_group` FROM `'._DB_PREFIX_.'cart_rule_product_rule_group`)');
|
||||||
Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'cart_rule_product_rule_value` WHERE `id_product_rule` NOT IN (SELECT `id_product_rule` FROM `'._DB_PREFIX_.'cart_rule_product_rule`)');
|
Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'cart_rule_product_rule_value` WHERE `id_product_rule` NOT IN (SELECT `id_product_rule` FROM `'._DB_PREFIX_.'cart_rule_product_rule`)');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,7 +215,26 @@ class CartRuleCore extends ObjectModel
|
|||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getProductRules()
|
public function getProductRuleGroups()
|
||||||
|
{
|
||||||
|
if (!Validate::isLoadedObject($this) || $this->product_restriction == 0)
|
||||||
|
return array();
|
||||||
|
|
||||||
|
$productRuleGroups = array();
|
||||||
|
$results = Db::getInstance()->ExecuteS('
|
||||||
|
SELECT *
|
||||||
|
FROM '._DB_PREFIX_.'cart_rule_product_rule_group prg
|
||||||
|
WHERE prg.id_cart_rule = '.(int)$this->id, false);
|
||||||
|
foreach ($results as $row)
|
||||||
|
{
|
||||||
|
if (!isset($productRuleGroups[$row['id_product_rule_group']]))
|
||||||
|
$productRuleGroups[$row['id_product_rule_group']] = array('id_product_rule_group' => $row['id_product_rule_group'], 'quantity' => $row['quantity']);
|
||||||
|
$productRuleGroups[$row['id_product_rule_group']]['product_rules'] = $this->getProductRules($row['id_product_rule_group']);
|
||||||
|
}
|
||||||
|
return $productRuleGroups;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getProductRules($id_product_rule_group)
|
||||||
{
|
{
|
||||||
if (!Validate::isLoadedObject($this) || $this->product_restriction == 0)
|
if (!Validate::isLoadedObject($this) || $this->product_restriction == 0)
|
||||||
return array();
|
return array();
|
||||||
@@ -224,11 +244,11 @@ class CartRuleCore extends ObjectModel
|
|||||||
SELECT *
|
SELECT *
|
||||||
FROM '._DB_PREFIX_.'cart_rule_product_rule pr
|
FROM '._DB_PREFIX_.'cart_rule_product_rule pr
|
||||||
LEFT JOIN '._DB_PREFIX_.'cart_rule_product_rule_value prv ON pr.id_product_rule = prv.id_product_rule
|
LEFT JOIN '._DB_PREFIX_.'cart_rule_product_rule_value prv ON pr.id_product_rule = prv.id_product_rule
|
||||||
WHERE pr.id_cart_rule = '.(int)$this->id, false);
|
WHERE pr.id_product_rule_group = '.(int)$id_product_rule_group);
|
||||||
foreach ($results as $row)
|
foreach ($results as $row)
|
||||||
{
|
{
|
||||||
if (!isset($productRules[$row['id_product_rule']]))
|
if (!isset($productRules[$row['id_product_rule']]))
|
||||||
$productRules[$row['id_product_rule']] = array('quantity' => $row['quantity'], 'type' => $row['type'], 'values' => array());
|
$productRules[$row['id_product_rule']] = array('type' => $row['type'], 'values' => array());
|
||||||
$productRules[$row['id_product_rule']]['values'][] = $row['id_item'];
|
$productRules[$row['id_product_rule']]['values'][] = $row['id_item'];
|
||||||
}
|
}
|
||||||
return $productRules;
|
return $productRules;
|
||||||
@@ -328,50 +348,117 @@ class CartRuleCore extends ObjectModel
|
|||||||
// Check if the products chosen by the customer are usable with the cart rule
|
// Check if the products chosen by the customer are usable with the cart rule
|
||||||
if ($this->product_restriction)
|
if ($this->product_restriction)
|
||||||
{
|
{
|
||||||
$productRules = $this->getProductRules();
|
$productRuleGroups = $this->getProductRuleGroups();
|
||||||
foreach ($productRules as $productRule)
|
foreach ($productRuleGroups as $id_product_rule_group => $productRuleGroup)
|
||||||
{
|
{
|
||||||
switch ($productRule['type'])
|
$productRules = $this->getProductRules($id_product_rule_group);
|
||||||
|
foreach ($productRules as $productRule)
|
||||||
{
|
{
|
||||||
case 'attributes':
|
$eligibleProductsList = array();
|
||||||
$cartAttributes = Db::getInstance()->ExecuteS('
|
foreach ($context->cart->getProducts() as $product)
|
||||||
SELECT cp.quantity, pac.`id_attribute`
|
$eligibleProductsList[] = (int)$product['id_product'];
|
||||||
FROM `'._DB_PREFIX_.'cart_product` cp
|
|
||||||
LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac ON cp.id_product_attribute = pac.id_product_attribute
|
switch ($productRule['type'])
|
||||||
WHERE cp.`id_cart` = '.(int)$context->cart->id.'
|
{
|
||||||
AND cp.id_product_attribute > 0');
|
case 'attributes':
|
||||||
$matchingProducts = 0;
|
$cartAttributes = Db::getInstance()->ExecuteS('
|
||||||
foreach ($cartAttributes as $cartAttribute)
|
SELECT cp.quantity, cp.`id_product`, pac.`id_attribute`
|
||||||
if (in_array($cartAttribute['id_attribute'], $productRule['values']))
|
FROM `'._DB_PREFIX_.'cart_product` cp
|
||||||
$matchingProducts += $cartAttribute['quantity'];
|
LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac ON cp.id_product_attribute = pac.id_product_attribute
|
||||||
if ($matchingProducts < $productRule['quantity'])
|
WHERE cp.`id_cart` = '.(int)$context->cart->id.'
|
||||||
return Tools::displayError('You cannot use this voucher with these products');
|
AND cp.`id_product` IN ('.implode($eligibleProductsList, ',').')
|
||||||
break;
|
AND cp.id_product_attribute > 0');
|
||||||
case 'products':
|
$countMatchingProducts = 0;
|
||||||
$cartProducts = Db::getInstance()->ExecuteS('
|
$matchingProductsList = array();
|
||||||
SELECT cp.quantity, cp.`id_product`
|
foreach ($cartAttributes as $cartAttribute)
|
||||||
FROM `'._DB_PREFIX_.'cart_product` cp
|
if (in_array($cartAttribute['id_attribute'], $productRule['values']))
|
||||||
WHERE cp.`id_cart` = '.(int)$context->cart->id);
|
{
|
||||||
$matchingProducts = 0;
|
$countMatchingProducts += $cartAttribute['quantity'];
|
||||||
foreach ($cartProducts as $cartProduct)
|
$matchingProductsList[] = $cartAttribute['id_product'];
|
||||||
if (in_array($cartProduct['id_product'], $productRule['values']))
|
}
|
||||||
$matchingProducts += $cartProduct['quantity'];
|
if ($countMatchingProducts < $productRuleGroup['quantity'])
|
||||||
if ($matchingProducts < $productRule['quantity'])
|
return Tools::displayError('You cannot use this voucher with these products');
|
||||||
return Tools::displayError('You cannot use this voucher with these products');
|
$eligibleProductsList = array_intersect($eligibleProductsList, $matchingProductsList);
|
||||||
break;
|
break;
|
||||||
case 'categories':
|
case 'products':
|
||||||
$cartCategories = Db::getInstance()->ExecuteS('
|
$cartProducts = Db::getInstance()->ExecuteS('
|
||||||
SELECT cp.quantity, catp.`id_category`
|
SELECT cp.quantity, cp.`id_product`
|
||||||
FROM `'._DB_PREFIX_.'cart_product` cp
|
FROM `'._DB_PREFIX_.'cart_product` cp
|
||||||
LEFT JOIN `'._DB_PREFIX_.'category_product` catp ON cp.id_product = catp.id_product
|
WHERE cp.`id_cart` = '.(int)$context->cart->id.'
|
||||||
WHERE cp.`id_cart` = '.(int)$context->cart->id);
|
AND cp.`id_product` IN ('.implode($eligibleProductsList, ',').')');
|
||||||
$matchingProducts = 0;
|
$countMatchingProducts = 0;
|
||||||
foreach ($cartCategories as $cartCategory)
|
$matchingProductsList = array();
|
||||||
if (in_array($cartCategory['id_category'], $productRule['values']))
|
foreach ($cartProducts as $cartProduct)
|
||||||
$matchingProducts += $cartCategory['quantity'];
|
if (in_array($cartProduct['id_product'], $productRule['values']))
|
||||||
if ($matchingProducts < $productRule['quantity'])
|
{
|
||||||
return Tools::displayError('You cannot use this voucher with these products');
|
$countMatchingProducts += $cartProduct['quantity'];
|
||||||
break;
|
$matchingProductsList[] = $cartProduct['id_product'];
|
||||||
|
}
|
||||||
|
if ($countMatchingProducts < $productRuleGroup['quantity'])
|
||||||
|
return Tools::displayError('You cannot use this voucher with these products');
|
||||||
|
$eligibleProductsList = array_intersect($eligibleProductsList, $matchingProductsList);
|
||||||
|
break;
|
||||||
|
case 'categories':
|
||||||
|
$cartCategories = Db::getInstance()->ExecuteS('
|
||||||
|
SELECT cp.quantity, cp.`id_product`, catp.`id_category`
|
||||||
|
FROM `'._DB_PREFIX_.'cart_product` cp
|
||||||
|
LEFT JOIN `'._DB_PREFIX_.'category_product` catp ON cp.id_product = catp.id_product
|
||||||
|
WHERE cp.`id_cart` = '.(int)$context->cart->id.'
|
||||||
|
AND cp.`id_product` IN ('.implode($eligibleProductsList, ',').')');
|
||||||
|
$countMatchingProducts = 0;
|
||||||
|
$matchingProductsList = array();
|
||||||
|
foreach ($cartCategories as $cartCategory)
|
||||||
|
if (in_array($cartCategory['id_category'], $productRule['values']))
|
||||||
|
{
|
||||||
|
$countMatchingProducts += $cartCategory['quantity'];
|
||||||
|
$matchingProductsList[] = $cartCategory['id_product'];
|
||||||
|
}
|
||||||
|
if ($countMatchingProducts < $productRuleGroup['quantity'])
|
||||||
|
return Tools::displayError('You cannot use this voucher with these products');
|
||||||
|
$eligibleProductsList = array_intersect($eligibleProductsList, $matchingProductsList);
|
||||||
|
break;
|
||||||
|
case 'manufacturers':
|
||||||
|
$cartManufacturers = Db::getInstance()->ExecuteS('
|
||||||
|
SELECT cp.quantity, cp.`id_product`, p.`id_manufacturer`
|
||||||
|
FROM `'._DB_PREFIX_.'cart_product` cp
|
||||||
|
LEFT JOIN `'._DB_PREFIX_.'product` p ON cp.id_product = p.id_product
|
||||||
|
WHERE cp.`id_cart` = '.(int)$context->cart->id.'
|
||||||
|
AND cp.`id_product` IN ('.implode($eligibleProductsList, ',').')');
|
||||||
|
$countMatchingProducts = 0;
|
||||||
|
$matchingProductsList = array();
|
||||||
|
foreach ($cartManufacturers as $cartManufacturer)
|
||||||
|
if (in_array($cartManufacturer['id_manufacturer'], $productRule['values']))
|
||||||
|
{
|
||||||
|
$countMatchingProducts += $cartManufacturer['quantity'];
|
||||||
|
$matchingProductsList[] = $cartManufacturer['id_product'];
|
||||||
|
}
|
||||||
|
if ($countMatchingProducts < $productRuleGroup['quantity'])
|
||||||
|
return Tools::displayError('You cannot use this voucher with these products');
|
||||||
|
$eligibleProductsList = array_intersect($eligibleProductsList, $matchingProductsList);
|
||||||
|
break;
|
||||||
|
case 'suppliers':
|
||||||
|
$cartSuppliers = Db::getInstance()->ExecuteS('
|
||||||
|
SELECT cp.quantity, cp.`id_product`, p.`id_supplier`
|
||||||
|
FROM `'._DB_PREFIX_.'cart_product` cp
|
||||||
|
LEFT JOIN `'._DB_PREFIX_.'product` p ON cp.id_product = p.id_product
|
||||||
|
WHERE cp.`id_cart` = '.(int)$context->cart->id.'
|
||||||
|
AND cp.`id_product` IN ('.implode($eligibleProductsList, ',').')');
|
||||||
|
$countMatchingProducts = 0;
|
||||||
|
$matchingProductsList = array();
|
||||||
|
foreach ($cartSuppliers as $cartSupplier)
|
||||||
|
if (in_array($cartSupplier['id_supplier'], $productRule['values']))
|
||||||
|
{
|
||||||
|
$countMatchingProducts += $cartSupplier['quantity'];
|
||||||
|
$matchingProductsList[] = $cartSupplier['id_product'];
|
||||||
|
}
|
||||||
|
if ($countMatchingProducts < $productRuleGroup['quantity'])
|
||||||
|
return Tools::displayError('You cannot use this voucher with these products');
|
||||||
|
$eligibleProductsList = array_intersect($eligibleProductsList, $matchingProductsList);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!count($eligibleProductsList))
|
||||||
|
return Tools::displayError('You cannot use this voucher with these products');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -461,11 +548,11 @@ class CartRuleCore extends ObjectModel
|
|||||||
$price = ($useTax ? $product['price_wt'] : $product['price']);
|
$price = ($useTax ? $product['price_wt'] : $product['price']);
|
||||||
if ($price > 0 && ($minPrice === false || $minPrice > $price))
|
if ($price > 0 && ($minPrice === false || $minPrice > $price))
|
||||||
$minPrice = $price;
|
$minPrice = $price;
|
||||||
$reductionValue += $minPrice * $this->reduction_percent / 100;
|
|
||||||
}
|
}
|
||||||
|
$reductionValue += $minPrice * $this->reduction_percent / 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Discount (�)
|
// Discount (¤)
|
||||||
if ($this->reduction_amount)
|
if ($this->reduction_amount)
|
||||||
{
|
{
|
||||||
$reduction_amount = $this->reduction_amount;
|
$reduction_amount = $this->reduction_amount;
|
||||||
|
|||||||
@@ -330,7 +330,7 @@ abstract class PaymentModuleCore extends Module
|
|||||||
|
|
||||||
if ($id_order_state != Configuration::get('PS_OS_ERROR') && $id_order_state != Configuration::get('PS_OS_CANCELED'))
|
if ($id_order_state != Configuration::get('PS_OS_ERROR') && $id_order_state != Configuration::get('PS_OS_CANCELED'))
|
||||||
{
|
{
|
||||||
// Create a new instance of Cart Rule without id_lang, in order to update it quantity
|
// Create a new instance of Cart Rule without id_lang, in order to update its quantity
|
||||||
$cart_rule_to_update = new CartRule($cart_rule_obj->id);
|
$cart_rule_to_update = new CartRule($cart_rule_obj->id);
|
||||||
$cart_rule_to_update->quantity = $cart_rule_to_update->quantity - 1;
|
$cart_rule_to_update->quantity = $cart_rule_to_update->quantity - 1;
|
||||||
$cart_rule_to_update->update();
|
$cart_rule_to_update->update();
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ class OrderCartRuleCore extends ObjectModel
|
|||||||
'primary' => 'id_order_cart_rule',
|
'primary' => 'id_order_cart_rule',
|
||||||
'fields' => array(
|
'fields' => array(
|
||||||
'id_order' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
|
'id_order' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
|
||||||
|
'id_cart_rule' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
|
||||||
'id_order_invoice' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
|
'id_order_invoice' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
|
||||||
'name' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true),
|
'name' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true),
|
||||||
'value' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat', 'required' => true),
|
'value' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat', 'required' => true),
|
||||||
|
|||||||
@@ -76,8 +76,9 @@ class AdminCartRulesControllerCore extends AdminController
|
|||||||
{
|
{
|
||||||
// All the associations are deleted for an update, then recreated when we call the "afterAdd" method
|
// All the associations are deleted for an update, then recreated when we call the "afterAdd" method
|
||||||
$id_cart_rule = Tools::getValue('id_cart_rule');
|
$id_cart_rule = Tools::getValue('id_cart_rule');
|
||||||
foreach (array('country', 'carrier', 'group', 'product_rule') as $type)
|
foreach (array('country', 'carrier', 'group', 'product_rule_group') as $type)
|
||||||
Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'cart_rule_'.$type.'` WHERE `id_cart_rule` = '.(int)$id_cart_rule);
|
Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'cart_rule_'.$type.'` WHERE `id_cart_rule` = '.(int)$id_cart_rule);
|
||||||
|
Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'cart_rule_product_rule` WHERE `id_product_rule_group` NOT IN (SELECT `id_product_rule_group` FROM `'._DB_PREFIX_.'cart_rule_product_rule_group`)');
|
||||||
Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'cart_rule_product_rule_value` WHERE `id_product_rule` NOT IN (SELECT `id_product_rule` FROM `'._DB_PREFIX_.'cart_rule_product_rule`)');
|
Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'cart_rule_product_rule_value` WHERE `id_product_rule` NOT IN (SELECT `id_product_rule` FROM `'._DB_PREFIX_.'cart_rule_product_rule`)');
|
||||||
Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'cart_rule_combination` WHERE `id_cart_rule_1` = '.(int)$id_cart_rule.' OR `id_cart_rule_2` = '.(int)$id_cart_rule);
|
Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'cart_rule_combination` WHERE `id_cart_rule_1` = '.(int)$id_cart_rule.' OR `id_cart_rule_2` = '.(int)$id_cart_rule);
|
||||||
|
|
||||||
@@ -105,18 +106,26 @@ class AdminCartRulesControllerCore extends AdminController
|
|||||||
Db::getInstance()->Execute('INSERT INTO `'._DB_PREFIX_.'cart_rule_combination` (`id_cart_rule_1`, `id_cart_rule_2`) VALUES '.implode(',', $values));
|
Db::getInstance()->Execute('INSERT INTO `'._DB_PREFIX_.'cart_rule_combination` (`id_cart_rule_1`, `id_cart_rule_2`) VALUES '.implode(',', $values));
|
||||||
}
|
}
|
||||||
// Add product rule restrictions
|
// Add product rule restrictions
|
||||||
if (Tools::getValue('product_restriction') && is_array($array = Tools::getValue('product_rule')) && count($array))
|
if (Tools::getValue('product_restriction') && is_array($ruleGroupArray = Tools::getValue('product_rule_group')) && count($ruleGroupArray))
|
||||||
{
|
{
|
||||||
foreach ($array as $id)
|
foreach ($ruleGroupArray as $ruleGroupId)
|
||||||
{
|
{
|
||||||
Db::getInstance()->Execute('INSERT INTO `'._DB_PREFIX_.'cart_rule_product_rule` (`id_cart_rule`, `quantity`, `type`)
|
Db::getInstance()->Execute('INSERT INTO `'._DB_PREFIX_.'cart_rule_product_rule_group` (`id_cart_rule`, `quantity`)
|
||||||
VALUES ('.(int)$currentObject->id.', '.(int)Tools::getValue('product_rule_'.$id.'_quantity').', "'.pSQL(Tools::getValue('product_rule_'.$id.'_type')).'")');
|
VALUES ('.(int)$currentObject->id.', '.(int)Tools::getValue('product_rule_group_'.$ruleGroupId.'_quantity').')');
|
||||||
$id_product_rule = Db::getInstance()->Insert_ID();
|
$id_product_rule_group = Db::getInstance()->Insert_ID();
|
||||||
|
|
||||||
$values = array();
|
if (is_array($ruleArray = Tools::getValue('product_rule_'.$ruleGroupId)) && count($ruleArray))
|
||||||
foreach (Tools::getValue('product_rule_select_'.$id) as $id)
|
foreach ($ruleArray as $ruleId)
|
||||||
$values[] = '('.(int)$id_product_rule.','.(int)$id.')';
|
{
|
||||||
Db::getInstance()->Execute('INSERT INTO `'._DB_PREFIX_.'cart_rule_product_rule_value` (`id_product_rule`, `id_item`) VALUES '.implode(',', $values));
|
Db::getInstance()->Execute('INSERT INTO `'._DB_PREFIX_.'cart_rule_product_rule` (`id_product_rule_group`, `type`)
|
||||||
|
VALUES ('.(int)$id_product_rule_group.', "'.pSQL(Tools::getValue('product_rule_'.$ruleGroupId.'_'.$ruleId.'_type')).'")');
|
||||||
|
$id_product_rule = Db::getInstance()->Insert_ID();
|
||||||
|
|
||||||
|
$values = array();
|
||||||
|
foreach (Tools::getValue('product_rule_select_'.$ruleGroupId.'_'.$ruleId) as $id)
|
||||||
|
$values[] = '('.(int)$id_product_rule.','.(int)$id.')';
|
||||||
|
Db::getInstance()->Execute('INSERT INTO `'._DB_PREFIX_.'cart_rule_product_rule_value` (`id_product_rule`, `id_item`) VALUES '.implode(',', $values));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,13 +161,67 @@ class AdminCartRulesControllerCore extends AdminController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getProductRuleDisplay($product_rule_id, $product_rule_type, $product_rule_quantity = 1, $selected = array())
|
/* Retrieve the cart rule product rule groups in the POST data if available, and in the database if there is none */
|
||||||
|
public function getProductRuleGroupsDisplay($cartRule)
|
||||||
|
{
|
||||||
|
$productRuleGroupsArray = array();
|
||||||
|
if (Tools::getValue('product_restriction') && is_array($array = Tools::getValue('product_rule_group')) && count($array))
|
||||||
|
{
|
||||||
|
$i = 1;
|
||||||
|
foreach ($array as $ruleGroupId)
|
||||||
|
{
|
||||||
|
$productRulesArray = array();
|
||||||
|
if (is_array($array = Tools::getValue('product_rule_'.$ruleGroupId)) && count($array))
|
||||||
|
{
|
||||||
|
foreach ($array as $ruleId)
|
||||||
|
{
|
||||||
|
$productRulesArray[] = $this->getProductRuleDisplay(
|
||||||
|
$ruleGroupId,
|
||||||
|
$ruleId,
|
||||||
|
Tools::getValue('product_rule_'.$ruleGroupId.'_'.$ruleId.'_type'),
|
||||||
|
Tools::getValue('product_rule_select_'.$ruleGroupId.'_'.$ruleId)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$productRuleGroupsArray[] = $this->getProductRuleGroupDisplay(
|
||||||
|
$i++,
|
||||||
|
(int)Tools::getValue('product_rule_group_'.$ruleGroupId.'_quantity'),
|
||||||
|
$productRulesArray
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$i = 1;
|
||||||
|
foreach ($cartRule->getProductRuleGroups() as $productRuleGroup)
|
||||||
|
{
|
||||||
|
$j = 1;
|
||||||
|
$productRulesDisplay = array();
|
||||||
|
foreach ($productRuleGroup['product_rules'] as $id_product_rule => $productRule)
|
||||||
|
$productRulesDisplay[] = $this->getProductRuleDisplay($i, $j++, $productRule['type'], $productRule['values']);
|
||||||
|
$productRuleGroupsArray[] = $this->getProductRuleGroupDisplay($i++, $productRuleGroup['quantity'], $productRulesDisplay);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $productRuleGroupsArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return the form for a single cart rule group either with or without product_rules set up */
|
||||||
|
public function getProductRuleGroupDisplay($product_rule_group_id, $product_rule_group_quantity = 1, $product_rules = null)
|
||||||
|
{
|
||||||
|
Context::getContext()->smarty->assign('product_rule_group_id', $product_rule_group_id);
|
||||||
|
Context::getContext()->smarty->assign('product_rule_group_quantity', $product_rule_group_quantity);
|
||||||
|
Context::getContext()->smarty->assign('product_rules', $product_rules);
|
||||||
|
return Context::getContext()->smarty->fetch('controllers/cart_rules/product_rule_group.tpl');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getProductRuleDisplay($product_rule_group_id, $product_rule_id, $product_rule_type, $selected = array())
|
||||||
{
|
{
|
||||||
Context::getContext()->smarty->assign(
|
Context::getContext()->smarty->assign(
|
||||||
array(
|
array(
|
||||||
|
'product_rule_group_id' => (int)$product_rule_group_id,
|
||||||
'product_rule_id' => (int)$product_rule_id,
|
'product_rule_id' => (int)$product_rule_id,
|
||||||
'product_rule_type' => $product_rule_type,
|
'product_rule_type' => $product_rule_type,
|
||||||
'product_rule_quantity' => (int)$product_rule_quantity
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -193,6 +256,30 @@ class AdminCartRulesControllerCore extends AdminController
|
|||||||
$choose_content = $this->createTemplate('product_rule_itemlist.tpl')->fetch();
|
$choose_content = $this->createTemplate('product_rule_itemlist.tpl')->fetch();
|
||||||
Context::getContext()->smarty->assign('product_rule_choose_content', $choose_content);
|
Context::getContext()->smarty->assign('product_rule_choose_content', $choose_content);
|
||||||
break;
|
break;
|
||||||
|
case 'manufacturers':
|
||||||
|
$products = array('selected' => array(), 'unselected' => array());
|
||||||
|
$results = Db::getInstance()->ExecuteS('
|
||||||
|
SELECT name, id_manufacturer as id
|
||||||
|
FROM '._DB_PREFIX_.'manufacturer
|
||||||
|
ORDER BY name');
|
||||||
|
foreach ($results as $row)
|
||||||
|
$products[in_array($row['id'], $selected) ? 'selected' : 'unselected'][] = $row;
|
||||||
|
Context::getContext()->smarty->assign('product_rule_itemlist', $products);
|
||||||
|
$choose_content = Context::getContext()->smarty->fetch('cart_rules/product_rule_itemlist.tpl');
|
||||||
|
Context::getContext()->smarty->assign('product_rule_choose_content', $choose_content);
|
||||||
|
break;
|
||||||
|
case 'suppliers':
|
||||||
|
$products = array('selected' => array(), 'unselected' => array());
|
||||||
|
$results = Db::getInstance()->ExecuteS('
|
||||||
|
SELECT name, id_supplier as id
|
||||||
|
FROM '._DB_PREFIX_.'supplier
|
||||||
|
ORDER BY name');
|
||||||
|
foreach ($results as $row)
|
||||||
|
$products[in_array($row['id'], $selected) ? 'selected' : 'unselected'][] = $row;
|
||||||
|
Context::getContext()->smarty->assign('product_rule_itemlist', $products);
|
||||||
|
$choose_content = Context::getContext()->smarty->fetch('cart_rules/product_rule_itemlist.tpl');
|
||||||
|
Context::getContext()->smarty->assign('product_rule_choose_content', $choose_content);
|
||||||
|
break;
|
||||||
case 'categories':
|
case 'categories':
|
||||||
// Todo: Consider optimization
|
// Todo: Consider optimization
|
||||||
$categories = array('selected' => array(), 'unselected' => array());
|
$categories = array('selected' => array(), 'unselected' => array());
|
||||||
@@ -207,8 +294,6 @@ class AdminCartRulesControllerCore extends AdminController
|
|||||||
$choose_content = $this->createTemplate('product_rule_itemlist.tpl')->fetch();
|
$choose_content = $this->createTemplate('product_rule_itemlist.tpl')->fetch();
|
||||||
Context::getContext()->smarty->assign('product_rule_choose_content', $choose_content);
|
Context::getContext()->smarty->assign('product_rule_choose_content', $choose_content);
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
die;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->createTemplate('product_rule.tpl')->fetch();
|
return $this->createTemplate('product_rule.tpl')->fetch();
|
||||||
@@ -217,7 +302,9 @@ class AdminCartRulesControllerCore extends AdminController
|
|||||||
public function ajaxProcess()
|
public function ajaxProcess()
|
||||||
{
|
{
|
||||||
if (Tools::isSubmit('newProductRule'))
|
if (Tools::isSubmit('newProductRule'))
|
||||||
die ($this->getProductRuleDisplay(Tools::getValue('product_rule_id'), Tools::getValue('product_rule_type')));
|
die ($this->getProductRuleDisplay(Tools::getValue('product_rule_group_id'), Tools::getValue('product_rule_id'), Tools::getValue('product_rule_type')));
|
||||||
|
if (Tools::isSubmit('newProductRuleGroup') && $product_rule_group_id = Tools::getValue('product_rule_group_id'))
|
||||||
|
die ($this->getProductRuleGroupDisplay($product_rule_group_id, Tools::getValue('product_rule_group_'.$product_rule_group_id.'_quantity')));
|
||||||
|
|
||||||
if (Tools::isSubmit('customerFilter'))
|
if (Tools::isSubmit('customerFilter'))
|
||||||
{
|
{
|
||||||
@@ -244,30 +331,6 @@ class AdminCartRulesControllerCore extends AdminController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getProductRulesDisplay($cartRule)
|
|
||||||
{
|
|
||||||
$i = 1;
|
|
||||||
$productRulesArray = array();
|
|
||||||
if (Tools::getValue('product_restriction') && is_array($array = Tools::getValue('product_rule')) && count($array))
|
|
||||||
{
|
|
||||||
foreach ($array as $id)
|
|
||||||
{
|
|
||||||
$productRulesArray[] = $this->getProductRuleDisplay(
|
|
||||||
$i++,
|
|
||||||
Tools::getValue('product_rule_'.$id.'_type'),
|
|
||||||
(int)Tools::getValue('product_rule_'.$id.'_quantity'),
|
|
||||||
Tools::getValue('product_rule_select_'.$id)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
foreach ($cartRule->getProductRules() as $productRule)
|
|
||||||
$productRulesArray[] = $this->getProductRuleDisplay($i++, $productRule['type'], $productRule['quantity'], $productRule['values']);
|
|
||||||
}
|
|
||||||
return $productRulesArray;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function renderForm()
|
public function renderForm()
|
||||||
{
|
{
|
||||||
$back = Tools::safeOutput(Tools::getValue('back', ''));
|
$back = Tools::safeOutput(Tools::getValue('back', ''));
|
||||||
@@ -306,7 +369,7 @@ class AdminCartRulesControllerCore extends AdminController
|
|||||||
Validate::isLoadedObject($product))
|
Validate::isLoadedObject($product))
|
||||||
$reduction_product_filter = trim($product->reference.' '.$product->name);
|
$reduction_product_filter = trim($product->reference.' '.$product->name);
|
||||||
|
|
||||||
$product_rules = $this->getProductRulesDisplay($current_object);
|
$product_rule_groups = $this->getProductRuleGroupsDisplay($current_object);
|
||||||
|
|
||||||
Context::getContext()->smarty->assign(
|
Context::getContext()->smarty->assign(
|
||||||
array(
|
array(
|
||||||
@@ -316,7 +379,7 @@ class AdminCartRulesControllerCore extends AdminController
|
|||||||
'title' => $this->l('Payment : Cart Rules '),
|
'title' => $this->l('Payment : Cart Rules '),
|
||||||
'languages' => Language::getLanguages(),
|
'languages' => Language::getLanguages(),
|
||||||
'defaultDateFrom' => date('Y-m-d H:00:00'),
|
'defaultDateFrom' => date('Y-m-d H:00:00'),
|
||||||
'defaultDateTo' => date('Y-m-d H:00:00', strtotime('+1 year')),
|
'defaultDateTo' => date('Y-m-d H:00:00', strtotime('+1 month')),
|
||||||
'customerFilter' => $customer_filter,
|
'customerFilter' => $customer_filter,
|
||||||
'giftProductFilter' => $gift_product_filter,
|
'giftProductFilter' => $gift_product_filter,
|
||||||
'reductionProductFilter' => $reduction_product_filter,
|
'reductionProductFilter' => $reduction_product_filter,
|
||||||
@@ -327,8 +390,8 @@ class AdminCartRulesControllerCore extends AdminController
|
|||||||
'carriers' => $current_object->getAssociatedRestrictions('carrier', 1),
|
'carriers' => $current_object->getAssociatedRestrictions('carrier', 1),
|
||||||
'groups' => $current_object->getAssociatedRestrictions('group', 0),
|
'groups' => $current_object->getAssociatedRestrictions('group', 0),
|
||||||
'cart_rules' => $current_object->getAssociatedRestrictions('cart_rule', 1),
|
'cart_rules' => $current_object->getAssociatedRestrictions('cart_rule', 1),
|
||||||
'product_rules' => $product_rules,
|
'product_rule_groups' => $product_rule_groups,
|
||||||
'product_rules_counter' => count($product_rules),
|
'product_rule_groups_counter' => count($product_rule_groups),
|
||||||
'attribute_groups' => AttributeGroup::getAttributesGroups(Context::getContext()->language->id),
|
'attribute_groups' => AttributeGroup::getAttributesGroups(Context::getContext()->language->id),
|
||||||
'currentIndex' => self::$currentIndex,
|
'currentIndex' => self::$currentIndex,
|
||||||
'currentToken' => $this->token,
|
'currentToken' => $this->token,
|
||||||
|
|||||||
@@ -259,11 +259,29 @@ CREATE TABLE `PREFIX_cart_rule_combination` (
|
|||||||
PRIMARY KEY (`id_cart_rule_1`, `id_cart_rule_2`)
|
PRIMARY KEY (`id_cart_rule_1`, `id_cart_rule_2`)
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE `PREFIX_cart_rule_product_rule` (
|
CREATE TABLE `PREFIX_cart_rule_manufacturer` (
|
||||||
`id_product_rule` int(10) unsigned NOT NULL auto_increment,
|
`id_cart_rule` int(10) unsigned NOT NULL,
|
||||||
|
`id_manufacturer` int(10) unsigned NOT NULL,
|
||||||
|
PRIMARY KEY (`id_cart_rule`, `id_manufacturer`)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE `PREFIX_cart_rule_supplier` (
|
||||||
|
`id_cart_rule` int(10) unsigned NOT NULL,
|
||||||
|
`id_supplier` int(10) unsigned NOT NULL,
|
||||||
|
PRIMARY KEY (`id_cart_rule`, `id_supplier`)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE `PREFIX_cart_rule_product_rule_group` (
|
||||||
|
`id_product_rule_group` int(10) unsigned NOT NULL auto_increment,
|
||||||
`id_cart_rule` int(10) unsigned NOT NULL,
|
`id_cart_rule` int(10) unsigned NOT NULL,
|
||||||
`quantity` int(10) unsigned NOT NULL default 1,
|
`quantity` int(10) unsigned NOT NULL default 1,
|
||||||
`type` ENUM('products', 'categories', 'attributes') NOT NULL,
|
PRIMARY KEY (`id_product_rule_group`)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE `PREFIX_cart_rule_product_rule` (
|
||||||
|
`id_product_rule` int(10) unsigned NOT NULL auto_increment,
|
||||||
|
`id_product_rule_group` int(10) unsigned NOT NULL,
|
||||||
|
`type` ENUM('products', 'categories', 'attributes', 'manufacturers', 'suppliers') NOT NULL,
|
||||||
PRIMARY KEY (`id_product_rule`)
|
PRIMARY KEY (`id_product_rule`)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -30,3 +30,30 @@ CREATE TABLE `PREFIX_category_shop` (
|
|||||||
/* PHP:generate_root_category_for_multishop(); */;
|
/* PHP:generate_root_category_for_multishop(); */;
|
||||||
|
|
||||||
/* PHP:update_mailalerts_add_column_idshop(); */;
|
/* PHP:update_mailalerts_add_column_idshop(); */;
|
||||||
|
|
||||||
|
|
||||||
|
CREATE TABLE `PREFIX_cart_rule_manufacturer` (
|
||||||
|
`id_cart_rule` int(10) unsigned NOT NULL,
|
||||||
|
`id_manufacturer` int(10) unsigned NOT NULL,
|
||||||
|
PRIMARY KEY (`id_cart_rule`, `id_manufacturer`)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE `PREFIX_cart_rule_supplier` (
|
||||||
|
`id_cart_rule` int(10) unsigned NOT NULL,
|
||||||
|
`id_supplier` int(10) unsigned NOT NULL,
|
||||||
|
PRIMARY KEY (`id_cart_rule`, `id_supplier`)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE `PREFIX_cart_rule_product_rule_group` (
|
||||||
|
`id_product_rule_group` int(10) unsigned NOT NULL auto_increment,
|
||||||
|
`id_cart_rule` int(10) unsigned NOT NULL,
|
||||||
|
`quantity` int(10) unsigned NOT NULL default 1,
|
||||||
|
PRIMARY KEY (`id_product_rule_group`)
|
||||||
|
);
|
||||||
|
|
||||||
|
INSERT INTO `PREFIX_cart_rule_product_rule_group` (`id_product_rule_group`, `id_cart_rule`, `quantity`) (
|
||||||
|
SELECT `id_cart_rule`, `id_cart_rule`, `quantity` FROM `PREFIX_cart_rule_product_rule`
|
||||||
|
);
|
||||||
|
|
||||||
|
ALTER TABLE `PREFIX_cart_rule_product_rule` CHANGE `id_cart_rule` `id_product_rule_group` int(10) unsigned NOT NULL;
|
||||||
|
ALTER TABLE `PREFIX_cart_rule_product_rule` CHANGE `type` ENUM('products', 'categories', 'attributes', 'manufacturers', 'suppliers') NOT NULL;
|
||||||
|
|||||||
Reference in New Issue
Block a user