Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wordpress 使用woocommerce显示优惠券使用限制编号_Wordpress_Woocommerce_Shortcode - Fatal编程技术网

Wordpress 使用woocommerce显示优惠券使用限制编号

Wordpress 使用woocommerce显示优惠券使用限制编号,wordpress,woocommerce,shortcode,Wordpress,Woocommerce,Shortcode,我在woocommerce做了一张优惠券,使用限额为150 我想在我的主页上用一个短代码来获取剩余优惠券的数量 比如,如果我的优惠券是“优惠券测试”,使用限额为150,当我在我的主页中进行[优惠券测试]时,它返回150,如果有订单,它将更改为149等等 提前感谢:)您可以在短代码中添加以下代码 $coupon_code = 'Coupon-test'; global $woocommerce; $coupon_data = new WC_Coupon($coupon_code); echo ($

我在woocommerce做了一张优惠券,使用限额为150

我想在我的主页上用一个短代码来获取剩余优惠券的数量

比如,如果我的优惠券是“优惠券测试”,使用限额为150,当我在我的主页中进行[优惠券测试]时,它返回150,如果有订单,它将更改为149等等


提前感谢:)

您可以在短代码中添加以下代码

$coupon_code = 'Coupon-test';
global $woocommerce;
$coupon_data = new WC_Coupon($coupon_code);
echo ($coupon_data->usage_limit - $coupon_data->usage_count);// return number of remaining coupons