From ab5edcd2d19cd0dfcb9c602802ff702aa6df56e9 Mon Sep 17 00:00:00 2001 From: mDeflotte Date: Thu, 1 Dec 2011 16:34:20 +0000 Subject: [PATCH] // Allow / Disallow multishipping --- .../admin/AdminPreferencesController.php | 7 ++++ controllers/front/CartController.php | 9 ++++ themes/prestashop/js/cart-summary.js | 15 ++++--- themes/prestashop/order-address.tpl | 42 ++++++++++--------- themes/prestashop/shopping-cart.tpl | 4 +- 5 files changed, 51 insertions(+), 26 deletions(-) diff --git a/controllers/admin/AdminPreferencesController.php b/controllers/admin/AdminPreferencesController.php index b1b8e96fe..07829e205 100644 --- a/controllers/admin/AdminPreferencesController.php +++ b/controllers/admin/AdminPreferencesController.php @@ -165,6 +165,13 @@ class AdminPreferencesControllerCore extends AdminController 'list' => $order_process_type, 'identifier' => 'value' ), + 'PS_ALLOW_MULTISHIPPING' => array( + 'title' => $this->l('Allow multi-shipping'), + 'desc' => $this->l('Allow the customer to ship is order to multiple addressed or in to deliver the products "in stock" first. This option will transform the customer cart in one or more orders.'), + 'validation' => 'isBool', + 'cast' => 'intval', + 'type' => 'bool' + ), 'PS_REGISTRATION_PROCESS_TYPE' => array( 'title' => $this->l('Registration process type'), 'desc' => $this->l('The "Only account creation" step register process allows the customer to register faster, and create his address later.'), diff --git a/controllers/front/CartController.php b/controllers/front/CartController.php index cee94f8b0..2745b994c 100644 --- a/controllers/front/CartController.php +++ b/controllers/front/CartController.php @@ -117,6 +117,9 @@ class CartControllerCore extends FrontController protected function processChangeProductAddressDelivery() { + if (!Configuration::get('PS_ALLOW_MULTISHIPPING')) + return; + $old_id_address_delivery = (int)Tools::getValue('old_id_address_delivery'); $new_id_address_delivery = (int)Tools::getValue('new_id_address_delivery'); @@ -129,6 +132,9 @@ class CartControllerCore extends FrontController protected function processAllowSeperatedPackage() { + if (!Configuration::get('PS_ALLOW_MULTISHIPPING')) + return; + if (Tools::getValue('value') === false) die('{"error":true, "error_message": "No value setted"}'); @@ -139,6 +145,9 @@ class CartControllerCore extends FrontController protected function processDuplicateProduct() { + if (!Configuration::get('PS_ALLOW_MULTISHIPPING')) + return; + if ( !$this->context->cart->duplicateProduct( $this->id_product, diff --git a/themes/prestashop/js/cart-summary.js b/themes/prestashop/js/cart-summary.js index bb06677d8..28283b886 100644 --- a/themes/prestashop/js/cart-summary.js +++ b/themes/prestashop/js/cart-summary.js @@ -109,7 +109,8 @@ function changeAddressDelivery(obj) updateHookShoppingCart(jsonData.HOOK_SHOPPING_CART); updateHookShoppingCartExtra(jsonData.HOOK_SHOPPING_CART_EXTRA); if (jsonData.carriers != null) - getCarrierListAndUpdate(); + if (typeof(getCarrierListAndUpdate) != 'undefined') + getCarrierListAndUpdate(); // @todo reverse the remove order // This effect remove the current line, but it's better to remove the other one, and refresshing this one @@ -299,7 +300,8 @@ function deleteProductFromSummary(id) updateHookShoppingCartExtra(jsonData.HOOK_SHOPPING_CART_EXTRA); updateCustomizedDatas(jsonData.customizedDatas); if (jsonData.carriers != null) - getCarrierListAndUpdate(); + if (typeof(getCarrierListAndUpdate) != 'undefined') + getCarrierListAndUpdate(); } }, error: function(XMLHttpRequest, textStatus, errorThrown) {alert("TECHNICAL ERROR: unable to save update quantity \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);} @@ -349,7 +351,8 @@ function upQuantity(id, qty) updateHookShoppingCart(jsonData.HOOK_SHOPPING_CART); updateHookShoppingCartExtra(jsonData.HOOK_SHOPPING_CART_EXTRA); if (jsonData.carriers != null) - getCarrierListAndUpdate(); + if (typeof(getCarrierListAndUpdate) != 'undefined') + getCarrierListAndUpdate(); } }, error: function(XMLHttpRequest, textStatus, errorThrown) {alert("TECHNICAL ERROR: unable to save update quantity \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);} @@ -408,7 +411,8 @@ function downQuantity(id, qty) updateHookShoppingCart(jsonData.HOOK_SHOPPING_CART); updateHookShoppingCartExtra(jsonData.HOOK_SHOPPING_CART_EXTRA); if (jsonData.carriers != null) - getCarrierListAndUpdate(); + if (typeof(getCarrierListAndUpdate) != 'undefined') + getCarrierListAndUpdate(); } }, error: function(XMLHttpRequest, textStatus, errorThrown) {alert("TECHNICAL ERROR: unable to save update quantity \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);} @@ -635,7 +639,8 @@ $(document).ready(function() { +'&token='+static_token, success: function(jsonData) { - getCarrierListAndUpdate(); + if (typeof(getCarrierListAndUpdate) != 'undefined') + getCarrierListAndUpdate(); } }); }); diff --git a/themes/prestashop/order-address.tpl b/themes/prestashop/order-address.tpl index 21b241e6c..df4314339 100644 --- a/themes/prestashop/order-address.tpl +++ b/themes/prestashop/order-address.tpl @@ -164,7 +164,7 @@ {include file="$tpl_dir./order-steps.tpl"} {include file="$tpl_dir./errors.tpl"} - {if !$multi_shipping} + {if !$multi_shipping && {Configuration::get('PS_ALLOW_MULTISHIPPING')}}
{l s='Multi-shipping'}
@@ -176,26 +176,28 @@ {/if}
{else} -
-
-
{l s='Multi-shipping'}
-
- + {if {Configuration::get('PS_ALLOW_MULTISHIPPING')}} +
+
+
{l s='Multi-shipping'}
+
+ +
+ +
+
- -
- -
+ {/if}
{/if} diff --git a/themes/prestashop/shopping-cart.tpl b/themes/prestashop/shopping-cart.tpl index 767c9d02f..14bf49ceb 100644 --- a/themes/prestashop/shopping-cart.tpl +++ b/themes/prestashop/shopping-cart.tpl @@ -404,7 +404,9 @@

{if !$opc} {l s='Next'} » - {l s='Multi-shipping'} » + {if {Configuration::get('PS_ALLOW_MULTISHIPPING')}} + {l s='Multi-shipping'} » + {/if} {/if} « {l s='Continue shopping'}