首页 > 解决方案 > Opencart 3x Checkbox 设置最大限制

问题描述

``` <?xml version="1.0" encoding="utf-8"?>
<modification>
  <name>Checkbox Limit Belirleme</name>
  <code>checkbox_limit_belirleme</code>
  <version>1</version>
  <author>Üzümnet Kurumsal</author>
  <link>www.uzumnet.com</link>
  <file path="catalog/view/theme/journal3/template/product/product.twig">
    <operation>
      <search><![CDATA[<input type="checkbox" name="option[{{ option.product_option_id }}][]" value="{{ option_value.product_option_value_id }}" />]]></search>
      <add position="replace"><![CDATA[
      <input class="check" type="checkbox" name="option[{{ option.product_option_id }}][]" value="{{ option_value.product_option_value_id }}" />
      <script>
          var checks = document.querySelectorAll(".check");
            var max = 3;
            for (var i = 0; i < checks.length; i++)
            checks[i].onclick = selectiveCheck;
        function selectiveCheck (event) {
            var checkedChecks = document.querySelectorAll(".check:checked");
            if (checkedChecks.length >= max + 1)
            return false;  }
        </script>
      ]]></add>
    </operation>
    
    <operation>
      <search><![CDATA[]]></search>
      <add position="af"><![CDATA[  ]]></add>
    </operation>
    </file>
</modification> 

*我是为在 opencart 3 x 版本上工作的 Journal 3 Theme 做的 *

那些想要限制 Opencart 3 版本的产品详细信息复选框的人可以使用此代码。

标签: opencart-3

解决方案


推荐阅读