0

Prerequisites

  • [x] I have carried out troubleshooting steps and I believe I have found a bug.
  • [x] I have searched for similar bugs in both open and closed issues and cannot find a duplicate.

Describe the bug

needs_setup is never even used if I override it for my WC_Payment_Gateway_CC payment gateway.

Please, let me know if this is deprecated.


    public function needs_setup(): bool {
        WC_MyGateway_Logger::logg('DEBUG: ' . $this->id . ' ' . $this->plugin_id); // never reached
        return empty($this->get_option('account_id'));
    }

Expected behavior

needs_setup should be triggered if overridden and should show Complete setup like PayPal plugin does, for example.

Actual behavior

Nothing happens.

Steps to reproduce

I am using WooCommerce Version 10.2.0-dev.

WordPress Environment

WordPress Environment

The System Status Report is found in your WordPress admin under WooCommerce > Status. Please select “Get system report”, then “Copy for GitHub”, and then paste it here.

Isolating the problem

  • [x] I have deactivated other plugins and confirmed this bug occurs when only WooCommerce plugin is active.
  • [x] This bug happens with a default WordPress theme active, or Storefront.
  • [x] I can reproduce this bug consistently using the steps above.

I am overridding this public method in my woocommerce payment gateway. However, it is being ignored completely.

1
  • I tried with the last stable version 10.1.2 and needs_setup is called in the back office when the payment gateway is added or removed in "WooCommerce" -> "Settings" -> "Payments". Commented Sep 3 at 16:51

1 Answer 1

1

It looks like adding is_account_connected in combination with needs_setup did the trick for me. According to this logic here: PaymentGateway.php#L58, needs_setup should evaluate to true whereas is_account_connected needs to evaluate to false.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.