Percentage discount based on user role and payment method in Woocommerce
问题 I was trying to make a code snippet for functions.php which would apply a discount of 2 % for cart totals when the role "subscriber" and the payment method "credit-card" are both selected. My progress so far function discount_when_role_and_payment(/* magic */) { global $woocommerce; if ( /* credit-card selected */ && current_user_can('subscriber') ) { /* get woocommerce cart totals, apply 2% discount and return*/ } return /*cart totals after discount*/; } add_filter( '/* magic */', 'discount