1

I am using this code to generate the credit card form but it throws a notice that

credit_card_form is deprecated since version 2.6! Use WC_Payment_Gateway_CC->form instead.

public function payment_fields() {
          $this->credit_card_form();
        }

So how do i access that class as i am currently extending the WC_Payment_Gateway?

class GGOwl_Woo extends WC_Payment_Gateway {

1 Answers1

3

As suggested by deprecated method notice itself, you should use WC_Payment_Gateway_CC instead. You can use similar code yourself as used in WC_Payment_Gateway::credit_card_form. So you can replace $this->credit_card_form() with following:

$cc_form           = new WC_Payment_Gateway_CC();
$cc_form->id       = $this->id;
$cc_form->supports = $this->supports;
$cc_form->form();

This is just a workaround, you should actually extend your class from WC_Payment_Gateway_CC.

rmalviya
  • 1,847
  • 12
  • 39
  • thank you ..i am trying to figure out how to use the form values? any reference –  Jun 29 '19 at 15:40
  • You can extend your class with `WC_Payment_Gateway_CC` which itself is subclass of `WC_Payment_Gateway`, so with some addition similar API is available to you. You can see source code of the class to learn more: https://github.com/woocommerce/woocommerce/blob/3.6.4/includes/gateways/class-wc-payment-gateway-cc.php – rmalviya Jun 29 '19 at 15:45