Automattic\WooCommerce\Internal\RestApi\Routes\V4\Settings\PaymentGateways\Schema

AbstractPaymentGatewaySettingsSchema::get_shipping_method_restriction_field_overrides │ protected │ WC 1.0

Get design-aligned overrides for the shipping method restriction fields shared by the offline gateways (COD, BACS and Cheque).

The gateway's own multiselect options are only loaded on the classic settings page, so the options are loaded here for the REST API.

Method of the class: AbstractPaymentGatewaySettingsSchema{}

No Hooks.

Returns

array. Map of field_id => override, to merge into the core field overrides.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_shipping_method_restriction_field_overrides( $gateway ): array;
$gateway(WC_Payment_Gateway) (required)
Gateway instance.

AbstractPaymentGatewaySettingsSchema::get_shipping_method_restriction_field_overrides() code WC 11.3.0

protected function get_shipping_method_restriction_field_overrides( WC_Payment_Gateway $gateway ): array {
	$method_title = $gateway->get_method_title();

	return array(
		'enable_for_methods' => array(
			'label'   => __( 'Available for shipping methods', 'woocommerce' ),
			'type'    => 'multiselect',
			/* translators: %s: payment method title. */
			'desc'    => sprintf( __( 'Choose which shipping methods support %s.', 'woocommerce' ), $method_title ),
			'options' => method_exists( $gateway, 'get_shipping_method_options' ) ? $gateway->get_shipping_method_options() : array(),
		),
		'enable_for_virtual' => array(
			'label' => __( 'Accept for virtual orders', 'woocommerce' ),
			'type'  => 'checkbox',
			/* translators: %s: payment method title. */
			'desc'  => sprintf( __( 'Accept %s if the order is virtual', 'woocommerce' ), $method_title ),
		),
	);
}