43 lines
2.1 KiB
PHP
43 lines
2.1 KiB
PHP
<?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']));
|
|
}
|
|
|
|
if ((isset($product['product_id']) AND (int)($product['product_id'])) || !$image) {
|
|
$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');
|
|
$productList .= '<p><input type="checkbox" name="id_products[]" value="'.$product['product_id'].'_'.$product['product_attribute_id'].'" id="product_'.$product['product_id'].'_'.$product['product_attribute_id'].'"/><label for="product_'.$product['product_id'].'_'.$product['product_attribute_id'].'">'.((isset($product_img_path))?'<img src="'.$product_img_path.'" /> ':'').' '.$product['product_name'].'</label></p>';
|
|
}
|
|
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')));
|
|
}
|
|
}
|
|
} |