opencart-3 - 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 版本的产品详细信息复选框的人可以使用此代码。
解决方案
推荐阅读
- python - 运行与 twisted.internet.reactor 并行的 couroutine
- elasticsearch - 产品平面数据索引 Magento 2.4.2 索引错误
- bash - 在 bash 管道中“按 Enter”
- arrays - 我想知道二维数组地址的原理是怎样的
- ios - 从解码json响应iOS中只得到一项
- python - 如何在 django 中制作自定义和动态表单?
- react-native - 当我的 onChangeText 方法具有必须通过的过滤器/正则表达式时,为什么 TextInput 会尝试更新值?
- amazon-web-services - 在 AWS Glue 作业中运行 java -jar
- karate - 空手道 MockServer:获取 java.net.URISyntaxException:当我们在获取请求的查询参数之一中传递“{”时出现非法字符错误
- sketchware - 我想为草图软件中的自定义视图设置一个 onClick 侦听器