Search code examples
wordpresswoocommercepaymentgateway

Why is admin_options not called in WooCommerce Payment Gateway Extension


I'm creating a custom payment gateway for WooCommerce, but I'm struggling to display the settings in de admin area.

I've followed tutorials like:

https://docs.woocommerce.com/document/payment-gateway-api/

https://docs.woocommerce.com/document/settings-api/

https://rudrastyh.com/woocommerce/payment-gateway-plugin.html.

However in my case admin_options is just never called when I go to the settings page for my payment gateway.

The payment gateway is in the list of payment methods. It's also visible in the frontend as selectable payment method.

Inside my class that extends WC_Payment_Gateway I have put

public function admin_options() {
    echo 'TEST'; 
    die();
}

To check if it's called, but it isn't. Other methods like the constructor, init_form_fields are called, so at least some part is working.

Any ideas on what might be happening or how to tackle this are very welcome.


Solution

  • $this->id contained some uppercase letters....it seems that was not allowed...making it lower case resolved the issue.

    I was triggered by the answer of #Vishal in this post:

    WordPress Plugin WooCommerce, Custom Payment Gateway Settings Not Saving