get( Automattic\WooCommerce\StoreApi\Schemas\ExtendSchema::class ); self::extend_store(); } /** * Registers the actual data into each endpoint. */ public static function extend_store() { if ( is_callable( [ self::$extend, 'register_endpoint_data' ] ) ) { self::$extend->register_endpoint_data( [ 'endpoint' => CheckoutSchema::IDENTIFIER, 'namespace' => self::IDENTIFIER, 'schema_callback' => [self::class, 'extend_checkout_schema' ], 'schema_type' => ARRAY_A, ] ); } } /** * Register schema into the Checkout endpoint. * * @return array Registered schema. * */ public static function extend_checkout_schema() { $schema = []; // Get all section IDs $sections = THWCFD_Utils_Block::get_block_checkout_sections(); $excluded_ids = ['address', 'order']; foreach ($sections as $section_id => $section) { if (in_array($section_id, $excluded_ids, true)) { continue; } $schema[$section_id] = [ // Translators: %s is the section ID. 'description' => sprintf(__('Additional checkout fields for section %s', 'woo-checkout-field-editor-pro'), $section_id), 'type' => ['object', 'null'], 'context' => ['view', 'edit'], 'readonly' => true, 'arg_options' => [ 'validate_callback' => function( $value ) { return ( $value ); }, ], ]; } return $schema; } } endif;