Someone knows how to get qty for each simple product of configurable product via javascript in product page?
It seems that spConfig
retrieved with
#product_addtocart_form": {
"configurable": {
"spConfig": <?php /* @escapeNotVerified */ echo $block->getJsonConfig() ?>
}
}
hasn't data about qty.
I have to retrieve it with custom code or do you have some hints on how to find qty information?
Best Answer
Thx to @Amit Bera for hints, here my answer.
Override
\Magento\ConfigurableProduct\Model\ConfigurableAttributeData
and extendsgetAttributeOptionsData()
addingqty
field:Now in
\app\code\xxx\yyy\view\frontend\templates\product\view\type\options\configurable.phtml
you could retrieve simple product qty with simple js: