I’ve been building a Magento 2 template however I’ve hit a roadblock with the way I’m pulling the prices. The prices are being pulled correctly for simple products by using the following (simplified as I’m exploding the variable to split the string):
$price = $product->getPrice();
<p><?php echo $price; ?></p>
Due to Magento 2 changing the way it processes the prices of configurable products, the price is being outputted as 0.00 for configurables and not pulling the price of the simple products that are attached to it. This was to be expected because I’m not telling it to pull the price of the simple products.
What’s the best way for me to get the prices of the simple products? There’s a size dropdown on the configurable so ideally, the price would change depending on which product you click on in the dropdown.
Due to me having to explode the price string, I can’t just call the block in the XML file either unless I write an overkill jQuery script to split the string on the browser…
Thanks!
2
Answers
in your block phtml file you can just use
it should show you final price,it work with simple and bundle products
Try this code it will help you.