thepixelage/craft-productlabels

产品标签是用于创建产品标签的Craft Commerce插件

4.0.6 2022-08-26 00:57 UTC

This package is auto-updated.

Last update: 2024-09-26 05:38:09 UTC


README

Product Labels icon

Craft CMS的产品标签插件

产品标签是用于管理产品促销标签的Craft Commerce插件。

许可证

此插件需要通过Craft Plugin Store购买的商业许可证。

要求

此插件需要Craft CMS 4.0.0或更高版本和Craft Commerce 4.0.0或更高版本。

安装

您可以从插件商店或使用Composer安装此插件。

从插件商店

转到项目控制面板中的插件商店,搜索“产品标签”,然后在其模态窗口中点击“安装”按钮。

使用Composer

打开您的终端,并在项目目录中运行以下命令

# tell Composer to load the plugin
composer require thepixelage/craft-productlabels

# tell Craft to install the plugin
./craft install/plugin productlabels

设置

您可以通过转到产品标签 > 设置并配置字段布局来自定义产品标签的字段布局,就像对条目做的那样。

管理产品标签

产品标签附带一组设置字段,用于控制产品标签何时显示

产品销售条件规则

产品销售条件规则可用于指定产品应匹配的一组销售。

产品条件规则

产品条件规则可用于指定要匹配的一组产品。如果您需要一种指定不通过类别或其他属性相关联的产品列表的方法,这将很有用。

显示产品标签

此插件向产品元素类型添加了productLabels属性,该属性返回一个包含适用于产品的有效ProductLabel的数组。一旦查询到产品标签列表,就可以像显示条目一样显示它。

使用Twig的示例

{% set products = craft.products.all() %}
{% for product in products %}
    <h1>{{ product.title }}</h1>
    {% for label in product.productLabels %}
        {{ label.myCustomField }}
    {% endfor %}
{% endfor %}

使用GraphQL的示例

{
  products {
    title
    productLabels {
      title
      ... on ProductLabel {
        myCustomField
      }
    }
  }
}

ThePixelAge创建