Advertisement
imnguyen

GACO: semi-working conditional fee

Feb 16th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1.  
  2. function authorize_less($available_gateways) {
  3. $maximum = 0;
  4. if ( WC()->cart->total < $maximum ) {
  5. unset( $available_gateways['authorizenet'] );
  6. }
  7. return $available_gateways;
  8. }
  9. add_filter( 'woocommerce_available_payment_gateways', 'authorize_less');
  10. add_action( 'woocommerce_cart_calculate_fees' , 'authorize_less' );
  11. add_action( 'woocommerce_after_cart_item_quantity_update', 'authorize_less' );
  12.  
  13.  
  14.  
  15. function authorize_more($available_gateways) {
  16. $maximum = 0;
  17. if ( WC()->cart->total > $maximum ) {
  18. unset( $available_gateways['cod'] );
  19. }
  20. return $available_gateways;
  21. }
  22. add_filter( 'woocommerce_available_payment_gateways', 'authorize_more');
  23. add_action( 'woocommerce_cart_calculate_fees' , 'authorize_more' );
  24. add_action( 'woocommerce_removed_coupon', 'authorize_more' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement