【发布时间】:2021-05-18 16:00:29
【问题描述】:
我想使用 ACF 来存储一个变量,然后在 wc_enqueue_js 标记中使用该变量。如果该变量可通过 php 作为 $couponCheck 使用,我需要将其作为“updated_checkout”函数中的数组提供。所以当优惠券被提交时,它会被数组检查。
这有意义吗?
<?php $couponCheck = get_field('coupons');>
wc_enqueue_js( "jQuery(function($) {
// On coupon change
$(document.body).on('updated_checkout', function(){
var couponArray = XXX;
var couponCheck = $('.woocommerce-remove-coupon').attr('data-coupon');
if(jQuery.inArray('couponCheck', coupnArray)) {
$('.gift-with-coupon').show();
}
});
});");
?>
谢谢。
【问题讨论】:
标签: php jquery wordpress woocommerce