Last active
          September 5, 2017 17:10 
        
      - 
      
- 
        Save rynaldos-zz/e46aa2e2f54a0b450ba1bab9797001a8 to your computer and use it in GitHub Desktop. 
    [WooCommerce] Add a standard $ value surcharge to all transactions
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | add_action( 'woocommerce_cart_calculate_fees','wc_add_surcharge' ); | |
| function wc_add_surcharge() { | |
| global $woocommerce; | |
| if ( is_admin() && ! defined( 'DOING_AJAX' ) ) | |
| return; | |
| $county = array('US'); | |
| // change the $fee to set the surcharge to a value to suit | |
| $fee = 1.00; | |
| if ( in_array( WC()->customer->get_shipping_country(), $county ) ) : | |
| $woocommerce->cart->add_fee( 'Surcharge', $fee, true, 'standard' ); | |
| endif; | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment