Advertisement
imnguyen

GACO: custom fee

Feb 14th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. function woo_dm_add_custom_fees(){
  2. $cart_total = 0;
  3. foreach( WC()->cart->get_cart() as $item ){
  4. $cart_total += $item["line_total"];
  5. }
  6. $fee = (int)$cart_total*5/100;
  7. WC()->cart->add_fee( "Credits :", $fee, false, '' );
  8. }
  9.  
  10. add_action( 'woocommerce_cart_calculate_fees' , 'woo_dm_add_custom_fees' );
  11. add_action( 'woocommerce_after_cart_item_quantity_update', 'woo_dm_add_custom_fees' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement