• pawelkmpt

    (@pawelkmpt)


    Our WooCommerce store supports multiple currencies. After installing Affirm we see following notice when order was made in different currency than USD or CAD:

    Affirm: Affirm only supports USD or CAD for currency.

    It is added in WC_Gateway_Affirm::adminNotices() to the admin_notices action.

    This notice is unnecessary for us and confusing for some teammates. I’ve tried to remove it with

    remove_action( 'admin_notices', array( affirm()->get_gateway(), 'adminNotices' ) );

    function does return true but notice persists. What I found out? New instances of WC_Gateway_Affirm are created in 3 places:

    • WC_Affirm_Blocks_Checkout
    • WC_Affirm_Blocks_Cart
    • WooCommerce_Gateway_Affirm::get_gateway() which is affirm()->get_gateway() but this case only when I actually call get_gateway() method. It’s not created earlier.

    Creating new instances of WC_Gateway_Affirm in checkout and cart classes makes it register notices hook twice and impossible to remove as objects are stored in private properties.

    I think plugin should use WooCommerce_Gateway_Affirm::get_gateway() in these places instead.

  • You must be logged in to reply to this topic.