shopware - 将类添加到缺货变体
问题描述
我需要将 CSS 类添加到缺货的变体中,这样我就可以事先知道哪个变体有库存或没有库存。
我一直在检查详细信息页面(特别是 buy_container.tpl 文件),看看那里是否有线索。我使用 var dump 检查$sArticle.sConfigurator但它没有说明其中一个变体是否缺货。我还检查了$sArticle.instock和$sArticle.isAvailable但由于详细信息页面使用 ajax 重新加载数据,这些变量仅在选择缺货变体后才起作用,我需要事先知道哪个变体缺货.
这是我需要添加 CSS 类的地方:
{foreach $sConfigurator.values as $configValue}
{if !{config name=hideNoInstock} || ({config name=hideNoInstock} && $configValue.selectable)}
<div class="variant--option {if $outofstock}OUT-OF-STOCK{/if} {if $configValue.selected}variant-selected{/if}">
<input type="radio"
class="option--input"
{if $configValue.selected} checked="checked"{/if}
value="{$configValue.optionID}"
name="group[{$sConfigurator.groupID}]"
{if $theme.ajaxVariantSwitch}
data-ajax-select-variants="true"{else}
data-auto-submit="true"{/if} />
{$configValue.optionname}{if $configValue.upprice} {if $configValue.upprice > 0}{/if}{/if}
</div>
{/if}
{/foreach}
任何线索将不胜感激,谢谢。
解决方案
尝试使用选择配置器。使用此配置器,此信息将可用。参见:https ://github.com/shopware/shopware/blob/5.5/themes/Frontend/Bare/frontend/detail/config_variant.tpl#L31
没有其他配置器将提供此数据。当您想使用其他配置器时,您需要自己实现这样的变量/函数。
推荐阅读
- javascript - JS中console.log('any string or statement'+ object)和console.log('any string or statement', object)的区别?
- php - 具有基本 php 形式的 DropzoneJs
- angularjs - 如何使用 && 显示 ng-checked 条件
- javascript - javascript - 发送了 2 个承诺,第二个承诺的结果排在第一位 - 如何处理?
- c# - 如何在 C# 中正确反序列化 JSON
- google-cloud-platform - BigQueryIO - 尽管有 CreateDisposition.CREATE_IF_NEEDED,但只能创建第一天表
- python - Python3,word2vec,如何在我的模型中获取关于“价格”的相似度排名列表
- event-handling - 如何在父 Svelte 组件中使用事件委托
- c - strtok 不返回任何值
- microsoft-graph-api - Microsoft Graph API - 获取订阅问题