user2175784
user2175784

Reputation: 183

How to check if the product is downloadable?

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

Answers (1)

MatsLindh
MatsLindh

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

Related Questions