WordPress.org

Support

Support » Plugins and Hacks » [Resolved] Adding fee for each cart item

[Resolved] Adding fee for each cart item

  • I’m using a paypal snippet to add a processing fee at checkout but i was wondering if there was a way to add the processing fee for each product added to the shopping cart.

    function woo_add_cart_fee() {
    
    	global $woocommerce;
    
    	if ( is_cart() ) {
    
    		$woocommerce->cart->add_fee( __('Processing', 'woocommerce'), 3 );
    
    	}
    
    }
    
    add_action( 'woocommerce_before_cart_table', 'woo_add_cart_fee' );

    Any help is appreciated.

Viewing 2 replies - 1 through 2 (of 2 total)
  • nevermind. a few hours of searching but I found it.

    /**
     * Add a 1% surcharge to your cart / checkout
     * change the $percentage to set the surcharge to a value to suit
     * Uses the WooCommerce fees API
     *
     * Add to theme functions.php
     */
    add_action( 'woocommerce_cart_calculate_fees','woocommerce_custom_surcharge' );
    function woocommerce_custom_surcharge() {
      global $woocommerce;
    
    	if ( is_admin() && ! defined( 'DOING_AJAX' ) )
    		return;
    
    	$percentage = 0.01;
    	$surcharge = ( $woocommerce->cart->cart_contents_total + $woocommerce->cart->shipping_total ) * $percentage;
    	$woocommerce->cart->add_fee( 'Surcharge', $surcharge, true, 'standard' );
    
    }

    Solved & Resolved

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] Adding fee for each cart item’ is closed to new replies.
Skip to toolbar