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( array( self::$extend, 'register_endpoint_data' ) ) ) { self::$extend->register_endpoint_data( array( 'endpoint' => CheckoutSchema::IDENTIFIER, 'namespace' => self::IDENTIFIER, 'schema_callback' => array( 'WC_SC_Extend_Store_Endpoint', 'extend_checkout_schema' ), 'schema_type' => ARRAY_A, ) ); } } /** * Register subscription product schema into cart/items endpoint. * * @return array Registered schema. */ public static function extend_checkout_schema() { return array( 'is_gift' => array( 'description' => _x( 'Whether to send coupons to someone else.', 'REST API', 'woocommerce-smart-coupons' ), 'type' => array( 'string', 'null' ), 'context' => array( 'view', 'edit' ), 'readonly' => true, 'optional' => true, 'arg_options' => array( 'validate_callback' => function( $value ) { return is_string( $value ); }, 'sanitize_callback' => 'sanitize_text_field', ), ), 'send_to' => array( 'description' => _x( 'Whether to send coupons to only one person or multiple people.', 'REST API', 'woocommerce-smart-coupons' ), 'type' => array( 'string', 'null' ), 'context' => array( 'view', 'edit' ), 'readonly' => true, 'arg_options' => array( 'validate_callback' => function( $value ) { return is_string( $value ); }, 'sanitize_callback' => 'sanitize_text_field', ), ), 'wc_sc_schedule_gift_sending' => array( 'description' => _x( 'Whether to send coupons now or schedule for later.', 'REST API', 'woocommerce-smart-coupons' ), 'type' => array( 'string', 'null' ), 'context' => array( 'view', 'edit' ), 'readonly' => true, 'arg_options' => array( 'validate_callback' => function( $value ) { return is_string( $value ); }, 'sanitize_callback' => 'sanitize_text_field', ), ), 'gift_receiver_email' => array( 'description' => _x( 'Email address of recipients', 'REST API', 'woocommerce-smart-coupons' ), 'type' => array( 'object', 'null' ), 'context' => array( 'view', 'edit' ), 'readonly' => true, 'arg_options' => array( 'validate_callback' => function( $value ) { return is_array( $value ); }, 'sanitize_callback' => 'wc_clean', ), 'items' => array( 'type' => 'string', ), ), 'gift_sending_timestamp' => array( 'description' => _x( 'Coupons scheduled date & time', 'REST API', 'woocommerce-smart-coupons' ), 'type' => array( 'object', 'null' ), 'context' => array( 'view', 'edit' ), 'readonly' => true, 'arg_options' => array( 'validate_callback' => function( $value ) { return is_array( $value ); }, 'sanitize_callback' => 'wc_clean', ), 'items' => array( 'type' => 'string', ), ), 'gift_receiver_message' => array( 'description' => _x( 'Message for coupon recipient', 'REST API', 'woocommerce-smart-coupons' ), 'type' => array( 'object', 'null' ), 'context' => array( 'view', 'edit' ), 'readonly' => true, 'arg_options' => array( 'validate_callback' => function( $value ) { return is_array( $value ); }, 'sanitize_callback' => 'wc_clean', ), 'items' => array( 'type' => 'string', ), ), ); } } }