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

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

我正在使用此代码生成信用卡表格,但它会提示

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

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

那么我如何访问 class 因为我目前正在扩展 WC_Payment_Gateway

class GGOwl_Woo extends WC_Payment_Gateway {

正如弃用方法通知本身所建议的那样,您应该改用 WC_Payment_Gateway_CC。 您可以自己使用与 WC_Payment_Gateway::credit_card_form 中类似的代码。因此,您可以将 $this->credit_card_form() 替换为以下内容:

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

这只是一种解决方法,您实际上应该从 WC_Payment_Gateway_CC 扩展 class。