From d63a2d7d5ac775d4a825c9e31744a9e3ed152536 Mon Sep 17 00:00:00 2001 From: Marion Muszynski Date: Mon, 30 May 2016 15:42:20 +0200 Subject: [PATCH 1/4] addind field to config if delivery of sale is enabled only in fr --- modules/privatesales/AdminPrivateSalesSales.php | 11 +++++++++++ modules/privatesales/Sale.php | 5 +++++ override/controllers/OrderController.php | 8 ++++++++ override/controllers/ParentOrderController.php | 11 ++++++++++- themes/site/order-address.tpl | 8 ++++++++ 5 files changed, 42 insertions(+), 1 deletion(-) diff --git a/modules/privatesales/AdminPrivateSalesSales.php b/modules/privatesales/AdminPrivateSalesSales.php index ba2df11a..88368248 100755 --- a/modules/privatesales/AdminPrivateSalesSales.php +++ b/modules/privatesales/AdminPrivateSalesSales.php @@ -424,6 +424,15 @@ class AdminPrivateSalesSales extends AdminTab {
'; + + echo ' +
+
+ cursale!==NULL? ($this->cursale->shipping_fr==0? ' checked="checked"': ''):' checked="checked"').' /> '.$this->l('Non').'   cursale!==NULL && $this->cursale->shipping_fr==1?' checked="checked"': '').' /> '.$this->l('Oui').' + * +
+
+
'; // } // echo ' @@ -771,6 +780,7 @@ class AdminPrivateSalesSales extends AdminTab { $sale->pub = Tools::getValue('pub', 0); $sale->id_category = Tools::getValue('id_category', Configuration::get('PRIVATESALES_ROOT')); $sale->id_employee = (int) Tools::getValue('id_employee'); + $sale->shipping_fr = (int) Tools::getValue('shipping_fr'); $sale->delivery_delay = (int) Tools::getValue('delivery_delay'); $sale->sale_type = array(); $sale->versions = array(); @@ -843,6 +853,7 @@ class AdminPrivateSalesSales extends AdminTab { $sale->forward_news = Tools::getValue('forward_news', 0); $sale->id_category = Tools::getValue('id_category', Configuration::get('PRIVATESALES_ROOT')); $sale->id_employee = (int) Tools::getValue('id_employee'); + $sale->shipping_fr = (int) Tools::getValue('shipping_fr'); $sale->delivery_delay = (int) Tools::getValue('delivery_delay'); $sale->sale_type = array(); $sale->description = array(); diff --git a/modules/privatesales/Sale.php b/modules/privatesales/Sale.php index a3727773..a082f6db 100755 --- a/modules/privatesales/Sale.php +++ b/modules/privatesales/Sale.php @@ -17,6 +17,7 @@ class Sale { var $forward_news = 0; var $id_category; var $id_employee = 0; + var $shipping_fr = 0; var $title = array(); var $alias = array(); var $groups = array(); @@ -42,6 +43,7 @@ class Sale { $this->forward_news = $sale['forward_news']; $this->id_category = $sale['id_category']; $this->id_employee = $sale['id_employee']; + $this->shipping_fr = $sale['shipping_fr']; $this->title = $sale['title']; $this->alias = $sale['alias']; $this->groups = $sale['groups']; @@ -94,6 +96,7 @@ class Sale { `public` = '.(int) $this->pub.', `id_category` = '.(int) $this->id_category.', `id_employee` = '.(int) $this->id_employee.', + `shipping_fr` = '.(int) $this->shipping_fr.', `delivery_delay` = '.(int) $this->delivery_delay.', `date_upd` = NOW() WHERE `id_sale` = '.(int) $this->id.' @@ -188,6 +191,7 @@ class Sale { '.(int) $this->forward_news.', '.(int) $this->id_category.', '.(int) $this->id_employee.', + '.(int) $this->shipping_fr.', NOW(), '.(int) $this->sale_type.', '.(int) $this->delivery_delay.', @@ -324,6 +328,7 @@ class Sale { 'position' => $ps[0]['position'], 'id_category' => $ps[0]['id_category'], 'id_employee' => $ps[0]['id_employee'], + 'shipping_fr' => $ps[0]['shipping_fr'], 'delivery_delay' => $ps[0]['delivery_delay'], 'sale_type' => array(), 'title' => array(), diff --git a/override/controllers/OrderController.php b/override/controllers/OrderController.php index 7a507fb9..325e1578 100755 --- a/override/controllers/OrderController.php +++ b/override/controllers/OrderController.php @@ -38,6 +38,14 @@ class OrderController extends OrderControllerCore { $removed = TRUE; } } + // shipping only in france + if ($this->step > 1){ + $delivery = new Address(self::$cart->id_address_delivery); + if($sale->shipping_fr == 1 && $delivery->id_country != 8 && !Tools::getValue('ajax')) { + $this->step = 1; + Tools::redirect('order.php?step=1&onlyfr=1'); + } + } } if($removed === TRUE) { diff --git a/override/controllers/ParentOrderController.php b/override/controllers/ParentOrderController.php index 151b8206..e61e1073 100755 --- a/override/controllers/ParentOrderController.php +++ b/override/controllers/ParentOrderController.php @@ -58,10 +58,14 @@ class ParentOrderController extends ParentOrderControllerCore { $_carriers = array(); $_sales = array(); $carrier_uniq = array(); + $shipping_only_athome = false; foreach ($cart_products as $key => $cart_product) { $sale = Sale::getSaleFromCategory($cart_product['id_category_default']); if($sale) { $sale_carriers = $sale->getCarriers(); + if ($sale->shipping_fr == 1) { + $shipping_only_athome = true; + } $sale_delivery[] = $sale->delivery_delay; $_sales[(int)$sale->id] = $sale_carriers; if(count($sale_carriers) == 0) { @@ -165,9 +169,14 @@ class ParentOrderController extends ParentOrderControllerCore { $carriers_ah = array(); $carriers_ooh = array(); $config_carrier_ooh = array(88,89); // prod - // $config_carrier_ooh = array(47,48); // dev + $config_carrier_ooh = array(47,48); // dev // $config_carrier_ooh = array(40,45); // local foreach ($carriers as $carrier) { + // if($shipping_only_athome && $carrier['id_carrier'] != 87) { // prod + if($shipping_only_athome && $carrier['id_carrier'] != 45) { // dev + // if($shipping_only_athome && $carrier['id_carrier'] != 38) { // local + continue; + } if (in_array($carrier['id_carrier'], $config_carrier_ooh) ){ $carriers_ooh[] = $carrier; } else { diff --git a/themes/site/order-address.tpl b/themes/site/order-address.tpl index 00d7997e..fa046362 100755 --- a/themes/site/order-address.tpl +++ b/themes/site/order-address.tpl @@ -164,6 +164,14 @@

{l s='Addresses'}

{include file="$tpl_dir./errors.tpl"} +{if $smarty.get.onlyfr} +
+

{l s='There is an error'} :

+
    +
  1. {l s='Nous sommes désolé, un ou plusieurs produits de votre panier ne peuvent être livrés en dehors de la France. Nous nous excusons pour le désagrément causé'}
  2. +
+
+{/if} {if $smarty.get.domtom || $smarty.get.canaries}

{l s='There is'} {l s='error'} :

From 96ca86fe850f5cd251ac268cffead72f1f52fedb Mon Sep 17 00:00:00 2001 From: Marion Muszynski Date: Wed, 1 Jun 2016 10:57:31 +0200 Subject: [PATCH 2/4] modif error message --- override/controllers/OrderController.php | 19 ++++++++++++------- .../controllers/ParentOrderController.php | 4 ++-- themes/site/order-address.tpl | 6 ++++-- themes/site_mobile/order-address.tpl | 10 ++++++++++ 4 files changed, 28 insertions(+), 11 deletions(-) diff --git a/override/controllers/OrderController.php b/override/controllers/OrderController.php index 325e1578..c8c7d68d 100755 --- a/override/controllers/OrderController.php +++ b/override/controllers/OrderController.php @@ -30,7 +30,7 @@ class OrderController extends OrderControllerCore { if(Module::isInstalled('privatesales')) { $removed = FALSE; - + $products_only_fr = array(); foreach(self::$cart->getProducts() as $product) { if(($sale = Sale::getSaleFromCategory($product['id_category_default'])) !== NULL) { if($sale->isFinished() || !$sale->enabled) { @@ -39,12 +39,17 @@ class OrderController extends OrderControllerCore { } } // shipping only in france - if ($this->step > 1){ - $delivery = new Address(self::$cart->id_address_delivery); - if($sale->shipping_fr == 1 && $delivery->id_country != 8 && !Tools::getValue('ajax')) { - $this->step = 1; - Tools::redirect('order.php?step=1&onlyfr=1'); - } + if($sale->shipping_fr == 1) { + $products_only_fr[] = $product['name']; + self::$smarty->assign('products_fr',$products_only_fr); + } + } + + if (!empty($products_only_fr) && $this->step == 2) { + $delivery = new Address(self::$cart->id_address_delivery); + if ($delivery->id_country != 8 && !Tools::getValue('ajax')) { + $this->step = 1; + Tools::redirect('order.php?step=1&onlyfr=1'); } } diff --git a/override/controllers/ParentOrderController.php b/override/controllers/ParentOrderController.php index e61e1073..4857efd6 100755 --- a/override/controllers/ParentOrderController.php +++ b/override/controllers/ParentOrderController.php @@ -168,9 +168,9 @@ class ParentOrderController extends ParentOrderControllerCore { // distinction "at home" et "out of home" $carriers_ah = array(); $carriers_ooh = array(); - $config_carrier_ooh = array(88,89); // prod + // $config_carrier_ooh = array(88,89); // prod $config_carrier_ooh = array(47,48); // dev - // $config_carrier_ooh = array(40,45); // local + // $config_carrier_ooh = array(40,45); // local foreach ($carriers as $carrier) { // if($shipping_only_athome && $carrier['id_carrier'] != 87) { // prod if($shipping_only_athome && $carrier['id_carrier'] != 45) { // dev diff --git a/themes/site/order-address.tpl b/themes/site/order-address.tpl index fa046362..579495a5 100755 --- a/themes/site/order-address.tpl +++ b/themes/site/order-address.tpl @@ -166,9 +166,11 @@ {include file="$tpl_dir./errors.tpl"} {if $smarty.get.onlyfr}
-

{l s='There is an error'} :

+

{l s='Nous sommes désolé, un ou plusieurs produits de votre panier ne peuvent être livrés en dehors de la France. Nous nous excusons pour le désagrément causé'} :

    -
  1. {l s='Nous sommes désolé, un ou plusieurs produits de votre panier ne peuvent être livrés en dehors de la France. Nous nous excusons pour le désagrément causé'}
  2. + {foreach from=$products_fr item=product key=key} +
  3. {$product}
  4. + {/foreach}
{/if} diff --git a/themes/site_mobile/order-address.tpl b/themes/site_mobile/order-address.tpl index 4b024552..870e121d 100755 --- a/themes/site_mobile/order-address.tpl +++ b/themes/site_mobile/order-address.tpl @@ -162,6 +162,16 @@ {include file="$tpl_dir./order-steps.tpl"} {include file="$tpl_dir./errors.tpl"} +{if $smarty.get.onlyfr} +
+

{l s='Nous sommes désolé, un ou plusieurs produits de votre panier ne peuvent être livrés en dehors de la France. Nous nous excusons pour le désagrément causé'} :

+
    + {foreach from=$products_fr item=product key=key} +
  1. {$product}
  2. + {/foreach} +
+
+{/if} {if $smarty.get.domtom || $smarty.get.canaries}

{l s='There is'} {l s='error'} :

From 3e0ad8592dc91e7b0d8198c955c4bbe87e1d9549 Mon Sep 17 00:00:00 2001 From: Marion Muszynski Date: Wed, 1 Jun 2016 11:23:37 +0200 Subject: [PATCH 3/4] update link --- override/controllers/OrderController.php | 21 +++++++++++++-------- themes/site/order-address.tpl | 4 ++-- themes/site_mobile/order-address.tpl | 4 ++-- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/override/controllers/OrderController.php b/override/controllers/OrderController.php index c8c7d68d..fcc3a7d5 100755 --- a/override/controllers/OrderController.php +++ b/override/controllers/OrderController.php @@ -40,16 +40,21 @@ class OrderController extends OrderControllerCore { } // shipping only in france if($sale->shipping_fr == 1) { - $products_only_fr[] = $product['name']; - self::$smarty->assign('products_fr',$products_only_fr); + // $link = new Link(); + $products_only_fr[] = array( + 'name' => $product['name'].' - '.$sale->title[(int)self::$cart->id_lang], + //'link' => $link->getProductLink((int)$product['id_product'], $product['link_rewrite'], $product['category'], $product['ean13']) + ); } } - - if (!empty($products_only_fr) && $this->step == 2) { - $delivery = new Address(self::$cart->id_address_delivery); - if ($delivery->id_country != 8 && !Tools::getValue('ajax')) { - $this->step = 1; - Tools::redirect('order.php?step=1&onlyfr=1'); + if (!empty($products_only_fr)) { + self::$smarty->assign('products_fr',$products_only_fr); + if ($this->step == 2) { + $delivery = new Address(self::$cart->id_address_delivery); + if ($delivery->id_country != 8 && !Tools::getValue('ajax')) { + $this->step = 1; + Tools::redirect('order.php?step=1&onlyfr=1'); + } } } diff --git a/themes/site/order-address.tpl b/themes/site/order-address.tpl index 579495a5..291911d5 100755 --- a/themes/site/order-address.tpl +++ b/themes/site/order-address.tpl @@ -166,10 +166,10 @@ {include file="$tpl_dir./errors.tpl"} {if $smarty.get.onlyfr}
-

{l s='Nous sommes désolé, un ou plusieurs produits de votre panier ne peuvent être livrés en dehors de la France. Nous nous excusons pour le désagrément causé'} :

+

{l s='Nous sommes désolé, un ou plusieurs produits de votre panier ne peuvent être livrés en dehors de la France. Nous nous excusons pour le désagrément causé.'}

    {foreach from=$products_fr item=product key=key} -
  1. {$product}
  2. +
  3. {$product['name']}
  4. {/foreach}
diff --git a/themes/site_mobile/order-address.tpl b/themes/site_mobile/order-address.tpl index 870e121d..d1a5db52 100755 --- a/themes/site_mobile/order-address.tpl +++ b/themes/site_mobile/order-address.tpl @@ -164,10 +164,10 @@ {include file="$tpl_dir./errors.tpl"} {if $smarty.get.onlyfr}
-

{l s='Nous sommes désolé, un ou plusieurs produits de votre panier ne peuvent être livrés en dehors de la France. Nous nous excusons pour le désagrément causé'} :

+

{l s='Nous sommes désolé, un ou plusieurs produits de votre panier ne peuvent être livrés en dehors de la France. Nous nous excusons pour le désagrément causé.'}

    {foreach from=$products_fr item=product key=key} -
  1. {$product}
  2. +
  3. {$product['name']}
  4. {/foreach}
From 332ac320fba5389d4067fac3929e51f6dd13e894 Mon Sep 17 00:00:00 2001 From: Marion Muszynski Date: Thu, 2 Jun 2016 12:19:24 +0200 Subject: [PATCH 4/4] modif for prod --- override/controllers/ParentOrderController.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/override/controllers/ParentOrderController.php b/override/controllers/ParentOrderController.php index 4857efd6..a4b97830 100755 --- a/override/controllers/ParentOrderController.php +++ b/override/controllers/ParentOrderController.php @@ -168,12 +168,12 @@ class ParentOrderController extends ParentOrderControllerCore { // distinction "at home" et "out of home" $carriers_ah = array(); $carriers_ooh = array(); - // $config_carrier_ooh = array(88,89); // prod - $config_carrier_ooh = array(47,48); // dev + $config_carrier_ooh = array(88,89); // prod + // $config_carrier_ooh = array(47,48); // dev // $config_carrier_ooh = array(40,45); // local foreach ($carriers as $carrier) { - // if($shipping_only_athome && $carrier['id_carrier'] != 87) { // prod - if($shipping_only_athome && $carrier['id_carrier'] != 45) { // dev + if($shipping_only_athome && $carrier['id_carrier'] != 87) { // prod + // if($shipping_only_athome && $carrier['id_carrier'] != 45) { // dev // if($shipping_only_athome && $carrier['id_carrier'] != 38) { // local continue; }