64 lines
2.2 KiB
PHP
64 lines
2.2 KiB
PHP
<?php
|
|
class Order extends OrderCore
|
|
{
|
|
/**
|
|
* Get order products
|
|
*
|
|
* @return array Products with price, quantity (with taxe and without)
|
|
*/
|
|
public function getProducts($products = false, $selected_products = false, $selected_qty = false)
|
|
{
|
|
if (!$products) {
|
|
$products = $this->getProductsDetail();
|
|
}
|
|
|
|
$customized_datas = Product::getAllCustomizedDatas($this->id_cart);
|
|
|
|
$result_array = array();
|
|
foreach ($products as $row) {
|
|
// Change qty if selected
|
|
if ($selected_qty) {
|
|
$row['product_quantity'] = 0;
|
|
foreach ($selected_products as $key => $id_product) {
|
|
if ($row['id_order_detail'] == $id_product) {
|
|
$row['product_quantity'] = (int)$selected_qty[$key];
|
|
}
|
|
}
|
|
if (!$row['product_quantity']) {
|
|
continue;
|
|
}
|
|
}
|
|
|
|
$this->setProductImageInformations($row);
|
|
$this->setProductCurrentStock($row);
|
|
|
|
// Backward compatibility 1.4 -> 1.5
|
|
$this->setProductPrices($row);
|
|
|
|
$this->setProductCustomizedDatas($row, $customized_datas);
|
|
|
|
// Add information for virtual product
|
|
if ($row['download_hash'] && !empty($row['download_hash'])) {
|
|
$row['filename'] = ProductDownload::getFilenameFromIdProduct((int)$row['product_id']);
|
|
// Get the display filename
|
|
$row['display_filename'] = ProductDownload::getFilenameFromFilename($row['filename']);
|
|
}
|
|
|
|
$row['id_address_delivery'] = $this->id_address_delivery;
|
|
|
|
if (isset($row['id_configurator']) && $row['id_configurator'] > 0) {
|
|
$row['configurator_opt'] = ConfiguratorStorage::getOptProductFlatten($row['id_configurator']);
|
|
}
|
|
|
|
/* Stock product */
|
|
$result_array[(int)$row['id_order_detail']] = $row;
|
|
}
|
|
|
|
if ($customized_datas) {
|
|
Product::addCustomizationPrice($result_array, $customized_datas);
|
|
}
|
|
|
|
return $result_array;
|
|
}
|
|
}
|