fix: use WC_Payment_Gateways
instance
#4248
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Because we were using
new WC_Payment_Gateways
, we added duplicate filters in the loop, which resulted in duplicate behavior when rendering the bank details.By using the singleton pattern provided by the class via
WC_Payment_Gateways:instance()
, we prevent this bad behavior.Debugging process
To find where the problem was, I first printed the stack trace on the function that renders the bank details and then checked all Neve functions that were used. There was nothing problematic with them; there were no multiple calls.
This leads me to the idea that some filter was added multiple times, so I printed the stack trace of the
WC_Payment_Gateways
constructor, which revealed the Neve function that added the filter multiple times.Will affect the visual aspect of the product
NO
Screenshots
Test instructions
Direct bank transfer
in Payments tab of WooCommerce settingsCheck before Pull Request is ready:
I have written a test and included it in this PRCloses #4244