__( 'Create Product Draft', 'ai-content-generator-for-woocommerce' ), 'description' => __( 'Creates a new WooCommerce simple product saved as a draft. Always draft — content must be reviewed by a human before publishing.', 'ai-content-generator-for-woocommerce' ), 'category' => 'webtoffee-ai-content', 'input_schema' => self::product_input_schema(), 'output_schema'=> self::product_output_schema(), 'execute_callback' => array( $this, 'execute_create_product_draft' ), 'permission_callback' => array( $this, 'permission_manage_woocommerce' ), 'meta' => array( 'show_in_rest' => true, 'mcp' => array( 'public' => true ) ), ) ); } private function register_create_product_published() { if ( ! function_exists( 'wp_register_ability' ) ) { return; } wp_register_ability( 'webtoffee-ai/create-product-published', array( 'label' => __( 'Create & Publish Product', 'ai-content-generator-for-woocommerce' ), 'description' => __( 'Creates a new WooCommerce simple product and immediately publishes it. Use only when content has already been reviewed.', 'ai-content-generator-for-woocommerce' ), 'category' => 'webtoffee-ai-content', 'input_schema' => self::product_input_schema(), 'output_schema'=> self::product_output_schema(), 'execute_callback' => array( $this, 'execute_create_product_published' ), 'permission_callback' => array( $this, 'permission_manage_woocommerce' ), 'meta' => array( 'show_in_rest' => true, 'mcp' => array( 'public' => true ) ), ) ); } private function register_publish_product_draft() { if ( ! function_exists( 'wp_register_ability' ) ) { return; } wp_register_ability( 'webtoffee-ai/publish-product-draft', array( 'label' => __( 'Publish Product Draft', 'ai-content-generator-for-woocommerce' ), 'description' => __( 'Changes the status of an existing draft product to published.', 'ai-content-generator-for-woocommerce' ), 'category' => 'webtoffee-ai-content', 'input_schema' => array( 'type' => 'object', 'required' => array( 'product_id' ), 'properties' => array( 'product_id' => array( 'type' => 'integer', 'description' => __( 'The WooCommerce product post ID to publish.', 'ai-content-generator-for-woocommerce' ), ), ), ), 'output_schema' => array( 'type' => 'object', 'properties' => array( 'success' => array( 'type' => 'boolean' ), 'product_id' => array( 'type' => 'integer' ), 'message' => array( 'type' => 'string' ), 'edit_url' => array( 'type' => array( 'string', 'null' ) ), ), ), 'execute_callback' => array( $this, 'execute_publish_product_draft' ), 'permission_callback' => array( $this, 'permission_manage_woocommerce' ), 'meta' => array( 'show_in_rest' => true, 'mcp' => array( 'public' => true ) ), ) ); } private function register_create_shop_coupon() { if ( ! function_exists( 'wp_register_ability' ) ) { return; } wp_register_ability( 'webtoffee-ai/create-shop-coupon', array( 'label' => __( 'Create Shop Coupon', 'ai-content-generator-for-woocommerce' ), 'description' => __( 'Creates a WooCommerce coupon: set the coupon title (code customers enter), discount as a fixed amount or percentage, and optional fixed scope (whole cart vs per matching product).', 'ai-content-generator-for-woocommerce' ), 'category' => 'webtoffee-ai-content', 'input_schema' => array( 'type' => 'object', 'required' => array( 'title', 'discount_type', 'amount' ), 'properties' => array( 'title' => array( 'type' => 'string', 'description' => __( 'Coupon title — becomes the coupon code at checkout (WooCommerce will normalize casing/spacing).', 'ai-content-generator-for-woocommerce' ), ), 'discount_type' => array( 'type' => 'string', 'enum' => array( 'percent', 'fixed' ), 'description' => __( 'percent: amount is a percentage off (1–100). fixed: amount is a fixed discount in the store currency.', 'ai-content-generator-for-woocommerce' ), ), 'amount' => array( 'type' => 'number', 'description' => __( 'Discount value: percentage (1–100) when discount_type is percent, or a positive fixed amount when discount_type is fixed.', 'ai-content-generator-for-woocommerce' ), ), 'fixed_scope' => array( 'type' => 'string', 'enum' => array( 'cart', 'product' ), 'default' => 'cart', 'description' => __( 'Only when discount_type is fixed: cart = fixed_cart (discount on cart total), product = fixed_product (per eligible line item).', 'ai-content-generator-for-woocommerce' ), ), ), ), 'output_schema' => array( 'type' => 'object', 'properties' => array( 'success' => array( 'type' => 'boolean', 'description' => __( 'Whether the coupon was created.', 'ai-content-generator-for-woocommerce' ), ), 'coupon_id' => array( 'type' => array( 'integer', 'null' ), 'description' => __( 'The shop_coupon post ID, or null on failure.', 'ai-content-generator-for-woocommerce' ), ), 'code' => array( 'type' => 'string', 'description' => __( 'The normalized coupon code.', 'ai-content-generator-for-woocommerce' ), ), 'message' => array( 'type' => 'string', 'description' => __( 'Human-readable result message.', 'ai-content-generator-for-woocommerce' ), ), 'edit_url' => array( 'type' => array( 'string', 'null' ), 'description' => __( 'Link to edit the coupon in wp-admin, or null.', 'ai-content-generator-for-woocommerce' ), ), ), ), 'execute_callback' => array( $this, 'execute_create_shop_coupon' ), 'permission_callback' => array( $this, 'permission_manage_woocommerce' ), 'meta' => array( 'show_in_rest' => true, 'mcp' => array( 'public' => true ) ), ) ); } private function register_search_product_id() { if ( ! function_exists( 'wp_register_ability' ) ) { return; } wp_register_ability( 'webtoffee-ai/search-product-id', array( 'label' => __( 'Search Product ID', 'ai-content-generator-for-woocommerce' ), 'description' => __( 'Searches for WooCommerce products by name and returns their IDs. Crucial for finding exact product IDs to use in BOGO creation or other operations.', 'ai-content-generator-for-woocommerce' ), 'category' => 'webtoffee-ai-content', 'input_schema' => array( 'type' => 'object', 'required' => array( 'search_term' ), 'properties' => array( 'search_term' => array( 'type' => 'string', 'description' => __( 'The name or partial name of the product to search for (e.g., "washing machine").', 'ai-content-generator-for-woocommerce' ), ), ), ), 'output_schema' => array( 'type' => 'array', 'items' => array( 'type' => 'object', 'properties' => array( 'id' => array( 'type' => 'integer' ), 'name' => array( 'type' => 'string' ), 'type' => array( 'type' => 'string' ), ), ), ), 'execute_callback' => array( $this, 'execute_search_product_id' ), 'permission_callback' => array( $this, 'permission_manage_woocommerce' ), 'meta' => array( 'show_in_rest' => true, 'mcp' => array( 'public' => true ) ), ) ); } private function register_update_product() { if ( ! function_exists( 'wp_register_ability' ) ) { return; } wp_register_ability( 'webtoffee-ai/update-product', array( 'label' => __( 'Update Product', 'ai-content-generator-for-woocommerce' ), 'description' => __( 'Updates fields on an existing WooCommerce product. Only supplied fields are changed.', 'ai-content-generator-for-woocommerce' ), 'category' => 'webtoffee-ai-content', 'input_schema' => array( 'type' => 'object', 'required' => array( 'product_id' ), 'properties' => array_merge( array( 'product_id' => array( 'type' => 'integer', 'description' => __( 'The WooCommerce product post ID to update.', 'ai-content-generator-for-woocommerce' ), ), 'status' => array( 'type' => 'string', 'enum' => array( 'draft', 'publish', 'pending', 'private' ), 'description' => __( 'New post status.', 'ai-content-generator-for-woocommerce' ), ), ), self::product_input_schema()['properties'] ), ), 'output_schema' => self::product_output_schema(), 'execute_callback' => array( $this, 'execute_update_product' ), 'permission_callback' => array( $this, 'permission_manage_woocommerce' ), 'meta' => array( 'show_in_rest' => true, 'mcp' => array( 'public' => true ) ), ) ); } private function register_delete_product() { if ( ! function_exists( 'wp_register_ability' ) ) { return; } wp_register_ability( 'webtoffee-ai/delete-product', array( 'label' => __( 'Delete Product', 'ai-content-generator-for-woocommerce' ), 'description' => __( 'Moves a WooCommerce product to the trash. Optionally force-deletes it permanently.', 'ai-content-generator-for-woocommerce' ), 'category' => 'webtoffee-ai-content', 'input_schema' => array( 'type' => 'object', 'required' => array( 'product_id' ), 'properties' => array( 'product_id' => array( 'type' => 'integer', 'description' => __( 'The WooCommerce product post ID to delete.', 'ai-content-generator-for-woocommerce' ), ), 'force_delete' => array( 'type' => 'boolean', 'default' => false, 'description' => __( 'Set to true to permanently delete instead of trash.', 'ai-content-generator-for-woocommerce' ), ), ), ), 'output_schema' => array( 'type' => 'object', 'properties' => array( 'success' => array( 'type' => 'boolean' ), 'product_id' => array( 'type' => 'integer' ), 'message' => array( 'type' => 'string' ), ), ), 'execute_callback' => array( $this, 'execute_delete_product' ), 'permission_callback' => array( $this, 'permission_manage_woocommerce' ), 'meta' => array( 'show_in_rest' => true, 'mcp' => array( 'public' => true ) ), ) ); } private function register_update_order_status() { if ( ! function_exists( 'wp_register_ability' ) ) { return; } wp_register_ability( 'webtoffee-ai/update-order-status', array( 'label' => __( 'Update Order Status', 'ai-content-generator-for-woocommerce' ), 'description' => __( 'Changes the status of a WooCommerce order and optionally appends a note.', 'ai-content-generator-for-woocommerce' ), 'category' => 'webtoffee-ai-content', 'input_schema' => array( 'type' => 'object', 'required' => array( 'order_id', 'new_status' ), 'properties' => array( 'order_id' => array( 'type' => 'integer', 'description' => __( 'The WooCommerce order ID.', 'ai-content-generator-for-woocommerce' ), ), 'new_status' => array( 'type' => 'string', 'description' => __( 'Target order status slug without "wc-" prefix (e.g. "completed", "cancelled", "processing").', 'ai-content-generator-for-woocommerce' ), ), 'note' => array( 'type' => 'string', 'default' => '', 'description' => __( 'Optional note to append to the order.', 'ai-content-generator-for-woocommerce' ), ), ), ), 'output_schema' => array( 'type' => 'object', 'properties' => array( 'success' => array( 'type' => 'boolean' ), 'order_id' => array( 'type' => 'integer' ), 'old_status' => array( 'type' => 'string' ), 'new_status' => array( 'type' => 'string' ), 'message' => array( 'type' => 'string' ), ), ), 'execute_callback' => array( $this, 'execute_update_order_status' ), 'permission_callback' => array( $this, 'permission_manage_woocommerce' ), 'meta' => array( 'show_in_rest' => true, 'mcp' => array( 'public' => true ) ), ) ); } }