Merge branch 'development' of https://github.com/PrestaShop/PrestaShop into development
This commit is contained in:
+1
-1
@@ -1451,7 +1451,7 @@ class ProductCore extends ObjectModel
|
||||
}
|
||||
|
||||
if (count($id_shop_list))
|
||||
$combination->id_shop_list = $id_shop_list;
|
||||
$combination->id_shop_list = array_unique($id_shop_list);
|
||||
|
||||
$combination->add();
|
||||
|
||||
|
||||
+1
-1
@@ -984,7 +984,7 @@ class ToolsCore
|
||||
|
||||
if (function_exists('mb_strtolower'))
|
||||
$str = mb_strtolower($str, 'utf-8');
|
||||
elseif (!$allow_accented_chars)
|
||||
if (!$allow_accented_chars)
|
||||
$str = Tools::replaceAccentedChars($str);
|
||||
|
||||
// Remove all non-whitelist chars.
|
||||
|
||||
@@ -239,17 +239,14 @@ class HelperCore
|
||||
|
||||
$html .= '
|
||||
<div class="category-filter">
|
||||
<span><a href="#" id="collapse_all" >'.$translations['Collapse All'].'</a>
|
||||
| </span>
|
||||
<span><a href="#" id="expand_all" >'.$translations['Expand All'].'</a>
|
||||
<span><a href="#" id="collapse_all">'.$translations['Collapse All'].'</a>| </span>
|
||||
<span><a href="#" id="expand_all">'.$translations['Expand All'].'</a>| </span>
|
||||
'.(!$use_radio ? '
|
||||
|</span>
|
||||
<span> <a href="#" id="check_all" >'.$translations['Check All'].'</a>
|
||||
|</span>
|
||||
<span><a href="#" id="uncheck_all" >'.$translations['Uncheck All'].'</a>|</span>
|
||||
' : '').($use_search ? '<span>'.$translations['search'].' : <input type="text" name="search_cat" id="search_cat"></span>' : '').'
|
||||
</div>
|
||||
';
|
||||
<span><a href="#" id="check_all">'.$translations['Check All'].'</a>| </span>
|
||||
<span><a href="#" id="uncheck_all">'.$translations['Uncheck All'].'</a>| </span>' : '')
|
||||
.($use_search ? '
|
||||
<span>'.$translations['search'].': <input type="text" name="search_cat" id="search_cat"/></span>' : '')
|
||||
.'</div>';
|
||||
|
||||
$home_is_selected = false;
|
||||
foreach ($selected_cat as $cat)
|
||||
|
||||
@@ -124,7 +124,7 @@ class HelperListCore extends Helper
|
||||
// Append when we get a syntax error in SQL query
|
||||
if ($list === false)
|
||||
{
|
||||
$this->displayWarning($this->l('Bad SQL query', 'Helper'));
|
||||
$this->context->controller->warnings[] = $this->l('Bad SQL query', 'Helper');
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ class OrderHistoryCore extends ObjectModel
|
||||
'id_order' => (int)$order->id
|
||||
));
|
||||
|
||||
if (Validate::isLoadedObject($order) && ($old_os instanceof OrderState) && ($new_os instanceof OrderState))
|
||||
if (Validate::isLoadedObject($order) && ($new_os instanceof OrderState))
|
||||
{
|
||||
// An email is sent the first time a virtual item is validated
|
||||
$virtual_products = $order->getVirtualProducts();
|
||||
@@ -160,108 +160,109 @@ class OrderHistoryCore extends ObjectModel
|
||||
if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT'))
|
||||
$manager = StockManagerFactory::getManager();
|
||||
// foreach products of the order
|
||||
foreach ($order->getProductsDetail() as $product)
|
||||
{
|
||||
// if becoming logable => adds sale
|
||||
if ($new_os->logable && !$old_os->logable)
|
||||
if (Validate::isLoadedObject($old_os))
|
||||
foreach ($order->getProductsDetail() as $product)
|
||||
{
|
||||
ProductSale::addProductSale($product['product_id'], $product['product_quantity']);
|
||||
// @since 1.5.0 - Stock Management
|
||||
if (!Pack::isPack($product['product_id']) &&
|
||||
($old_os->id == Configuration::get('PS_OS_ERROR') || $old_os->id == Configuration::get('PS_OS_CANCELED')) &&
|
||||
!StockAvailable::dependsOnStock($product['id_product'], (int)$order->id_shop))
|
||||
StockAvailable::updateQuantity($product['product_id'], $product['product_attribute_id'], -(int)$product['product_quantity'], $order->id_shop);
|
||||
}
|
||||
// if becoming unlogable => removes sale
|
||||
elseif (!$new_os->logable && $old_os->logable)
|
||||
{
|
||||
ProductSale::removeProductSale($product['product_id'], $product['product_quantity']);
|
||||
|
||||
// @since 1.5.0 - Stock Management
|
||||
if (!Pack::isPack($product['product_id']) &&
|
||||
($new_os->id == Configuration::get('PS_OS_ERROR') || $new_os->id == Configuration::get('PS_OS_CANCELED')) &&
|
||||
!StockAvailable::dependsOnStock($product['id_product']))
|
||||
StockAvailable::updateQuantity($product['product_id'], $product['product_attribute_id'], (int)$product['product_quantity'], $order->id_shop);
|
||||
}
|
||||
// if waiting for payment => payment error/canceled
|
||||
elseif (!$new_os->logable && !$old_os->logable &&
|
||||
($new_os->id == Configuration::get('PS_OS_ERROR') || $new_os->id == Configuration::get('PS_OS_CANCELED')) &&
|
||||
!StockAvailable::dependsOnStock($product['id_product']))
|
||||
StockAvailable::updateQuantity($product['product_id'], $product['product_attribute_id'], (int)$product['product_quantity'], $order->id_shop);
|
||||
// @since 1.5.0 : if the order is being shipped and this products uses the advanced stock management :
|
||||
// decrements the physical stock using $id_warehouse
|
||||
if ($new_os->shipped == 1 && $old_os->shipped == 0 &&
|
||||
Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') &&
|
||||
Warehouse::exists($product['id_warehouse']) &&
|
||||
$manager != null &&
|
||||
((int)$product['advanced_stock_management'] == 1 || Pack::usesAdvancedStockManagement($product['product_id'])))
|
||||
{
|
||||
// gets the warehouse
|
||||
$warehouse = new Warehouse($product['id_warehouse']);
|
||||
|
||||
// decrements the stock (if it's a pack, the StockManager does what is needed)
|
||||
$manager->removeProduct(
|
||||
$product['product_id'],
|
||||
$product['product_attribute_id'],
|
||||
$warehouse,
|
||||
$product['product_quantity'],
|
||||
Configuration::get('PS_STOCK_CUSTOMER_ORDER_REASON'),
|
||||
true,
|
||||
(int)$order->id
|
||||
);
|
||||
}
|
||||
// @since.1.5.0 : if the order was shipped, and is not anymore, we need to restock products
|
||||
elseif ($new_os->shipped == 0 && $old_os->shipped == 1 &&
|
||||
Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') &&
|
||||
Warehouse::exists($product['id_warehouse']) &&
|
||||
$manager != null &&
|
||||
((int)$product['advanced_stock_management'] == 1 || Pack::usesAdvancedStockManagement($product['product_id'])))
|
||||
{
|
||||
// if the product is a pack, we restock every products in the pack using the last negative stock mvts
|
||||
if (Pack::isPack($product['product_id']))
|
||||
// if becoming logable => adds sale
|
||||
if ($new_os->logable && !$old_os->logable)
|
||||
{
|
||||
$pack_products = Pack::getItems($product['product_id'], Configuration::get('PS_LANG_DEFAULT', null, null, $order->id_shop));
|
||||
foreach ($pack_products as $pack_product)
|
||||
ProductSale::addProductSale($product['product_id'], $product['product_quantity']);
|
||||
// @since 1.5.0 - Stock Management
|
||||
if (!Pack::isPack($product['product_id']) &&
|
||||
($old_os->id == Configuration::get('PS_OS_ERROR') || $old_os->id == Configuration::get('PS_OS_CANCELED')) &&
|
||||
!StockAvailable::dependsOnStock($product['id_product'], (int)$order->id_shop))
|
||||
StockAvailable::updateQuantity($product['product_id'], $product['product_attribute_id'], -(int)$product['product_quantity'], $order->id_shop);
|
||||
}
|
||||
// if becoming unlogable => removes sale
|
||||
elseif (!$new_os->logable && $old_os->logable)
|
||||
{
|
||||
ProductSale::removeProductSale($product['product_id'], $product['product_quantity']);
|
||||
|
||||
// @since 1.5.0 - Stock Management
|
||||
if (!Pack::isPack($product['product_id']) &&
|
||||
($new_os->id == Configuration::get('PS_OS_ERROR') || $new_os->id == Configuration::get('PS_OS_CANCELED')) &&
|
||||
!StockAvailable::dependsOnStock($product['id_product']))
|
||||
StockAvailable::updateQuantity($product['product_id'], $product['product_attribute_id'], (int)$product['product_quantity'], $order->id_shop);
|
||||
}
|
||||
// if waiting for payment => payment error/canceled
|
||||
elseif (!$new_os->logable && !$old_os->logable &&
|
||||
($new_os->id == Configuration::get('PS_OS_ERROR') || $new_os->id == Configuration::get('PS_OS_CANCELED')) &&
|
||||
!StockAvailable::dependsOnStock($product['id_product']))
|
||||
StockAvailable::updateQuantity($product['product_id'], $product['product_attribute_id'], (int)$product['product_quantity'], $order->id_shop);
|
||||
// @since 1.5.0 : if the order is being shipped and this products uses the advanced stock management :
|
||||
// decrements the physical stock using $id_warehouse
|
||||
if ($new_os->shipped == 1 && $old_os->shipped == 0 &&
|
||||
Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') &&
|
||||
Warehouse::exists($product['id_warehouse']) &&
|
||||
$manager != null &&
|
||||
((int)$product['advanced_stock_management'] == 1 || Pack::usesAdvancedStockManagement($product['product_id'])))
|
||||
{
|
||||
// gets the warehouse
|
||||
$warehouse = new Warehouse($product['id_warehouse']);
|
||||
|
||||
// decrements the stock (if it's a pack, the StockManager does what is needed)
|
||||
$manager->removeProduct(
|
||||
$product['product_id'],
|
||||
$product['product_attribute_id'],
|
||||
$warehouse,
|
||||
$product['product_quantity'],
|
||||
Configuration::get('PS_STOCK_CUSTOMER_ORDER_REASON'),
|
||||
true,
|
||||
(int)$order->id
|
||||
);
|
||||
}
|
||||
// @since.1.5.0 : if the order was shipped, and is not anymore, we need to restock products
|
||||
elseif ($new_os->shipped == 0 && $old_os->shipped == 1 &&
|
||||
Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') &&
|
||||
Warehouse::exists($product['id_warehouse']) &&
|
||||
$manager != null &&
|
||||
((int)$product['advanced_stock_management'] == 1 || Pack::usesAdvancedStockManagement($product['product_id'])))
|
||||
{
|
||||
// if the product is a pack, we restock every products in the pack using the last negative stock mvts
|
||||
if (Pack::isPack($product['product_id']))
|
||||
{
|
||||
if ($pack_product->advanced_stock_management == 1)
|
||||
$pack_products = Pack::getItems($product['product_id'], Configuration::get('PS_LANG_DEFAULT', null, null, $order->id_shop));
|
||||
foreach ($pack_products as $pack_product)
|
||||
{
|
||||
$mvts = StockMvt::getNegativeStockMvts($order->id, $pack_product->id, 0, $pack_product->pack_quantity * $product['product_quantity']);
|
||||
foreach ($mvts as $mvt)
|
||||
if ($pack_product->advanced_stock_management == 1)
|
||||
{
|
||||
$manager->addProduct(
|
||||
$pack_product->id,
|
||||
0,
|
||||
new Warehouse($mvt['id_warehouse']),
|
||||
$mvt['physical_quantity'],
|
||||
null,
|
||||
$mvt['price_te'],
|
||||
true
|
||||
);
|
||||
$mvts = StockMvt::getNegativeStockMvts($order->id, $pack_product->id, 0, $pack_product->pack_quantity * $product['product_quantity']);
|
||||
foreach ($mvts as $mvt)
|
||||
{
|
||||
$manager->addProduct(
|
||||
$pack_product->id,
|
||||
0,
|
||||
new Warehouse($mvt['id_warehouse']),
|
||||
$mvt['physical_quantity'],
|
||||
null,
|
||||
$mvt['price_te'],
|
||||
true
|
||||
);
|
||||
}
|
||||
if (!StockAvailable::dependsOnStock($product['id_product']))
|
||||
StockAvailable::updateQuantity($pack_product->id, 0, (int)$pack_product->pack_quantity * $product['product_quantity'], $order->id_shop);
|
||||
}
|
||||
if (!StockAvailable::dependsOnStock($product['id_product']))
|
||||
StockAvailable::updateQuantity($pack_product->id, 0, (int)$pack_product->pack_quantity * $product['product_quantity'], $order->id_shop);
|
||||
}
|
||||
}
|
||||
// else, it's not a pack, re-stock using the last negative stock mvts
|
||||
else
|
||||
{
|
||||
$mvts = StockMvt::getNegativeStockMvts($order->id, $product['product_id'], $product['product_attribute_id'], $product['product_quantity']);
|
||||
foreach ($mvts as $mvt)
|
||||
{
|
||||
$manager->addProduct(
|
||||
$product['product_id'],
|
||||
$product['product_attribute_id'],
|
||||
new Warehouse($mvt['id_warehouse']),
|
||||
$mvt['physical_quantity'],
|
||||
null,
|
||||
$mvt['price_te'],
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
// else, it's not a pack, re-stock using the last negative stock mvts
|
||||
else
|
||||
{
|
||||
$mvts = StockMvt::getNegativeStockMvts($order->id, $product['product_id'], $product['product_attribute_id'], $product['product_quantity']);
|
||||
foreach ($mvts as $mvt)
|
||||
{
|
||||
$manager->addProduct(
|
||||
$product['product_id'],
|
||||
$product['product_attribute_id'],
|
||||
new Warehouse($mvt['id_warehouse']),
|
||||
$mvt['physical_quantity'],
|
||||
null,
|
||||
$mvt['price_te'],
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->id_order_state = (int)$new_order_state;
|
||||
|
||||
Reference in New Issue
Block a user