I use this extension https://github.com/emizentech/magento2-call-for-price to hide price and replace it with a string like call us for a quote, it works fine at this point but when I try to add sample file by mark the product as has no weight and check is downloadable add sample file (pdf file), the string (call us for a quote) disappear. I think that the problem is the if statement condition includes only isSaleable product, I need to include other condition that the product has no weight and is downloadble
public function wrapResult($ html) { if($ this->getSaleableItem()->getCallforpriceText()==''): return '<div class="price-box ' . $ this->getData('css_classes') . '" ' . 'data-role="priceBox" ' . 'data-product-id="' . $ this->getSaleableItem()->getId() . '"' . '>' . $ html . '</div>'; else : return '<div class="price-box "><span>'.$ this->getSaleableItem()->getCallforpriceText().'</span></div>'; endif; }
and
<!--call for price condition--> <?php if($ _product->getCallforpriceText()==''):?> <?php if ($ _product->isSaleable()|| $ product->getWeight() == ): ?> <?php $ postParams = $ block->getAddToCartPostParams($ _product); ?> <form data-role="tocart-form" action="<?php /* @escapeNotVerified */ echo $ postParams['action']; ?>" method="post"> <input type="hidden" name="product" value="<?php /* @escapeNotVerified */ echo $ postParams['data']['product']; ?>"> <input type="hidden" name="<?php /* @escapeNotVerified */ echo Action::PARAM_NAME_URL_ENCODED; ?>" value="<?php /* @escapeNotVerified */ echo $ postParams['data'][Action::PARAM_NAME_URL_ENCODED]; ?>"> <?php echo $ block->getBlockHtml('formkey')?> <button type="submit" title="<?php echo $ block->escapeHtml(__('Add to Cart')); ?>" class="action tocart primary"> <span><?php /* @escapeNotVerified */ echo __('Add to Cart') ?></span> </button> </form> <?php else: ?> <?php if ($ _product->getIsSalable()): ?> <div class="stock available"><span><?php /* @escapeNotVerified */ echo __('In stock') ?></span></div> <?php else: ?> <div class="stock unavailable"><span><?php /* @escapeNotVerified */ echo __('Out of stock') ?></span></div> <?php endif; ?> <?php endif; ?> <?php endif; ?> </div>