/** * 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(); } $order = new Order($this->id_order); $customized_datas = Product::getAllCustomizedDatas($order->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); $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'] = $order->id_address_delivery; /* Ecotax */ $round_mode = $order->round_mode; $row['ecotax_tax_excl'] = $row['ecotax']; // alias for coherence $row['ecotax_tax_incl'] = $row['ecotax'] * (100 + $row['ecotax_tax_rate']) / 100; $row['ecotax_tax'] = $row['ecotax_tax_incl'] - $row['ecotax_tax_excl']; if ($round_mode == Order::ROUND_ITEM) { $row['ecotax_tax_incl'] = Tools::ps_round($row['ecotax_tax_incl'], _PS_PRICE_COMPUTE_PRECISION_, $round_mode); } $row['total_ecotax_tax_excl'] = $row['ecotax_tax_excl'] * $row['product_quantity']; $row['total_ecotax_tax_incl'] = $row['ecotax_tax_incl'] * $row['product_quantity']; $row['total_ecotax_tax'] = $row['total_ecotax_tax_incl'] - $row['total_ecotax_tax_excl']; foreach (array('ecotax_tax_excl', 'ecotax_tax_incl', 'ecotax_tax', 'total_ecotax_tax_excl', 'total_ecotax_tax_incl', 'total_ecotax_tax') as $ecotax_field) { $row[$ecotax_field] = Tools::ps_round($row[$ecotax_field], _PS_PRICE_COMPUTE_PRECISION_, $round_mode); } // Aliases $row['unit_price_tax_excl_including_ecotax'] = $row['unit_price_tax_excl']; $row['unit_price_tax_incl_including_ecotax'] = $row['unit_price_tax_incl']; $row['total_price_tax_excl_including_ecotax'] = $row['total_price_tax_excl']; $row['total_price_tax_incl_including_ecotax'] = $row['total_price_tax_incl']; /* Stock product */ $result_array[(int) $row['id_order_detail']] = $row; } if ($customized_datas) { Product::addCustomizationPrice($result_array, $customized_datas); } return $result_array; }
/** * Get order products * * @return array Products with price, quantity (with taxe and without) */ public function getProducts($products = false, $selectedProducts = false, $selectedQty = false) { if (!$products) { $products = $this->getProductsDetail(); } $resultArray = array(); foreach ($products as $row) { // Change qty if selected if ($selectedQty) { $row['product_quantity'] = 0; foreach ($selectedProducts as $key => $id_product) { if ($row['id_order_detail'] == $id_product) { $row['product_quantity'] = (int) $selectedQty[$key]; } } if (!$row['product_quantity']) { continue; } } $this->setProductPrices($row); /* Add information for virtual product */ if ($row['download_hash'] && !empty($row['download_hash'])) { $row['filename'] = ProductDownload::getFilenameFromIdProduct($row['product_id']); } /* Stock product */ $resultArray[(int) $row['id_order_detail']] = $row; } return $resultArray; }
/** * Get order products * * @return array Products with price, quantity (with taxe and without) */ public function getProducts($products = false, $selectedProducts = false, $selectedQty = false) { if (!$products) { $products = $this->getProductsDetail(); } //$customized_datas = Product::getAllCustomizedDatas($this->id_cart); $resultArray = array(); foreach ($products as $row) { //var_dump($row);die; // Change qty if selected if ($selectedQty) { $row['product_quantity'] = 0; foreach ($selectedProducts as $key => $id_product) { if ($row['id_order_detail'] == $id_product) { $row['product_quantity'] = (int) $selectedQty[$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; /* Stock product */ $resultArray[(int) $row['id_order_detail']] = $row; } /*if ($customized_datas) Product::addCustomizationPrice($resultArray, $customized_datas);*/ return $resultArray; }
/** * Get order products * * @return array Products with price, quantity (with taxe and without) */ public function getProducts($products = false, $selectedProducts = false, $selectedQty = false) { if (!$products) { $products = $this->getProductsDetail(); } $order = new Order($this->id_order); $customized_datas = Product::getAllCustomizedDatas($order->id_cart); $resultArray = array(); foreach ($products as $row) { // Change qty if selected if ($selectedQty) { $row['product_quantity'] = 0; foreach ($selectedProducts as $key => $id_product) { if ($row['id_order_detail'] == $id_product) { $row['product_quantity'] = (int) $selectedQty[$key]; } } if (!$row['product_quantity']) { continue; } } $this->setProductImageInformations($row); $this->setProductCurrentStock($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'] = $order->id_address_delivery; /* Translit product name */ //$row['translit_name'] = $this->translit($row['product_name'])."222"; if ($row['translit_name'] == "Война и мир") { $row['translit_name'] = "это война и мир"; } else { $row['translit_name'] = "это что-то другое"; } /* Stock product */ $resultArray[(int) $row['id_order_detail']] = $row; } if ($customized_datas) { Product::addCustomizationPrice($resultArray, $customized_datas); } return $resultArray; }
/** * Get order products * * @return array Products with price, quantity (with taxe and without) */ public function getProducts($products = false, $selectedProducts = false, $selectedQty = false) { if (!$products) { $products = $this->getProductsDetail(); } $resultArray = array(); foreach ($products as $k => $row) { // Change qty if selected if ($selectedQty) { $row['product_quantity'] = 0; foreach ($selectedProducts as $key => $id_product) { if ($row['id_order_detail'] == $id_product) { $row['product_quantity'] = intval($selectedQty[$key]); } } if (!$row['product_quantity']) { continue; } } $row['product_price_wt'] = number_format($row['product_price'] * (1 + $row['tax_rate'] * 0.01), 2, '.', ''); $row['total_wt'] = $row['product_quantity'] * $row['product_price_wt']; $row['total_price'] = number_format($row['total_wt'] / (1 + $row['tax_rate'] * 0.01), 2, '.', ''); $row['total_wt'] = number_format($row['total_wt'], 2, '.', ''); /* Add information for virtual product */ if ($row['download_hash'] and !empty($row['download_hash'])) { $row['filename'] = ProductDownload::getFilenameFromIdProduct($row['product_id']); } /* Stock product */ $resultArray[intval($row['id_order_detail'])] = $row; } return $resultArray; }
/** * Get order products * * @return array Products with price, quantity (with taxe and without) */ public function getProducts($products = false, $selectedProducts = false, $selectedQty = false) { if (!$products) { $products = $this->getProductsDetail(); } $resultArray = array(); foreach ($products as $k => $row) { // Change qty if selected if ($selectedQty) { $row['product_quantity'] = 0; foreach ($selectedProducts as $key => $id_product) { if ($row['id_order_detail'] == $id_product) { $row['product_quantity'] = intval($selectedQty[$key]); } } if (!$row['product_quantity']) { continue; } } if (Configuration::get('PS_1_3_2_UPDATE_DATE')) { if ($this->_taxCalculationMethod == PS_TAX_EXC) { $row['product_price'] = Tools::ps_round($row['product_price'], 2); } if ($this->_taxCalculationMethod == PS_TAX_INC) { $row['product_price_wt'] = Tools::ps_round($row['product_price'] * (1 + $row['tax_rate'] * 0.01), 2); } else { $row['product_price_wt'] = $row['product_price']; } if ($row['reduction_percent']) { $row['product_price_wt'] = Tools::ps_round($row['product_price_wt'] - $row['product_price_wt'] * ($row['reduction_percent'] * 0.01), 2); $row['product_price'] = $row['product_price'] - $row['product_price'] * ($row['reduction_percent'] * 0.01); } if ($row['reduction_amount']) { $row['product_price'] = $row['product_price'] - $row['reduction_amount']; if ($this->_taxCalculationMethod == PS_TAX_INC) { $row['product_price_wt'] = Tools::ps_round($row['product_price_wt'] - $row['reduction_amount'] * (1 + $row['tax_rate'] * 0.01), 2); } else { $row['product_price_wt'] = $row['product_price']; } } if (($row['reduction_percent'] or $row['reduction_amount']) and $this->_taxCalculationMethod == PS_TAX_EXC) { $row['product_price'] = Tools::ps_round($row['product_price'], 2); } $row['total_wt'] = $row['product_quantity'] * $row['product_price_wt']; $row['total_price'] = $row['product_quantity'] * $row['product_price_wt']; } else { $price = $row['product_price']; if ($this->_taxCalculationMethod == PS_TAX_EXC) { $price = Tools::ps_round($price, 2); } $row['product_price_wt'] = Tools::ps_round($price * (1 + $row['tax_rate'] * 0.01), 2); $row['total_wt'] = $row['product_quantity'] * $row['product_price_wt']; $row['total_price'] = $row['product_quantity'] * $row['product_price_wt']; } /* Add information for virtual product */ if ($row['download_hash'] and !empty($row['download_hash'])) { $row['filename'] = ProductDownload::getFilenameFromIdProduct($row['product_id']); } /* Stock product */ $resultArray[intval($row['id_order_detail'])] = $row; } return $resultArray; }