Merge branch 'ticket-dropshipping'

This commit is contained in:
Marion Muszynski 2016-06-02 12:19:46 +02:00
commit f8aaf85d62
6 changed files with 66 additions and 3 deletions

View File

@ -424,6 +424,15 @@ class AdminPrivateSalesSales extends AdminTab {
</script>
<div class="clear"></div>
</div>';
echo '<label>'.$this->l('Livraison seulement en France :').'</label>
<div class="margin-form">
<div id="shipping_fr" style="float: left;">
<input name="shipping_fr" type="radio" value="0"'.($this->cursale!==NULL? ($this->cursale->shipping_fr==0? ' checked="checked"': ''):' checked="checked"').' /> '.$this->l('Non').'&nbsp;&nbsp;&nbsp;<input name="shipping_fr" type="radio" value="1"'.($this->cursale!==NULL && $this->cursale->shipping_fr==1?' checked="checked"': '').' /> '.$this->l('Oui').'
<sup> *</sup>
</div>
<div class="clear"></div>
</div>';
// }
// echo '<label>'.$this->l('Sale type:').'</label>
@ -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();

View File

@ -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(),

View File

@ -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) {
@ -38,6 +38,24 @@ class OrderController extends OrderControllerCore {
$removed = TRUE;
}
}
// shipping only in france
if($sale->shipping_fr == 1) {
// $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)) {
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');
}
}
}
if($removed === TRUE) {

View File

@ -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(40,45); // local
// $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 {

View File

@ -164,6 +164,16 @@
<h1>{l s='Addresses'}</h1>
{include file="$tpl_dir./errors.tpl"}
{if $smarty.get.onlyfr}
<div class="error">
<p>{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é.'}</p>
<ol>
{foreach from=$products_fr item=product key=key}
<li><a href="{$link->getPageLink('order.php', true)}">{$product['name']}</a></li>
{/foreach}
</ol>
</div>
{/if}
{if $smarty.get.domtom || $smarty.get.canaries}
<div class="error">
<p>{l s='There is'} {l s='error'} :</p>

View File

@ -162,6 +162,16 @@
{include file="$tpl_dir./order-steps.tpl"}
{include file="$tpl_dir./errors.tpl"}
{if $smarty.get.onlyfr}
<div class="error">
<p>{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é.'}</p>
<ol>
{foreach from=$products_fr item=product key=key}
<li><a href="{$link->getPageLink('order.php', true)}">{$product['name']}</a></li>
{/foreach}
</ol>
</div>
{/if}
{if $smarty.get.domtom || $smarty.get.canaries}
<div class="error">
<p>{l s='There is'} {l s='error'} :</p>