• Resolved calle81

    (@calle81)


    I set 10% as a tax. Can I also add a transition fee of € 0.20? If so, how can I do it? Can you give me some php snippets to put in my function file? Sorry for my english.

    Thanks.

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Subrata Mal

    (@subratamal)

    @calle81 You can additional fee to the WooCommerce cart using WooCommerce filters. For reference please see https://woocommerce.com/document/add-a-surcharge-to-cart-and-checkout-uses-fees-api/

    Thread Starter calle81

    (@calle81)

    Thanks @subratamal for the reply, but I would like to add this fee only to the Product ID for Wallet Top-up. You can help me?

    Thanks

    Plugin Author Subrata Mal

    (@subratamal)

    @calle81 Please use the attached code in the theme functions.php file.

    /**
     * Add a transaction fee to wallet recharge in cart / checkout
     */
    add_action( 'woocommerce_cart_calculate_fees', 'wc_add_transaction_fee' );
    function wc_add_transaction_fee() {
    	if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
    		return;
    	}
    
    	// change the $fee to set the surcharge to a value to suit.
    	$fee = 0.20;
    
    	if ( is_wallet_rechargeable_cart() ) {
    		WC()->cart->add_fee( 'Transition Fee', $fee );
    	}
    }
    Thread Starter calle81

    (@calle81)

    Thanks @subratamal, but it doesn’t work. The fee is added to the checkout page but when I go to paypal the additional € 0.20 is not added.

    Example if I have to pay € 30 instead of being paid € 30 + 10% + 0.20 for a total of € 33.20, it charges me only € 33 on paypal without the € 0.20 of the additional fee.

    Plugin Author Subrata Mal

    (@subratamal)

    @calle81 Please try the attached updated code and let us know.

    /**
     * Add a transaction fee to wallet recharge in cart / checkout
     */
    add_action( 'woocommerce_cart_calculate_fees', 'wc_add_transaction_fee' );
    function wc_add_transaction_fee() {
    	if ( is_admin() ) {
    		return;
    	}
    	$fee = array(
    		'name'   => __( 'Transition Fee' ),
    		'amount' => 0.20,
    	);
    	if ( is_wallet_rechargeable_cart() ) {
    		wc()->cart->fees_api()->add_fee( $fee );
    	}
    }
    Thread Starter calle81

    (@calle81)

    Thanks @subratamal , but no this php snippet works for me either… ??

    Thread Starter calle81

    (@calle81)

    Hi @subratamal , do you have any news? Thanks.

    Plugin Author Subrata Mal

    (@subratamal)

    @calle81 This code is working for us please contact your theme developer and check if there is any plugin or theme conflict.

    Thread Starter calle81

    (@calle81)

    @subratamal ok. Thanks.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘how to add additional costs in addition to the tax rate?’ is closed to new replies.