Reputation: 183
I would like to check if the product is downloadable and has no weight so I can check it besides if the product isSaleable to solve a bug.
This is the check that I want to add condition to it
<?php if ($_product->isSaleable()): ?>
Upvotes: 0
Views: 760
Reputation: 52792
To determine if a product is a downloadable product, you have to check the type of the product. You can see how this is implemented in the internal admin panel widget, and should be able to adapt it to your own template:
if ($_product->isSaleable() && ($_product->getTypeId() == \Magento\Downloadable\Model\Product\Type::TYPE_DOWNLOADABLE)):
Upvotes: 1