*/ protected function input_properties(): array { return array( 'code' => array( 'type' => 'string', 'description' => __( 'The code of the coupon to change.', 'acrossai-abilities-manager' ) ), 'discount_type' => array( 'type' => 'string', 'description' => __( 'percent, fixed_cart or fixed_product.', 'acrossai-abilities-manager' ) ), 'amount' => array( 'type' => 'string', 'description' => __( 'The discount amount.', 'acrossai-abilities-manager' ) ), 'description' => array( 'type' => 'string', 'description' => __( 'Internal description.', 'acrossai-abilities-manager' ) ), 'date_expires' => array( 'type' => 'string', 'description' => __( 'Expiry date, YYYY-MM-DD. Empty string removes it.', '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.', 'acrossai-abilities-manager' ) ), 'maximum_amount' => array( 'type' => 'string', 'description' => __( 'Maximum cart total.', 'acrossai-abilities-manager' ) ), 'individual_use' => array( 'type' => 'boolean', 'description' => __( 'Cannot be combined with other coupons.', 'acrossai-abilities-manager' ) ), 'free_shipping' => array( 'type' => 'boolean', 'description' => __( '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' => true, ); } /** * @since 0.0.34 * @param array $input Input. * @return array|WP_Error */ protected function run( array $input ) { return Config_Repository::save_coupon( $input, false ); } }