javascript - 如何根据产品 ID 为 Woocommerce 产品属性定义一个类?
问题描述
我有一个脚本需要基于产品 ID 的动态值。
<script type='text/javascript'>
var ccs_cc_args = ccs_cc_args || []
ccs_cc_args.push(['cpn', 'CPN']); ///Dynamically replace the CPN text
ccs_cc_args.push(['mf', 'MFR_NAME']); //Dynamically replace the MFR_NAME text
ccs_cc_args.push(['pn', 'MPN']); //Dynamically replace the MPN text
ccs_cc_args.push(['market', 'PH']);
(function () {
var o = ccs_cc_args; o.push(['_SKey', '6ad5831c']); o.push(['_ZoneId', 'hp-auto-pp']);
var sc = document.createElement('script'); sc.type = 'text/javascript'; sc.async = true;
sc.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'cdn.cnetcontent.com/jsc/h.js';
var n = document.getElementsByTagName('script')[0]; n.parentNode.insertBefore(sc, n);
})();
</script>
我找到了一个解决方案,其中将值替换为 PHP 文件中定义的类,例如 this,并将脚本中的值替换为定义的 class.text
<div class="productboxArticlenumber">MLH82N/A</div>
但我无法弄清楚 woocommerce 产品属性术语是什么类,因为它们以这样的表格格式返回,以及如何使其引用产品 ID。
<tr class="woocommerce-product-attributes-item woocommerce-product-attributes-item--attribute_pa_brand">
<th class="woocommerce-product-attributes-item__label">Brand</th>
<td class="woocommerce-product-attributes-item__value"><p>Huawei</p>
解决方案
推荐阅读
- python - Facebook Marketing/Insights API 返回 OAuthException,错误代码为 100 缺少权限
- python - 根据条件获取最早的pandas列的值
- c - 将一个 Methode 的变量结果调用到另一个 Methode 以在 C 中使用它
- angular - 如何从 api 预加载角度分量数据
- spring - 如何在 Spring 启动时请求 Array 中包含的 body 对象文件
- r - 如何在闪亮中指定具有不同样式的不同单选按钮?
- c# - 从包含的 ObjectB 访问 ObjectA 的成员
- jsbin - jsbin - 是否可以更改快捷方式?
- java - 将 Firebase 中的数据显示到自定义信息窗口中
- c# - ftp 发布 vs 文件夹发布和使用 FTP 程序上传