[*] BO: Add free shipping to BackOffice Order
This commit is contained in:
@@ -150,7 +150,31 @@
|
||||
useCart($(this).attr('rel'));
|
||||
return false;
|
||||
});
|
||||
|
||||
$('#free_shipping').click(function() {
|
||||
var free_shipping = 0;
|
||||
if (this.checked)
|
||||
free_shipping = 1;
|
||||
$.ajax({
|
||||
type:"POST",
|
||||
url: "{$link->getAdminLink('AdminCarts')}",
|
||||
async: true,
|
||||
dataType: "json",
|
||||
data : {
|
||||
ajax: "1",
|
||||
token: "{getAdminToken tab='AdminCarts'}",
|
||||
tab: "AdminCarts",
|
||||
action: "updateFreeShipping",
|
||||
id_cart: id_cart,
|
||||
id_customer: id_customer,
|
||||
'free_shipping': free_shipping
|
||||
},
|
||||
success : function(res)
|
||||
{
|
||||
displaySummary(res);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('.duplicate_order').live('click', function(e) {
|
||||
e.preventDefault();
|
||||
duplicateOrder($(this).attr('rel'));
|
||||
@@ -669,9 +693,14 @@
|
||||
$('#carrier_recycled_package').attr('checked', true);
|
||||
else
|
||||
$('#carrier_recycled_package').removeAttr('checked');
|
||||
if (jsonSummary.free_shipping)
|
||||
$('#free_shipping').attr('checked', true);
|
||||
else
|
||||
$('#free_shipping').removeAttr('checked');
|
||||
|
||||
$('#gift_message').html(jsonSummary.cart.gift_message);
|
||||
if(!changed_shipping_price)
|
||||
$('#shipping_price').val(jsonSummary.summary.total_shipping);
|
||||
$('#shipping_price').html('<b>'+jsonSummary.summary.total_shipping+'</b>');
|
||||
shipping_price_selected_carrier = jsonSummary.summary.total_shipping;
|
||||
|
||||
$('#total_vouchers').html(jsonSummary.summary.total_discounts_tax_exc);
|
||||
@@ -1116,8 +1145,11 @@
|
||||
</select>
|
||||
</p>
|
||||
<p>
|
||||
<label for="shipping_price">{l s='Shipping price:'}</label> <input type="text" id="shipping_price" name="shipping_price" size="7" /> <span class="currency_sign"></span>
|
||||
<a class="button" href="#" onclick="resetShippingPrice();return false;">{l s='Reset shipping price'}</a>
|
||||
<label for="shipping_price">{l s='Shipping price:'}</label> <span id="shipping_price" name="shipping_price"></span> <span class="currency_sign"></span>
|
||||
</p>
|
||||
<p>
|
||||
<label for="free_shipping">{l s='Free shipping:'}</label>
|
||||
<input type="checkbox" id="free_shipping" name="free_shipping" value="1" />
|
||||
</p>
|
||||
</div>
|
||||
<div id="float:left;">
|
||||
|
||||
@@ -91,6 +91,8 @@ abstract class PaymentModuleCore extends Module
|
||||
|
||||
if (!$shop)
|
||||
$shop = Context::getContext()->shop;
|
||||
if (!$this->active)
|
||||
die(Tools::displayError());
|
||||
// Does order already exists ?
|
||||
if (Validate::isLoadedObject($cart) && $cart->OrderExists() == false)
|
||||
{
|
||||
|
||||
@@ -415,6 +415,7 @@ class AdminCartsControllerCore extends AdminController
|
||||
echo Tools::jsonEncode($this->ajaxReturnVars());
|
||||
}
|
||||
}
|
||||
|
||||
public function ajaxProcessDuplicateOrder()
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
@@ -444,7 +445,38 @@ class AdminCartsControllerCore extends AdminController
|
||||
echo Tools::jsonEncode($this->ajaxReturnVars());
|
||||
}
|
||||
}
|
||||
|
||||
public function ajaxProcessupdateFreeShipping()
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
{
|
||||
if (!$id_cart_rule = CartRule::getIdByCode('BO_ORDER_'.(int)$this->context->cart->id))
|
||||
{
|
||||
$cart_rule = new CartRule();
|
||||
$cart_rule->code = 'BO_ORDER_'.(int)$this->context->cart->id;
|
||||
$cart_rule->name = array(Configuration::get('PS_LANG_DEFAULT') => $this->l('Free Shipping'));
|
||||
$cart_rule->id_customer = (int)$this->context->cart->id_customer;
|
||||
$cart_rule->free_shipping = true;
|
||||
$cart_rule->quantity = 1;
|
||||
$cart_rule->quantity_per_user = 1;
|
||||
$cart_rule->minimum_amount_currency = (int)$this->context->cart->id_currency;
|
||||
$cart_rule->reduction_currency = (int)$this->context->cart->id_currency;
|
||||
$cart_rule->date_from = date('Y-m-d H:i:s', time());
|
||||
$cart_rule->date_to = date('Y-m-d H:i:s', time() + 24 * 36000);
|
||||
$cart_rule->active = 1;
|
||||
$cart_rule->add();
|
||||
}
|
||||
else
|
||||
$cart_rule = new CartRule((int)$id_cart_rule);
|
||||
|
||||
$this->context->cart->removeCartRule((int)$cart_rule->id);
|
||||
if (Tools::getValue('free_shipping'))
|
||||
$this->context->cart->addCartRule((int)$cart_rule->id);
|
||||
|
||||
echo Tools::jsonEncode($this->ajaxReturnVars());
|
||||
}
|
||||
}
|
||||
|
||||
public function ajaxProcessAddVoucher()
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
@@ -617,7 +649,8 @@ class AdminCartsControllerCore extends AdminController
|
||||
'link_order' => $this->context->link->getPageLink(
|
||||
'order', false,
|
||||
(int)$this->context->cart->id_lang,
|
||||
'step=3&recover_cart='.$id_cart.'&token_cart='.md5(_COOKIE_KEY_.'recover_cart_'.$id_cart))
|
||||
'step=3&recover_cart='.$id_cart.'&token_cart='.md5(_COOKIE_KEY_.'recover_cart_'.$id_cart)),
|
||||
'free_shipping' => (bool)CartRule::getIdByCode('BO_ORDER_'.(int)$this->context->cart->id)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user