I am using a module which uses product_mini_ID-IMAGE, and when any product does not have attributes/combinations, the product image ID looks like that: product_mini_608_0.jpg
, but when the product has attributes, then product image ID looks like that: product_mini_608_567.jpg
.
I will be happy if anyone could help me to resolve that problem.
orderInfo += '<tr><td><img src="../img/tmp/product_mini_'+datos.products[i].product_id+''+datos.img_path+'_0.jpg?time='+datos.random+'" height="45" width="45"></td><td>'+datos.products[i].product_name+' ('+datos.products[i].product_reference+' '+datos.products[i].product_supplier_reference+')</td><td>'+datos.products[i].product_quantity+'</td><td>'+ps_round(datos.products[i].unit_price_tax_incl,2)+datos.currency+'</td><td>'+ps_round(datos.products[i].total_price_tax_incl,2)+datos.currency+'</td></tr>';
Second id is product_attribute_id.
These images are for use in orders. In each order, the "Product Attribute Code" is also specified.
Try to test the presence or absence of an id_product_attribute before, try this piece of code:
if (isset(datos.products[i].product_attribute_id)) {
var imgProd = '../img
/tmp/product_mini_'+datos.products[i].product_id+''+datos.img_path+'_'+datos.products[i].product_attribute_id+'.jpg';
} else {
var imgProd = '../img/tmp/product_mini_'+datos.products[i].product_id+''+datos.img_path+'_0.jpg';
}
orderInfo += '<tr><td><img src="../img/tmp/product_mini_'+imgProd+'?time='+datos.random+'" height="45" width="45"></td><td>'+datos.products[i].product_name+' ('+datos.products[i].product_reference+' '+datos.products[i].product_supplier_reference+')</td><td>'+datos.products[i].product_quantity+'</td><td>'+ps_round(datos.products[i].unit_price_tax_incl,2)+datos.currency+'</td><td>'+ps_round(datos.products[i].total_price_tax_incl,2)+datos.currency+'</td></tr>';