ClassicCommerce not triggering filter for adding settings sections in tabs

I’m trying to add a section in the Settings > Payments dashboard.
Adding the section works, but populating it doesn’t. The filter doesn’t seem to trigger/work.

/classic-commerce/includes/admin/settings/class-wc-settings-payment-gateways:71 is not triggered when my plugin does:

add_filter('woocommerce_get_settings_checkout', 'ajdg_paypal_surcharge_settings', 10, 2);

I’ve been poking around in the code and can’t find a cause. It’s like the filter doesn’t exist in CC.
But it does in the above mentioned file.

For comparison, this works fine:

add_filter('woocommerce_get_sections_checkout', 'ajdg_paypal_surcharge_section');

Both work in WooCommerce 2.2.2 and up. and the code seems the same enough even in WC 3.x-5.6 to imply that it should work on CC too. Seeing that it works half in CC, I imagine it’s a bug in Classic Commerce.

I can’t find any errors in any logs. Nor does ClassicPress/ClassicCommerce seem to acknowledge the filter.

Other than the missing dashboard, the plugin works fine. All other hooks/filters and everything works. Just the settings hook doesn’t work - Further suggesting there is a bug in CC.

Thoughts? Advise?

2 Likes

Is this related?

There do seem to be a couple of mentions I could find online, but it is way beyond my level of understanding. Pinging @omukiguy to see if he has an idea.

The only other thing I could suggest is to download a copy of WC 3.5.3 and see if it works there. Then we will know for sure that it is something we did.

Also can you post a screenshot of what you are seeing?

Are you able to share your code - or a minimal example that reproduces the issue you are seeing?

@ozfiddler exactly that yes.

@ozfiddler

This is in Classic Commerce - All works except the dashboard content is missing (due to the filter not working).
https://disk.stor.fit/index.php/s/oZbrMwf8oSWDcQ3

And this one is in WooCommerce 5+ where it works fine. (alo worked in older WC versions)
https://disk.stor.fit/index.php/s/4A98FfiqikLrQRm

Are you saying it works in WC 3.5.3? It looks like it might be a limitation we inherited.

Sorry, missed this. So it does work in WC 3.5.3.

That sounds about right. They fixed it in February 2019.

Yes, just been testing this using the sample code from the docs. It works on the Products tab but not the Shipping or the Payments. Same result in CC and WC 3.5.3.

Does this look like a fairly straighforward fix we could push in the next release?

I don’t know for sure, not my area of exertise, but the changes seem to affect one file:

If you have CC installed already, try testing those changes to that file.

I’m playing with it! I have the new section showing correctly :+1: but I have now lost the main payment gateway page :-1:

I expect someone who knew what they were doing could probably get it to work fairly easily.

OK - I have it working now. This is the payments section, and a new section added. I will see if I can remember how to do a PR for this.


The documentation of WC says the filters are introduced in 2.2.2.
I’ve created these plugins maybe 2-3 years ago. So whatever version of WC was current then, it works on that for sure.

Hopefully it’s a easy fix :slight_smile: and thanks for your efforts!

1 Like

I think it should be fairly easy. I have done a PR…

It needs to be reviewed and we will see when we can get it added.

1 Like

If would be good if you could test it for us. Download the revised file and copy it in to a test site.

yay!
I can confirm this now seems to work on CC1.0.4.

2 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.