Merge branch 'ticket-AideContact-SAV' into develop

This commit is contained in:
Marion Muszynski 2016-10-25 10:57:06 +02:00
commit 44f108491f

View File

@ -0,0 +1,41 @@
<?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']));
} elseif (isset($product['product_id']) AND (int)($product['product_id'])) {
$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')));
}
}
}