[*] BO : #PSTEST-381 - Checkbox "Send available products first" must not be present if there is only product "out of stock", or to check states of virtual products
This commit is contained in:
+24
-3
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -313,17 +313,17 @@
|
||||
</table>
|
||||
</div>
|
||||
|
||||
{if !$cart->isAllProductsInStock() && Configuration::get('PS_SHIP_WHEN_AVAILABLE')}
|
||||
{if $show_option_allow_sparate_package}
|
||||
<p>
|
||||
<input type="checkbox" name="allow_seperated_package" id="allow_seperated_package" {if $cart->allow_seperated_package}checked="checked"{/if} />
|
||||
<label for="allow_seperated_package">{l s="Send the available products first"}</label>
|
||||
<label for="allow_seperated_package">{l s='Send the available products first'}</label>
|
||||
</p>
|
||||
{/if}
|
||||
{if !$opc}
|
||||
{if Configuration::get('PS_SHIP_WHEN_AVAILABLE')}
|
||||
{if Configuration::get('PS_ALLOW_MULTISHIPPING')}
|
||||
<p>
|
||||
<input type="checkbox" {if $multi_shipping}checked="checked"{/if} id="enable-multishipping" />
|
||||
<label for="enable-multishipping">{l s="I want to specify a delivery address for each products ordered."}</label>
|
||||
<label for="enable-multishipping">{l s='I want to specify a delivery address for each products ordered.'}</label>
|
||||
</p>
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
Reference in New Issue
Block a user