I need to get the EAN13 code for the combination that the user selects on the product page.
I generated a PS module and hooked it to hookdisplayProductAdditionalInfo. In the module PHP file, I can only get an array with EAN13 codes for all the product combinations.
$product = new Product((int)Tools::getValue('id_product'));
$id_lang = Context::getContext()->language->id;
$combinations = $product->getAttributeCombinations((int)$id_lang, true);
foreach ($combinations as $c)
{
printf ($c['ean13']);
}
The code above prints all the EAN13 codes. I need to get only the EAN13 for the combination that the user selected/is seeing. Every time the user changes the combination, I need to refresh and get the current EAN13.
The reason is that I'm sending the product code through API to an external server in order to get warehouses stocks and display on the screen.