2016-10-25 10:56:15 +02:00
|
|
|
<?php
|
|
|
|
require_once(dirname(__FILE__).'/../../config/config.inc.php');
|
|
|
|
require_once(dirname(__FILE__).'/../../init.php');
|
|
|
|
|
|
|
|
global $cookie;
|
|
|
|
|
|
|
|
$langs = Language::getLanguages();
|
|
|
|
$lang = (int) $cookie->id_lang;
|
|
|
|
$isolang = Language::getIsoById($lang);
|
|
|
|
$errors = array();
|
|
|
|
if ($cookie->isLogged() && Tools::getValue('id_order')) {
|
|
|
|
$order = new Order((int)Tools::getValue('id_order'));
|
|
|
|
$link = new Link();
|
|
|
|
if (Validate::isLoadedObject($order)) {
|
|
|
|
$products = $order->getProducts();
|
|
|
|
$productList = '';
|
|
|
|
foreach ($products as $key => $product) {
|
|
|
|
$p = new Product((int)$product['product_id'], false, $lang);
|
|
|
|
if (isset($product['product_attribute_id']) AND (int)($product['product_attribute_id'])) {
|
|
|
|
$image = Db::getInstance()->getRow('
|
|
|
|
SELECT id_image
|
|
|
|
FROM '._DB_PREFIX_.'product_attribute_image
|
|
|
|
WHERE id_product_attribute = '.(int)($product['product_attribute_id']));
|
2016-11-02 17:03:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((isset($product['product_id']) AND (int)($product['product_id'])) || !$image) {
|
2016-10-25 10:56:15 +02:00
|
|
|
$image = Db::getInstance()->getRow('
|
|
|
|
SELECT id_image
|
|
|
|
FROM '._DB_PREFIX_.'image
|
|
|
|
WHERE id_product = '.(int)($product['product_id']).' AND cover = 1');
|
|
|
|
}
|
|
|
|
$product_img_path = $link->getImageLink($p->link_rewrite, (int)$image['id_image'], 'small');
|
2017-09-25 17:58:47 +02:00
|
|
|
$productList .= '<p>';
|
|
|
|
$productList .= '<input type="checkbox" class="productreturn" name="id_products[]" value="'.$product['product_id'].'_'.$product['product_attribute_id'].'" id="product_'.$product['product_id'].'_'.$product['product_attribute_id'].'"/>';
|
|
|
|
$productList .= '<label for="product_'.$product['product_id'].'_'.$product['product_attribute_id'].'">'.((isset($product_img_path))?'<img src="'.$product_img_path.'" /> ':'').' '.$product['product_name'].'</label>';
|
|
|
|
$productList .= '</p>';
|
|
|
|
|
|
|
|
// Add quantity selector
|
|
|
|
if ($product['product_quantity'] > 0) {
|
|
|
|
$productList.= '<p id="product_'.$product['product_id'].'_'.$product['product_attribute_id'].'_qty" class="hidden">Quantité: <select style="width:auto;" name="product_'.$product['product_id'].'_'.$product['product_attribute_id'].'_qty">';
|
|
|
|
for($i=1; $i<=$product['product_quantity']; $i++) {
|
|
|
|
$productList.= '<option value="'.$i.'">'.$i.'</option>';
|
|
|
|
}
|
|
|
|
$productList.= '</select></p>';
|
|
|
|
}
|
2016-10-25 10:56:15 +02:00
|
|
|
}
|
|
|
|
if(!empty($productList)) {
|
|
|
|
header('Content-Type: text/json');
|
|
|
|
die(json_encode(array("error"=> 'false',"result" => $productList)));
|
|
|
|
} else {
|
|
|
|
header('Content-Type: text/json');
|
|
|
|
die(json_encode(array("error"=> 'true')));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|