• I used this add_fee() function to theme download_detalis.php widget by copy/pasting this sample code :

    function pw_add_handling_fee() {
    	// Add a $10 handling fee no matter what
    	EDD()->fees->add_fee( '10', 'Handling Fee', 'handling_fee' );
    }
    add_action( 'init', 'pw_add_handling_fee' );
    
    //adding fee for test
    pw_add_handling_fee();

    Then fee successfully added to cart page by title of Handling Fee
    But when i tried to remove fee that i’ve added for test by using remove_fee() with the code below nothing happend and fee didn’t removed !!!

    The code that i used for remove is the sample code :

    function pw_remove_handling_fee() {
    	EDD()->fees->remove_fee( 'handling_fee' );
    }
    add_action( 'init', 'pw_remove_handling_fee', 9999 );

    I didn’t change anything , Just used the sample code , As you see.
    Now! i forced to change 10 to 0 temporary to adding 0 extra cost to user cart !! AAhhuughh
    Please help me with this bug !

    • This topic was modified 5 years, 6 months ago by TheXrion.
    • This topic was modified 5 years, 6 months ago by TheXrion.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi @negarehgfx

    It looks like that your code is perfect.

    Can you please remove the below line from your code?

    //adding fee for test
    pw_add_handling_fee();

    It would be good if you can provide me the full code snippet to debug it properly. Actually code placement is also affect so I want to check how you are doing and it will help me to understand it better.

    Thread Starter TheXrion

    (@negarehgfx)

    Hi @pratik-jain

    I already removed this line before posting this issue

     //adding fee for test
    pw_add_handling_fee();

    Then I added lines above in my question to removing fees but didn’t worked in correct way
    So how it’s get fixed ? The problem get solved when clicked on pay button on cart page and then redirected to bank gateway as it should be , after canceling payment at the gateway i returned to cart And (This is how fixed) I saw fee removed from cart and never added again until if again i want to add it with pw_add_handling_fee().
    So this is how remove_fee() worked !

    Actually this could be a huge bug of Easy digital downloads plugin !

    • This reply was modified 5 years, 6 months ago by TheXrion.
    • This reply was modified 5 years, 6 months ago by TheXrion.

    Hi @negarehgfx

    I have tried to add FEE and Remove FEE with your provided code snippet and it worked well for me.

    It would be good if you can explain me the flow and provide me the full code how it goes. I think it is necessary to understand the actual behavior and flow.

    You can explain me the process, how it goes and what you are trying to do. For example, If user add product in to the cart then some FEE should be apply on it and when user remove the item from cart then FEE also should be removed.

    If I understand the flow then I can help you with some code snippet.

    Thanks.

    • This reply was modified 5 years, 6 months ago by Pratik Jain. Reason: some line update
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘remove_fee() not work !’ is closed to new replies.