diff --git a/classes/Cart.php b/classes/Cart.php index 303db7e78..f757d1274 100644 --- a/classes/Cart.php +++ b/classes/Cart.php @@ -3128,15 +3128,36 @@ class CartCore extends ObjectModel } /** + * @param bool $ignore_virtual Ignore virtual product + * @param bool $exclusive If true, the validation is exclusive : it must be present product in stock and out of stock * @since 1.5.0 + * * @return bool false is some products from the cart are out of stock */ - public function isAllProductsInStock() + public function isAllProductsInStock($ignore_virtual = false, $exclusive = false) { + $product_out_of_stock = 0; + $product_in_stock = 0; foreach ($this->getProducts() as $product) { - if ((int)$product['quantity_available'] <= 0) - return false; + if (!$exclusive) + { + if ((int)$product['quantity_available'] <= 0 + && (!$ignore_virtual || !$product['is_virtual'])) + return false; + } + else + { + if ((int)$product['quantity_available'] <= 0 + && (!$ignore_virtual || !$product['is_virtual'])) + $product_out_of_stock++; + if ((int)$product['quantity_available'] > 0 + && (!$ignore_virtual || !$product['is_virtual'])) + $product_in_stock++; + + if ($product_in_stock > 0 && $product_out_of_stock > 0) + return false; + } } return true; } diff --git a/controllers/front/ParentOrderController.php b/controllers/front/ParentOrderController.php index 3c2372455..30d3bc881 100644 --- a/controllers/front/ParentOrderController.php +++ b/controllers/front/ParentOrderController.php @@ -292,6 +292,9 @@ class ParentOrderControllerCore extends FrontController else $product['is_discounted'] = $product['price_without_specific_price'] != $product['price_wt']; } + + $show_option_allow_sparate_package = !$this->context->cart->isAllProductsInStock(true) + && Configuration::get('PS_SHIP_WHEN_AVAILABLE'); $this->context->smarty->assign($summary); $this->context->smarty->assign(array( @@ -310,6 +313,8 @@ class ParentOrderControllerCore extends FrontController 'currencyRate' => $this->context->currency->conversion_rate, 'currencyFormat' => $this->context->currency->format, 'currencyBlank' => $this->context->currency->blank, + 'show_option_allow_sparate_package' => $show_option_allow_sparate_package, + )); $this->context->smarty->assign(array( diff --git a/themes/default/lang/fr.php b/themes/default/lang/fr.php index 0eab0ada4..a470d1aca 100644 --- a/themes/default/lang/fr.php +++ b/themes/default/lang/fr.php @@ -727,6 +727,8 @@ $_LANG['shopping-cart_2fb3b950fd7711136f7f251ae5fbdbdc'] = 'Texte n°'; $_LANG['shopping-cart_ec211f7c20af43e742bf2570c3cb84f9'] = 'Ajouter'; $_LANG['shopping-cart_1d9baf077ee87921f57a8fe42d510b65'] = 'Enlever'; $_LANG['shopping-cart_f2a6c498fb90ee345d997f888fce3b18'] = 'Supprimer'; +$_LANG['shopping-cart_6faae4c39a8a0fc5020af4137f641c8e'] = 'Envoyer les produits disponibles en premier.'; +$_LANG['shopping-cart_3afd72d3691b9b3fd17e36c4863bb63b'] = 'Je tiens à préciser une adresse de livraison pour chaque produit commandé.'; $_LANG['shopping-cart_af0f5bdc5be121b9307687aeeae38c17'] = 'Adresse de livraison'; $_LANG['shopping-cart_601d8c4b9f72fc1862013c19b677a499'] = 'Adresse de facturation'; $_LANG['shopping-cart_10ac3d04253ef7e1ddc73e6091c0cd55'] = 'Suivant'; diff --git a/themes/default/shopping-cart.tpl b/themes/default/shopping-cart.tpl index c4df8268d..7fab80c76 100644 --- a/themes/default/shopping-cart.tpl +++ b/themes/default/shopping-cart.tpl @@ -313,17 +313,17 @@ -{if !$cart->isAllProductsInStock() && Configuration::get('PS_SHIP_WHEN_AVAILABLE')} +{if $show_option_allow_sparate_package}

allow_seperated_package}checked="checked"{/if} /> - +

{/if} {if !$opc} - {if Configuration::get('PS_SHIP_WHEN_AVAILABLE')} + {if Configuration::get('PS_ALLOW_MULTISHIPPING')}

- +

{/if} {/if}