Prestashop:How 是否在产品有货或缺货(允许订购)时显示默认标签?

Prestashop:How to show a default label either if the product is in stock that out of stock (allowed to order)?

我使用的是 prestashop 1.6,我需要在可用数量附近显示一个标签,告诉用户该产品可用,或者当数量设置为 0 时,可以订购。

Prestashop 已经做到了这一点,前提是您为商店中的每个产品一个接一个地设置这两条消息。我只需要所有产品的默认消息。

我找到了 product.tpl 这个代码:

    <!-- availability or doesntExist -->
    <p {if !$PS_STOCK_MANAGEMENT || ($product->quantity <= 0 && !$product->available_later && $allow_oosp) || ($product->quantity > 0 && !$product->available_now) || !$product->available_for_order || $PS_CATALOG_MODE} style="display: none;"{/if}>
        {*<span id="availability_label">{l s='Availability:'}</span>*}
        <span id="availability_value" class="label{if $product->quantity <= 0 && !$allow_oosp} label-danger{elseif $product->quantity <= 0} label-warning{else} label-success{/if}">{if $product->quantity <= 0}{if $PS_STOCK_MANAGEMENT && $allow_oosp}{$product->available_later}{else}{l s='FANCULO'}{/if}{elseif $PS_STOCK_MANAGEMENT}{$product->available_now}{/if}</span>
    </p>

我认为可以做到这一点,但我真的不明白如何编辑它以显示每种情况的默认值,也许可以利用 class 标签

提前致谢

试试这个代码:

<!-- availability or doesntExist -->
<p id="availability_statut"{if !$PS_STOCK_MANAGEMENT || ($product->quantity <= 0 && !$product->available_later && $allow_oosp) || ($product->quantity > 0 && !$product->available_now) || !$product->available_for_order || $PS_CATALOG_MODE} style="display: none;"{/if}>
                <span id="availability_value" class="label{if $product->quantity <= 0 && !$allow_oosp} label-danger{elseif $product->quantity <= 0} label-warning{else} label-success{/if}">
                    {if $product->quantity <= 0}
                        {if $PS_STOCK_MANAGEMENT && $allow_oosp}
                            {l s='product available later'}
                        {else}
                            {l s='This product is no longer in stock'}
                        {/if}
                    {elseif $PS_STOCK_MANAGEMENT}
                        {l s='available for order'}
                    {/if}
                </span>
            </p>

干杯:)