Automattic\WooCommerce\Internal\RestApi\Routes\V4\Settings\PaymentGateways\Schema
AbstractPaymentGatewaySettingsSchema::get_default_group
Get default single group with all gateway fields.
Method of the class: AbstractPaymentGatewaySettingsSchema{}
No Hooks.
Returns
Array.
Usage
// private - for code of main (parent) class only $result = $this->get_default_group( $gateway ): array;
- $gateway(WC_Payment_Gateway) (required)
- Gateway instance.
AbstractPaymentGatewaySettingsSchema::get_default_group() AbstractPaymentGatewaySettingsSchema::get default group code WC 10.4.3
private function get_default_group( WC_Payment_Gateway $gateway ): array {
$gateway->init_form_fields();
$group = array(
'title' => __( 'Settings', 'woocommerce' ),
'description' => '',
'order' => 1,
'fields' => array(),
);
// Add standard top-level fields first.
$group['fields'][] = array(
'id' => 'enabled',
'label' => __( 'Enable/Disable', 'woocommerce' ),
'type' => 'checkbox',
'desc' => __( 'Enable this payment gateway', 'woocommerce' ),
);
$group['fields'][] = array(
'id' => 'title',
'label' => __( 'Title', 'woocommerce' ),
'type' => 'text',
'desc' => __( 'This controls the title which the user sees during checkout.', 'woocommerce' ),
);
$group['fields'][] = array(
'id' => 'description',
'label' => __( 'Description', 'woocommerce' ),
'type' => 'text',
'desc' => __( 'This controls the description which the user sees during checkout.', 'woocommerce' ),
);
$group['fields'][] = array(
'id' => 'order',
'label' => __( 'Order', 'woocommerce' ),
'type' => 'number',
'desc' => __( 'Determines the display order of payment gateways during checkout.', 'woocommerce' ),
);
foreach ( $gateway->form_fields as $id => $field ) {
$field_type = $field['type'] ?? '';
// Skip non-data fields, top-level fields (already added above), and special fields.
if ( in_array( $field_type, array( 'title', 'sectionend' ), true ) ||
in_array( $id, array( 'enabled', 'description', 'title' ), true ) ||
$this->is_special_field( $id ) ) {
continue;
}
$group['fields'][] = $this->transform_field_to_schema( $id, $field, $gateway );
}
// Add special fields.
$special_fields = $this->get_special_field_schemas( $gateway );
$group['fields'] = array_merge( $group['fields'], $special_fields );
if ( empty( $group['fields'] ) ) {
return array();
}
return array( 'settings' => $group );
}