__( 'Create BOGO Coupon', 'ai-content-generator-for-woocommerce' ), 'description' => __( 'Creates a new Buy-One-Get-One (BOGO) coupon. Use predefined templates or select "custom" to pass specific product IDs and dynamic discount values.', 'ai-content-generator-for-woocommerce' ), 'category' => 'webtoffee-ai-content', 'input_schema' => array( 'type' => 'object', 'required' => array( 'coupon_name', 'campaign_type' ), 'properties' => array( 'coupon_name' => array( 'type' => 'string', 'description' => __( 'The human-readable name of the BOGO campaign.', 'ai-content-generator-for-woocommerce' ), ), 'campaign_type' => array( 'type' => 'string', 'enum' => array( 'default_1', 'default_2', 'default_3', 'custom' ), 'description' => __( 'Template to use. default_1: Buy X get Y at 50% off. default_2: Buy 2 get 1 free. default_3: Spend X get a free gift. custom: Use this for specific queries like "Buy Product A get Product B" and fill out the dynamic fields below.', 'ai-content-generator-for-woocommerce' ), ), 'status' => array( 'type' => 'string', 'enum' => array( 'draft', 'publish' ), 'default' => 'publish', 'description' => __( 'The post status of the new coupon.', 'ai-content-generator-for-woocommerce' ), ), 'description' => array( 'type' => 'string', 'description' => __( 'Optional description for the BOGO coupon.', 'ai-content-generator-for-woocommerce' ), ), 'conversion' => array( 'type' => 'string', 'enum' => array( 'auto', 'manual' ), 'default' => 'auto', 'description' => __( 'How the coupon is applied: "auto" (applies automatically) or "manual" (requires code).', 'ai-content-generator-for-woocommerce' ), ), 'start_date' => array( 'type' => 'string', 'description' => __( 'Start date in YYYY-MM-DD format. Leave empty for no start date.', 'ai-content-generator-for-woocommerce' ), ), 'expiry_date' => array( 'type' => 'string', 'description' => __( 'Expiry date in YYYY-MM-DD format. Leave empty for no expiry.', 'ai-content-generator-for-woocommerce' ), ), // Dynamic fields for "custom" campaign type 'buy_product_ids' => array( 'type' => 'array', 'items' => array( 'type' => 'integer' ), 'description' => __( 'Used if campaign_type is custom. Array of WooCommerce product IDs the customer must buy.', 'ai-content-generator-for-woocommerce' ), ), 'buy_quantity' => array( 'type' => 'integer', 'default' => 1, 'description' => __( 'Used if campaign_type is custom. Minimum quantity the customer must buy.', 'ai-content-generator-for-woocommerce' ), ), 'get_product_ids' => array( 'type' => 'array', 'items' => array( 'type' => 'integer' ), 'description' => __( 'Used if campaign_type is custom. Array of WooCommerce product IDs the customer receives as the offer.', 'ai-content-generator-for-woocommerce' ), ), 'get_quantity' => array( 'type' => 'integer', 'default' => 1, 'description' => __( 'Used if campaign_type is custom. Quantity of the offer product the customer receives.', 'ai-content-generator-for-woocommerce' ), ), 'discount_type' => array( 'type' => 'string', 'enum' => array( 'free', 'percent', 'fixed' ), 'default' => 'free', 'description' => __( 'Used if campaign_type is custom. How the "Get" product is discounted.', 'ai-content-generator-for-woocommerce' ), ), 'discount_value' => array( 'type' => 'number', 'description' => __( 'Used if campaign_type is custom. The discount value if discount_type is percent or fixed.', 'ai-content-generator-for-woocommerce' ), ), ), ), 'output_schema' => array( 'type' => 'object', 'properties' => array( 'success' => array( 'type' => 'boolean' ), 'coupon_id' => array( 'type' => array( 'integer', 'null' ) ), 'coupon_code' => array( 'type' => 'string' ), 'edit_url' => array( 'type' => array( 'string', 'null' ) ), 'message' => array( 'type' => 'string' ), ), ), 'execute_callback' => array( $this, 'execute_create_bogo' ), 'permission_callback' => array( $this, 'permission_manage_woocommerce' ), 'meta' => array( 'show_in_rest' => true, 'mcp' => array( 'public' => true ) ), ) ); } private function register_trash_bogo() { if ( ! function_exists( 'wp_register_ability' ) ) { return; } wp_register_ability( 'webtoffee-ai/trash-bogo', array( 'label' => __( 'Trash BOGO Coupon', 'ai-content-generator-for-woocommerce' ), 'description' => __( 'Moves an existing BOGO coupon to the trash.', 'ai-content-generator-for-woocommerce' ), 'category' => 'webtoffee-ai-content', 'input_schema' => array( 'type' => 'object', 'required' => array( 'coupon_id' ), 'properties' => array( 'coupon_id' => array( 'type' => 'integer', 'description' => __( 'The WooCommerce coupon post ID to trash.', 'ai-content-generator-for-woocommerce' ), ), ), ), 'output_schema' => array( 'type' => 'boolean', 'description' => __( 'True if the coupon was successfully trashed.', 'ai-content-generator-for-woocommerce' ), ), 'execute_callback' => array( $this, 'execute_trash_bogo' ), 'permission_callback' => array( $this, 'permission_manage_woocommerce' ), 'meta' => array( 'show_in_rest' => true, 'mcp' => array( 'public' => true ) ), ) ); } private function register_list_bogos() { if ( ! function_exists( 'wp_register_ability' ) ) { return; } wp_register_ability( 'webtoffee-ai/list-bogos', array( 'label' => __( 'List BOGO Coupons', 'ai-content-generator-for-woocommerce' ), 'description' => __( 'Retrieves a list of active BOGO coupons.', 'ai-content-generator-for-woocommerce' ), 'category' => 'webtoffee-ai-content', 'input_schema' => array( 'type' => 'object', 'properties' => array( 'limit' => array( 'type' => 'integer', 'default' => 20, 'description' => __( 'Number of coupons to return.', 'ai-content-generator-for-woocommerce' ), ), ), ), 'output_schema' => array( 'type' => 'array', 'items' => array( 'type' => 'object', 'properties' => array( 'id' => array( 'type' => 'integer' ), 'code' => array( 'type' => 'string' ), 'name' => array( 'type' => 'string' ), ) ), ), 'execute_callback' => array( $this, 'execute_list_bogos' ), 'permission_callback' => array( $this, 'permission_manage_woocommerce' ), 'meta' => array( 'show_in_rest' => true, 'mcp' => array( 'public' => true ) ), ) ); } private function register_toggle_bogo_status() { if ( ! function_exists( 'wp_register_ability' ) ) { return; } wp_register_ability( 'webtoffee-ai/toggle-bogo', array( 'label' => __( 'Toggle BOGO Status', 'ai-content-generator-for-woocommerce' ), 'description' => __( 'Enables (publishes) or disables (drafts) an existing BOGO coupon.', 'ai-content-generator-for-woocommerce' ), 'category' => 'webtoffee-ai-content', 'input_schema' => array( 'type' => 'object', 'required' => array( 'coupon_id', 'is_active' ), 'properties' => array( 'coupon_id' => array( 'type' => 'integer', 'description' => __( 'The WooCommerce BOGO coupon post ID.', 'ai-content-generator-for-woocommerce' ), ), 'is_active' => array( 'type' => 'boolean', 'description' => __( 'True to enable (publish), false to disable (draft).', 'ai-content-generator-for-woocommerce' ), ), ), ), 'output_schema' => array( 'type' => 'boolean', 'description' => __( 'True if the status was successfully updated.', 'ai-content-generator-for-woocommerce' ), ), 'execute_callback' => array( $this, 'execute_toggle_bogo_status' ), 'permission_callback' => array( $this, 'permission_manage_woocommerce' ), 'meta' => array( 'show_in_rest' => true, 'mcp' => array( 'public' => true ) ), ) ); } private function register_restore_bogo() { if ( ! function_exists( 'wp_register_ability' ) ) { return; } wp_register_ability( 'webtoffee-ai/restore-bogo', array( 'label' => __( 'Restore BOGO Coupon', 'ai-content-generator-for-woocommerce' ), 'description' => __( 'Restores a trashed BOGO coupon back to active (publish) status.', 'ai-content-generator-for-woocommerce' ), 'category' => 'webtoffee-ai-content', 'input_schema' => array( 'type' => 'object', 'required' => array( 'coupon_id' ), 'properties' => array( 'coupon_id' => array( 'type' => 'integer', 'description' => __( 'The trashed BOGO coupon post ID.', 'ai-content-generator-for-woocommerce' ), ), ), ), 'output_schema' => array( 'type' => 'boolean', 'description' => __( 'True if the coupon was restored successfully.', 'ai-content-generator-for-woocommerce' ), ), 'execute_callback' => array( $this, 'execute_restore_bogo' ), 'permission_callback' => array( $this, 'permission_manage_woocommerce' ), 'meta' => array( 'show_in_rest' => true, 'mcp' => array( 'public' => true ) ), ) ); } private function register_delete_bogo_permanently() { if ( ! function_exists( 'wp_register_ability' ) ) { return; } wp_register_ability( 'webtoffee-ai/delete-bogo', array( 'label' => __( 'Delete BOGO Permanently', 'ai-content-generator-for-woocommerce' ), 'description' => __( 'Permanently deletes a BOGO coupon from the database.', 'ai-content-generator-for-woocommerce' ), 'category' => 'webtoffee-ai-content', 'input_schema' => array( 'type' => 'object', 'required' => array( 'coupon_id' ), 'properties' => array( 'coupon_id' => array( 'type' => 'integer', 'description' => __( 'The BOGO coupon post ID to permanently delete.', 'ai-content-generator-for-woocommerce' ), ), ), ), 'output_schema' => array( 'type' => 'boolean', 'description' => __( 'True if the coupon was permanently deleted.', 'ai-content-generator-for-woocommerce' ), ), 'execute_callback' => array( $this, 'execute_delete_bogo_permanently' ), 'permission_callback' => array( $this, 'permission_manage_woocommerce' ), 'meta' => array( 'show_in_rest' => true, 'mcp' => array( 'public' => true ) ), ) ); } private function register_duplicate_bogo() { if ( ! function_exists( 'wp_register_ability' ) ) { return; } wp_register_ability( 'webtoffee-ai/duplicate-bogo', array( 'label' => __( 'Duplicate BOGO Coupon', 'ai-content-generator-for-woocommerce' ), 'description' => __( 'Duplicates an existing BOGO coupon and saves the copy as a draft.', 'ai-content-generator-for-woocommerce' ), 'category' => 'webtoffee-ai-content', 'input_schema' => array( 'type' => 'object', 'required' => array( 'coupon_id' ), 'properties' => array( 'coupon_id' => array( 'type' => 'integer', 'description' => __( 'The BOGO coupon post ID to duplicate.', 'ai-content-generator-for-woocommerce' ), ), ), ), 'output_schema' => array( 'type' => 'object', 'properties' => array( 'success' => array( 'type' => 'boolean' ), 'new_id' => array( 'type' => array( 'integer', 'null' ) ), 'new_code' => array( 'type' => 'string' ), 'message' => array( 'type' => 'string' ), ), ), 'execute_callback' => array( $this, 'execute_duplicate_bogo' ), 'permission_callback' => array( $this, 'permission_manage_woocommerce' ), 'meta' => array( 'show_in_rest' => true, 'mcp' => array( 'public' => true ) ), ) ); } /** * Shared input schema for both create-product abilities. * Mirrors all fields in the WooCommerce standard CSV format. * * @return array */ private static function product_input_schema() { return array( 'type' => 'object', 'required' => array( 'title' ), 'properties' => array( 'title' => array( 'type' => 'string', 'description' => __( 'Product name.', 'ai-content-generator-for-woocommerce' ), ), 'description' => array( 'type' => 'string', 'description' => __( 'Full HTML product description (post_content).', 'ai-content-generator-for-woocommerce' ), ), 'short_description' => array( 'type' => 'string', 'description' => __( 'Short product description / excerpt (post_excerpt).', 'ai-content-generator-for-woocommerce' ), ), 'sku' => array( 'type' => 'string', 'description' => __( 'Stock Keeping Unit identifier.', 'ai-content-generator-for-woocommerce' ), ), 'regular_price' => array( 'type' => 'string', 'description' => __( 'Regular price — numbers only, no currency symbols.', 'ai-content-generator-for-woocommerce' ), ), 'sale_price' => array( 'type' => 'string', 'description' => __( 'Sale price — numbers only. Leave empty if no sale.', 'ai-content-generator-for-woocommerce' ), ), 'stock_status' => array( 'type' => 'string', 'enum' => array( 'instock', 'outofstock', 'onbackorder' ), 'default' => 'instock', 'description' => __( 'Stock availability status.', 'ai-content-generator-for-woocommerce' ), ), 'stock' => array( 'type' => 'integer', 'description' => __( 'Stock quantity. Requires manage_stock to be true.', 'ai-content-generator-for-woocommerce' ), ), 'manage_stock' => array( 'type' => 'boolean', 'default' => false, 'description' => __( 'Whether to enable stock management for this product.', 'ai-content-generator-for-woocommerce' ), ), 'weight' => array( 'type' => 'string', 'description' => __( 'Product weight in the store\'s weight unit.', 'ai-content-generator-for-woocommerce' ), ), 'images' => array( 'type' => 'string', 'description' => __( 'Comma-separated image URLs. First becomes the featured image; rest become gallery images.', 'ai-content-generator-for-woocommerce' ), ), 'categories' => array( 'type' => 'string', 'description' => __( 'Pipe or comma-separated category names. e.g. "Electronics|Mobile" or "Shoes, Men\'s Shoes". Created automatically if they don\'t exist.', 'ai-content-generator-for-woocommerce' ), ), 'tags' => array( 'type' => 'string', 'description' => __( 'Pipe or comma-separated tag names. Created automatically if they don\'t exist.', 'ai-content-generator-for-woocommerce' ), ), ), ); } /** * Shared output schema for both create-product abilities. * * @return array */ private static function product_output_schema() { return array( 'type' => 'object', 'properties' => array( 'success' => array( 'type' => 'boolean', 'description' => __( 'Whether the product was created successfully.', 'ai-content-generator-for-woocommerce' ), ), 'product_id' => array( 'type' => array( 'integer', 'null' ), 'description' => __( 'The new product post ID, or null on failure.', 'ai-content-generator-for-woocommerce' ), ), 'message' => array( 'type' => 'string', 'description' => __( 'A human-readable result message.', 'ai-content-generator-for-woocommerce' ), ), 'edit_url' => array( 'type' => array( 'string', 'null' ), 'description' => __( 'Direct link to the product edit screen, or null on failure.', 'ai-content-generator-for-woocommerce' ), ), ), ); } }