Add WooCommerce coupon code automatically based on product categories
问题 I am trying to add a coupon code automatically if the cart has products from specific categories. The price must be updated in the Total after showing the discount amount. But I cant see any changes in the total, kindly help me. My code: add_action('wc_cart_product_subtotal' , 'getsubtotalc'); function getsubtotalc ($product_subtotal, $_product, $quantity, $object) { if( is_cart() || is_checkout() ) { global $woocommerce, $product; global $total_qty; /*$coupon_code = 'drawer'; if (