*/ protected function input_properties(): array { return array( 'code' => array( 'type' => 'string', 'description' => __( 'The code a customer types. Must not already exist.', 'acrossai-abilities-manager' ) ), 'discount_type' => array( 'type' => 'string', 'description' => __( 'percent, fixed_cart or fixed_product. Defaults to fixed_cart.', 'acrossai-abilities-manager' ) ), 'amount' => array( 'type' => 'string', 'description' => __( 'The discount amount. For percent, 10 means ten per cent.', 'acrossai-abilities-manager' ) ), 'description' => array( 'type' => 'string', 'description' => __( 'Internal description.', 'acrossai-abilities-manager' ) ), 'date_expires' => array( 'type' => 'string', 'description' => __( 'Expiry date, YYYY-MM-DD.', 'acrossai-abilities-manager' ) ), 'usage_limit' => array( 'type' => 'integer', 'description' => __( 'Total times the coupon may be used.', 'acrossai-abilities-manager' ) ), 'usage_limit_per_user' => array( 'type' => 'integer', 'description' => __( 'Times one customer may use it.', 'acrossai-abilities-manager' ) ), 'minimum_amount' => array( 'type' => 'string', 'description' => __( 'Minimum cart total for the coupon to apply.', 'acrossai-abilities-manager' ) ), 'maximum_amount' => array( 'type' => 'string', 'description' => __( 'Maximum cart total for the coupon to apply.', 'acrossai-abilities-manager' ) ), 'individual_use' => array( 'type' => 'boolean', 'description' => __( 'Whether it cannot be combined with other coupons.', 'acrossai-abilities-manager' ) ), 'free_shipping' => array( 'type' => 'boolean', 'description' => __( 'Whether it grants free shipping.', 'acrossai-abilities-manager' ) ), 'product_ids' => array( 'type' => 'array', 'items' => array( 'type' => 'integer' ), 'description' => __( 'Restrict to these products.', 'acrossai-abilities-manager' ) ), 'excluded_product_ids' => array( 'type' => 'array', 'items' => array( 'type' => 'integer' ), 'description' => __( 'Exclude these products.', 'acrossai-abilities-manager' ) ), 'product_categories' => array( 'type' => 'array', 'items' => array( 'type' => 'integer' ), 'description' => __( 'Restrict to these categories.', 'acrossai-abilities-manager' ) ), ); } /** * @since 0.0.34 * @return array */ protected function required_input(): array { return array( 'code' ); } /** * @since 0.0.34 * @return array */ protected function output_properties(): array { return array( 'coupon' => array( 'type' => 'object', 'additionalProperties' => true ), ); } /** * @since 0.0.34 * @return array */ protected function annotations(): array { return array( 'readonly' => false, 'destructive' => false, 'idempotent' => false, ); } /** * @since 0.0.34 * @param array $input Input. * @return array|WP_Error */ protected function run( array $input ) { return Config_Repository::save_coupon( $input, true ); } }