简体   繁体   English

在Bigcommerce模具框架中的类别页面上显示色板颜色

[英]Show swatch-colors on category page in bigcommerce stencil framwork

Here is my website http://evisionshop.com/ 这是我的网站http://evisionshop.com/

I need suggestion related to the swatch color. 我需要有关色板颜色的建议。 How I can show the products attribute color into category page with each product below price. 如何将产品属性颜色显示在类别页面中,而每个产品的价格都低于价格。

below is the code of category page 以下是类别页面的代码

          <h3 class="product-item-name">{{name}}</h3>

                  <!---swatch--->
                 <div class="cat_item"></div>
                   <!---swatch--->

          <div class="product-item-price">
            {{#if price}}
              {{> components/product/price price=price show_savings=false schema_org=false}}
            {{/if}}
          </div>

and here is the code with the help the swatch colors showing on products details page 这是代码,并在产品详细信息页面上显示了样本颜色的帮助下

<div class="form-field form-field-options form-field-swatch{{#if required}} form-required{{/if}}"
  data-swatch-selector
  data-product-attribute="swatch">
  <div class="form-field-title">
    {{display_name}}
    <span class="swatch-value" data-swatch-value>{{lang 'forms.swatches_none_selected'}}</span>
    {{#if required}}<span class="required-text">{{lang 'common.required'}}</span>{{/if}}
  </div>

  <div class="form-field-control">
    {{#each values}}
      <label class="swatch-wrap" data-swatch-value="{{label}}" data-product-attribute-value="{{id}}">
        <span class="form-label-text">{{label}}</span>

        <input
          class="form-input swatch-radio"
          id="attribute-{{id}}"
          type="radio"
          name="attribute[{{../id}}]"
          value="{{id}}"
          {{#if selected}}checked{{/if}}
          {{#if ../required}}required{{/if}}
          aria-required="{{required}}">

        <span class="swatch {{#if data.[1]}}two-colors{{/if}}{{#if data.[2]}} three-colors{{/if}}">
          {{#if pattern}}
            <span class="swatch-color swatch-pattern" style="background-image: url('{{getImage image 'core-swatch'}}');"></span>
          {{/if}}

          {{#if data.[0]}}
            <span class="swatch-color" style="background-color: #{{data.[0]}}"></span>
          {{/if}}

          {{#if data.[1]}}
            <span class="swatch-color secondary" style="background-color: #{{data.[1]}}"></span>
          {{/if}}

          {{#if data.[2]}}
            <span class="swatch-color tertiary" style="background-color: #{{data.[2]}}"></span>
          {{/if}}
        </span>

        {{#if pattern}}
          <span class="swatch-pattern-expanded">
            <img class="swatch-pattern-image" src="{{getImage image 'core-swatch'}}">
          </span>
        {{/if}}

      </label>
    {{/each}}
  </div>

</div>

I have jquery code which was working on simple theme and here is the code of jquery 我有正在处理简单主题的jquery代码,这是jquery的代码

<script>
$(document).ready(function(){

$(".ProductDetails").each(function(){
var mcurl = $("strong a",this).attr("href");
$(this).after("<div class='mccolors'></div>");
$(".mccolors").load(mcurl + " .productOptionPickListSwatch");


});

});
</script>

but it's not working on big commerce stencil framework I have changed classes but not working. 但是它不适用于大型商务模具框架,但是我已经更改了类,但无法正常工作。

If you click on the first products on the website home page it will show colors of products into details page here is the link 如果您单击网站主页上的第一个产品,它将在详细信息页面中显示产品的颜色,这是链接

http://evisionshop.com/blackview-e7s/ http://evisionshop.com/blackview-e7s/

and I am trying to call this color on category page please check the screenshot http://prntscr.com/fk0p1r 我正在尝试在类别页面上将此颜色称为“彩色”,请检查屏幕截图http://prntscr.com/fk0p1r

how I can achieve this with jquery or javascript with the help the <div class="cat_items"></div> I have called into the sections automatically show the swatch colors dynamically on the category page. 我已在各部分中调用的<div class="cat_items"></div>的帮助下,如何使用jquery或javascript实现此目的,从而自动在类别页面上动态显示色板颜色。

Thanks in advance for help. 在此先感谢您的帮助。

I had the exact same problem. 我有同样的问题。

The way to solve it is like this. 解决它的方法是这样的。 It's not pretty but it worked. 它虽然不漂亮,但确实有效。

  1. Go to Storefront > Footer Scripts 转到店面>页脚脚本

    You might have to play around a bit with the '190px' I removed the 'Required' field earlier from the swatch.html file. 您可能需要稍微处理一下“ 190px”,我之前已从swatch.html文件中删除了“ Required”字段。

  2. Include this at the end: 最后包括以下内容:


<style>
    @media screen and (max-width: 770px) {

        .productView-options .form-radio:checked+.form-option span.form-option-variant.form-option-variant--color:after{ left:190px!important; }
    }
    .productView-options [data-product-attribute='swatch']{
        position:relative !important;
    }
    .productView-options [data-product-attribute] .form-option{
        overflow:visible !important;
        position: initial !important;
    }
    .productView-options .form-option span.form-option-variant.form-option-variant--color:after {
        content:  attr(title);
        display: none;
    }
    .productView-options .form-radio:checked+.form-option span.form-option-variant.form-option-variant--color:after{
        display: inline-block;
        color: #000;
        padding: 0;
        position:absolute;
        top: -2px;
        left: 50px;
        border-radius:4px;
        width: 250px;
        text-align: left;
        font-size: 15px;
        font-weight: 100;

    }
</style>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM