在使用Woocommerce Product Addons时,我为特定的输入域安装了一个日期选择器。下面的代码适用于ID为'1381‘的产品。
如何将woocommerce的$product_id
赋值到jQuery代码中。
// Check the name of your addon field in the source. Example: addon-7934-test-addon
jQuery ( "input[name^=addon-1318-install-date-mmddyy]" ).datepicker( {
minDate: 0,
"dateFormat": 'mm-dd-yy'
} );
其中仅1318
应由当前产品替换&应显示日期选择器(如果可用)。
提前谢谢。
发布于 2015-07-03 15:50:08
我也遇到过同样的挑战--我没有尝试分配产品ID,而是在字段名称上使用了通配符--在我的例子中是一个交货日期--所以你可以去掉部分名称,只搜索字符串的一部分是否存在,所以对于上面的例子,它是:
// Check the name of your addon field in the source. Example: addon-7934-test-addon
jQuery( "input[name*='install-date-mmddyy']" ).datepicker( {
minDate: 0,
"dateFormat": 'yy-mm-dd'
} );
https://stackoverflow.com/questions/22195465
复制相似问题