WC_Payment_Gateway::get_new_payment_method_option_html()publicWC 2.6.0

Displays a radio button for entering a new payment method (new CC details) instead of using a saved method. Only displayed when a gateway supports tokenization.

Method of the class: WC_Payment_Gateway{}

Return

null. Nothing (null).

Usage

$WC_Payment_Gateway = new WC_Payment_Gateway();
$WC_Payment_Gateway->get_new_payment_method_option_html();

Changelog

Since 2.6.0 Introduced.

WC_Payment_Gateway::get_new_payment_method_option_html() code WC 9.3.1

public function get_new_payment_method_option_html() {
	/**
	 * Filter the saved payment method label.
	 *
	 * @since 2.6.0
	 * @param string $label Label.
	 * @param WC_Payment_Gateway $this Payment gateway instance.
	 * @return string
	 */
	$label = apply_filters( 'woocommerce_payment_gateway_get_new_payment_method_option_html_label', $this->new_method_label ? $this->new_method_label : __( 'Use a new payment method', 'woocommerce' ), $this );
	$html  = sprintf(
		'<li class="woocommerce-SavedPaymentMethods-new">
			<input id="wc-%1$s-payment-token-new" type="radio" name="wc-%1$s-payment-token" value="new" style="width:auto;" class="woocommerce-SavedPaymentMethods-tokenInput" />
			<label for="wc-%1$s-payment-token-new">%2$s</label>
		</li>',
		esc_attr( $this->id ),
		esc_html( $label )
	);
	/**
	 * Filter the saved payment method option.
	 *
	 * @since 2.6.0
	 * @param string $html Option HTML.
	 * @param WC_Payment_Gateway $this Payment gateway instance.
	 * @return string
	 */
	return apply_filters( 'woocommerce_payment_gateway_get_new_payment_method_option_html', $html, $this );
}