• Resolved svenms

    (@svenms)


    Is it possible to prevent the application and display of a fee with some logic? Filter, actions?

    Thanks!

    The page I need help with: [log in to see the link]

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter svenms

    (@svenms)

    Do you think it would be possible to initiate each class in a variable, for example:
    Change:

    return new Alg_WC_Checkout_Fees();

    For:

    $Alg_WC_Checkout_Fees = new Alg_WC_Checkout_Fees();
    return $Alg_WC_Checkout_Fees;

    That way we could access filters and actions inside each class and modify them if needed.

    Thank you very much!
    Sven

    Plugin Author tychesoftwares

    (@tychesoftwares)

    Hi @svenms,

    Thank you for reaching out to us with a new thought.

    I’ll have a word with our development team and will get back to you with an update.

    Plugin Author tychesoftwares

    (@tychesoftwares)

    Hi @svenms,

    I had a discussion with the team about this. And we would like to know the real example for the requirement you mentioned. Could you tell me why do you want to add the condition and which condition should be applied? Do you want to add the ability via actions & filters to be able to prevent the display & applying of some fees in the case when multiple fees are added to the cart?

    It would be really great if you can tell us in detail, we will try our best to serve you better.

    Thread Starter svenms

    (@svenms)

    Hello,

    Correct, we want to prevent some fees in some cases. Specifically, displaying them to some b2b customers as we use Woocommerce b2b plugin.
    Currently as the clases are instances, it is not possible to access them easily and deregister some actions/filters.

    Please let me know if you would need any further information or more specified data.

    Best regards and thank you very much!

    Thread Starter svenms

    (@svenms)

    Dear,

    What have you resolved about this request with the Team ?? ?

    Thanks!
    Best regards!

    Plugin Author tychesoftwares

    (@tychesoftwares)

    Hi @svenms,

    Currently, it’s not possible to make the changes that you have mentioned and due to that removing the action/filter of the plugin can’t be done. To remove the fees based on some conditions, you can replace the below file and place the provided code in the functions.php file of your currently active theme.

    Link to download file: https://www.dropbox.com/s/k0hcggwmhcxma5h/class-alg-wc-checkout-fees.zip?dl=0
    file path : /wp-content/plugins/checkout-fees-for-woocommerce/includes
    file name : class-alg-wccheckout-fees.php
    

    HOOK:

    function alg_wc_checkout_fees_after_fees_added() {
    	$fees = WC()->cart->get_fees();
    	foreach ( $fees as $key => $fee ) {
    		if ( 'Bank' === $fees[ $key ]->name ) { // Remove Bank fee.
    			unset( $fees[ $key ] );
    		}
    	}
    	WC()->cart->fees_api()->set_fees( $fees );
    }
    add_action( 'alg_wc_checkout_fees_after_fees_added', 'alg_wc_checkout_fees_after_fees_added' );
    

    Provided code will help to remove the fees added from the plugin. e.g The Fee with the title “Bank” is getting added via the plugin. After doing the above changes will remove the “Bank” fees from the table. You can do the necessary changes in the provided code according to your business requirements. Feel free to let us know if you need any help from us.

    If this still doesn’t help then please do the necessary changes in the plugin code and share it with us. If we feel that the changed code will not affect the other functionality of the plugin then we will release it in the future update after testing it thoroughly.

    Ask me if you have any further questions.

    Thread Starter svenms

    (@svenms)

    Thanks!

    Works like a charm for preventing fees to be added to the order.
    Just in case, do you imagine similar solution for preventing feed been added to products?

    Thank you very much!

    Sven

    Thread Starter svenms

    (@svenms)

    Dear, do you think it is possible to include the modifications in the file class-alg-wccheckout-fees.php in any following release?
    That way anyone will have the ability to disable a fee with functions.php and we won’t be checking if the plugin have been updated to replace the file again.

    FIle: https://easyupload.io/vxsfc6 in case you’ve deleted it.

    Best regards!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Prevent Fee in some Cases’ is closed to new replies.