diff --git a/modules/privatesales/models/SaleCore.php b/modules/privatesales/models/SaleCore.php index 94ff7a61..85ce6134 100644 --- a/modules/privatesales/models/SaleCore.php +++ b/modules/privatesales/models/SaleCore.php @@ -996,18 +996,20 @@ class SaleCore extends ObjectModel{ $sales = self::getSalesByIdProduct((int)$id_product); if (is_array($sales)) { foreach ($sales as $sale) { - if ($sale instanceof SaleCore && !$sale->otherdelay) { - if ($date_delivery === null) { - $date_delivery = $sale->date_shipping; - } - elseif ($date_delivery < $sale->date_shipping) { - $date_delivery = $sale->date_shipping; - } - } - else { - $delivery_date_range = self::DATE_RANGE_OTHER_DELAY; - break; - } + if ($sale instanceof SaleCore && $sale->isOpen()) { + if (!$sale->otherdelay) { + if ($date_delivery === null) { + $date_delivery = $sale->date_shipping; + } + elseif ($date_delivery < $sale->date_shipping) { + $date_delivery = $sale->date_shipping; + } + } + else { + $delivery_date_range = self::DATE_RANGE_OTHER_DELAY; + break; + } + } } } @@ -1035,7 +1037,6 @@ class SaleCore extends ObjectModel{ $date_range = SaleCore::DATE_RANGE_UNKNOWN; $products = $cart->getProducts(); - $sale = new SaleCore(); if (is_array($products)) { diff --git a/modules/privatesales/privatesales.php b/modules/privatesales/privatesales.php index e4e502fc..99458037 100644 --- a/modules/privatesales/privatesales.php +++ b/modules/privatesales/privatesales.php @@ -468,9 +468,16 @@ class Privatesales extends Module { Tools::redirect( $url . (strpos($url, '?') ? '&' : '?' ) . $redirect_string ); } + $cart_rules = $this->context->cart->getCartRules(); $products = $this->context->cart->getProducts(); $deletedprod = 0; foreach ($products as $product){ + foreach ($cart_rules as $cart_rule) { + if ($cart_rule['gift_product'] === $product['id_product']) { + continue(2); + } + } + $id_category = (int)$product['id_category_default']; $privatesale = SaleCore::loadSaleFromCategoryId($id_category, (int) $this->context->cookie->id_lang); if ($privatesale) { @@ -493,6 +500,7 @@ class Privatesales extends Module { } } } + if (!$privatesale) continue; if( strtotime($privatesale->date_start) > time() || strtotime($privatesale->date_end) < time() || !$privatesale->active || count(array_intersect( diff --git a/override/classes/Cart.php b/override/classes/Cart.php index 2b13a5e3..64a7e283 100644 --- a/override/classes/Cart.php +++ b/override/classes/Cart.php @@ -808,13 +808,13 @@ class Cart extends CartCore $count = 0; foreach ($this->getProducts() as $product) { $sale = SaleCore::getSaleByIdProduct($product['id_product']); - if ($sale) { + if ($sale && $sale->isOpen()) { if ($sale->otherdelay){ $otherdelay[$sale->id_privatesales] = $sale->otherdelay_title[1]; $title = $sale->otherdelay_title[1]; } + $count++; } - $count++; } if ($force_return_otherdelay && !empty($title)) { diff --git a/pdf/invoice.tpl b/pdf/invoice.tpl index fc0652d1..c6e7951d 100755 --- a/pdf/invoice.tpl +++ b/pdf/invoice.tpl @@ -199,12 +199,12 @@ {foreach $cart_rules as $cart_rule} {cycle values='#FFF,#DDD' assign=bgcolor} - {$cart_rule.name} - + {$cart_rule.name} + {if $tax_excluded_display} - - {$cart_rule.value_tax_excl} + - {displayPrice currency=$order->id_currency price=$cart_rule.value_tax_excl} {else} - - {$cart_rule.value} + - {displayPrice currency=$order->id_currency price=$cart_rule.value} {/if}