フロントエンドの管理者で作成した2つのカスタム商品属性を条件文で表示します。Magento 2 phtmlファイルの条件文
最初はAvailability
、次はshipping_rate
です。
/vendor/magento/module-catalog/view/frontend/templates/product/view/type/default.phtml
これまで:
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
// @codingStandardsIgnoreFile
?>
<?php /* @var $block \Magento\Catalog\Block\Product\View\AbstractView */?>
<?php $_product = $block->getProduct() ?>
<?php if ($block->displayProductStockStatus()): ?>
<?php if ($_product->isAvailable()): ?>
<div class="stock available" title="<?php /* @escapeNotVerified */ echo __('Availability') ?>">
<span><?php /* @escapeNotVerified */ echo __('In stock') ?></span>
</div>
<span class="estimated-delivery">
<?php /* @escapeNotVerified */ if ($_product->getResource()->getAttribute('availability')->getValue($_product) != '0'): ?>
Livraison estimée dans <?php /* @escapeNotVerified */ echo $_product->getResource()->getAttribute('availability')->getFrontend()->getValue($_product); ?> jour(s)</span>
<?php endif; ?>
<span>Livraison à partir de <?php /* @escapeNotVerified */ echo $_product->getResource()->getAttribute('shipping_rate')->getFrontend()->getValue($_product); ?> €</span>
<?php else: ?>
<div class="stock unavailable" title="<?php /* @escapeNotVerified */ echo __('Availability') ?>">
<span><?php /* @escapeNotVerified */ echo __('Out of stock') ?></span>
</div>
<?php endif; ?>
<?php endif; ?>
私の問題されています
私はに位置defauproductページテンプレートを編集した 可用性があります均等l〜0、私は何かを表示したい、そしてそれが0と異なるとき、何か他のもの。これは古典的な条件文ですが、私は成功しません:S
これは私がやったことです、それは動作しませんでした。
<span class="estimated-delivery">
<?php /* @escapeNotVerified */ if ($_product->getResource()->getAttribute('availability')->getValue($_product) != '0'): ?>
Livraison estimée dans <?php /* @escapeNotVerified */ echo $_product->getResource()->getAttribute('availability')->getFrontend()->getValue($_product); ?> jour(s)</span>
<?php else ?>
Disponibilité: <strong>En Stock</strong> </span>
<?php endif; ?>
誰かがこの条件文を書くのを助けることができますか?自分の質問に答えるために
おかげ