From dcb61341e9b2ae07a817f0a589679c0dc43779da Mon Sep 17 00:00:00 2001 From: pronob1010 Date: Tue, 19 Nov 2024 10:42:36 +0600 Subject: [PATCH 1/5] fix: args for /dokan/v1/stores/check --- includes/REST/StoreController.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/includes/REST/StoreController.php b/includes/REST/StoreController.php index f6d71edafc..da566f6666 100644 --- a/includes/REST/StoreController.php +++ b/includes/REST/StoreController.php @@ -131,6 +131,24 @@ public function register_routes() { 'methods' => WP_REST_Server::READABLE, 'callback' => [ $this, 'check_store_availability' ], 'permission_callback' => '__return_true', + 'args' => [ + 'store_slug' => [ + 'required' => false, + 'type' => 'string', + 'description' => __('Slug of the store to check availability.', 'dokan-lite'), + ], + 'username' => [ + 'required' => false, + 'type' => 'string', + 'description' => __('Username to check availability.', 'dokan-lite'), + ], + 'email' => [ + 'required' => false, + 'type' => 'string', + 'description' => __('Email address to check availability.', 'dokan-lite'), + 'format' => 'email', + ], + ], ], ] ); From 15e49f4cebb9e5b63552e76de86745964ec121d6 Mon Sep 17 00:00:00 2001 From: pronob1010 Date: Mon, 25 Nov 2024 10:59:15 +0600 Subject: [PATCH 2/5] feat : /dokan/v1/stores :POST args added --- includes/REST/StoreController.php | 99 ++++++++++++++++++++++++++++++- 1 file changed, 96 insertions(+), 3 deletions(-) diff --git a/includes/REST/StoreController.php b/includes/REST/StoreController.php index da566f6666..900c49a300 100644 --- a/includes/REST/StoreController.php +++ b/includes/REST/StoreController.php @@ -52,6 +52,99 @@ public function register_routes() { 'methods' => WP_REST_Server::CREATABLE, 'callback' => [ $this, 'create_store' ], 'permission_callback' => [ $this, 'permission_check_for_manageable_part' ], + 'args' => [ + 'user_login' => [ + 'required' => false, + 'type' => 'string', + 'description' => __( 'The username for the store owner. If not provided, it will be auto-generated.', 'dokan-lite' ), + ], + 'email' => [ + 'required' => true, + 'type' => 'string', + 'format' => 'email', + 'description' => __( 'The email address for the store owner.', 'dokan-lite' ), + ], + 'store_name' => [ + 'required' => true, + 'type' => 'string', + 'description' => __( 'The name of the store.', 'dokan-lite' ), + ], + 'social' => [ + 'required' => false, + 'type' => 'array', + 'description' => __( 'An array of social media details for the store.', 'dokan-lite' ), + ], + 'payment' => [ + 'required' => false, + 'type' => 'array', + 'description' => __( 'Payment details for the store. E.g., PayPal or bank details.', 'dokan-lite' ), + ], + 'phone' => [ + 'required' => false, + 'type' => 'string', + 'description' => __( 'The contact phone number for the store.', 'dokan-lite' ), + ], + 'show_email' => [ + 'required' => false, + 'type' => 'string', // Updated from boolean + 'description' => __( 'Whether to show the store email publicly.', 'dokan-lite' ), + ], + 'address' => [ + 'required' => false, + 'type' => 'array', + 'description' => __( 'Address details of the store.', 'dokan-lite' ), + ], + 'location' => [ // Newly added + 'required' => false, + 'type' => 'string', + 'description' => __( 'Geographical location of the store.', 'dokan-lite' ), + ], + 'banner_id' => [ + 'required' => false, + 'type' => 'integer', + 'description' => __( 'ID of the banner image for the store.', 'dokan-lite' ), + ], + 'icon' => [ + 'required' => false, + 'type' => 'string', + 'description' => __( 'URL of the icon image for the store.', 'dokan-lite' ), + ], + 'gravatar_id' => [ + 'required' => false, + 'type' => 'integer', + 'description' => __( 'ID of the gravatar image for the store.', 'dokan-lite' ), + ], + 'enable_tnc' => [ + 'required' => false, + 'type' => 'string', // Updated from boolean + 'description' => __( 'Enable Terms and Conditions for the store.', 'dokan-lite' ), + ], + 'store_tnc' => [ + 'required' => false, + 'type' => 'string', + 'description' => __( 'Terms and Conditions text for the store.', 'dokan-lite' ), + ], + 'show_min_order_discount' => [ + 'required' => false, + 'type' => 'string', // Updated from boolean + 'description' => __( 'Whether to show minimum order discount information.', 'dokan-lite' ), + ], + 'store_seo' => [ + 'required' => false, + 'type' => 'array', + 'description' => __( 'SEO metadata for the store.', 'dokan-lite' ), + ], + 'store_open_close' => [ + 'required' => false, + 'type' => 'array', + 'description' => __( 'Opening and closing times for the store.', 'dokan-lite' ), + ], + 'notify_vendor' => [ + 'required' => false, + 'type' => 'boolean', + 'description' => __( 'Whether to notify the vendor after creation.', 'dokan-lite' ), + ], + ], ], ] ); @@ -135,17 +228,17 @@ public function register_routes() { 'store_slug' => [ 'required' => false, 'type' => 'string', - 'description' => __('Slug of the store to check availability.', 'dokan-lite'), + 'description' => __( 'Slug of the store to check availability.', 'dokan-lite' ), ], 'username' => [ 'required' => false, 'type' => 'string', - 'description' => __('Username to check availability.', 'dokan-lite'), + 'description' => __( 'Username to check availability.', 'dokan-lite' ), ], 'email' => [ 'required' => false, 'type' => 'string', - 'description' => __('Email address to check availability.', 'dokan-lite'), + 'description' => __( 'Email address to check availability.', 'dokan-lite' ), 'format' => 'email', ], ], From 2f8552c6827275bdfe57c2044862e2bc646d8fc4 Mon Sep 17 00:00:00 2001 From: pronob1010 Date: Mon, 25 Nov 2024 11:28:43 +0600 Subject: [PATCH 3/5] feat: args added to /dokan/v1/stores/batch(POST, PUT,PATCH) --- includes/REST/StoreController.php | 34 +++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/includes/REST/StoreController.php b/includes/REST/StoreController.php index 900c49a300..cba0c55dea 100644 --- a/includes/REST/StoreController.php +++ b/includes/REST/StoreController.php @@ -86,7 +86,7 @@ public function register_routes() { ], 'show_email' => [ 'required' => false, - 'type' => 'string', // Updated from boolean + 'type' => 'string', 'description' => __( 'Whether to show the store email publicly.', 'dokan-lite' ), ], 'address' => [ @@ -94,7 +94,7 @@ public function register_routes() { 'type' => 'array', 'description' => __( 'Address details of the store.', 'dokan-lite' ), ], - 'location' => [ // Newly added + 'location' => [ 'required' => false, 'type' => 'string', 'description' => __( 'Geographical location of the store.', 'dokan-lite' ), @@ -116,7 +116,7 @@ public function register_routes() { ], 'enable_tnc' => [ 'required' => false, - 'type' => 'string', // Updated from boolean + 'type' => 'string', 'description' => __( 'Enable Terms and Conditions for the store.', 'dokan-lite' ), ], 'store_tnc' => [ @@ -126,7 +126,7 @@ public function register_routes() { ], 'show_min_order_discount' => [ 'required' => false, - 'type' => 'string', // Updated from boolean + 'type' => 'string', 'description' => __( 'Whether to show minimum order discount information.', 'dokan-lite' ), ], 'store_seo' => [ @@ -308,6 +308,32 @@ public function register_routes() { 'methods' => WP_REST_Server::EDITABLE, 'callback' => [ $this, 'batch_update' ], 'permission_callback' => [ $this, 'permission_check_for_manageable_part' ], + 'args' => [ + 'approved' => [ + 'type' => 'array', + 'required' => false, + 'items' => [ + 'type' => 'integer', + ], + 'description' => __( 'List of vendor IDs to approve.', 'dokan-lite' ), + ], + 'pending' => [ + 'type' => 'array', + 'required' => false, + 'items' => [ + 'type' => 'integer', + ], + 'description' => __( 'List of vendor IDs to set as pending.', 'dokan-lite' ), + ], + 'delete' => [ + 'type' => 'array', + 'required' => false, + 'items' => [ + 'type' => 'integer', + ], + 'description' => __( 'List of vendor IDs to delete.', 'dokan-lite' ), + ], + ], ], ] ); From f66cd93019a690b69e283f878c4295f34f66d650 Mon Sep 17 00:00:00 2001 From: pronob1010 Date: Tue, 31 Dec 2024 09:58:03 +0600 Subject: [PATCH 4/5] fix: array types as ref --- includes/REST/StoreController.php | 38 +++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/includes/REST/StoreController.php b/includes/REST/StoreController.php index cba0c55dea..9c8dd53779 100644 --- a/includes/REST/StoreController.php +++ b/includes/REST/StoreController.php @@ -52,7 +52,7 @@ public function register_routes() { 'methods' => WP_REST_Server::CREATABLE, 'callback' => [ $this, 'create_store' ], 'permission_callback' => [ $this, 'permission_check_for_manageable_part' ], - 'args' => [ + 'args' => [ 'user_login' => [ 'required' => false, 'type' => 'string', @@ -72,11 +72,28 @@ public function register_routes() { 'social' => [ 'required' => false, 'type' => 'array', + 'items' => [ + 'type' => 'string' + ], 'description' => __( 'An array of social media details for the store.', 'dokan-lite' ), ], 'payment' => [ 'required' => false, - 'type' => 'array', + 'type' => 'object', + 'properties' => array( + 'paypal' => array( + 'type' => 'array', + 'items' => array( + 'type' => 'string' + ) + ), + 'bank' => array( + 'type' => 'array', + 'items' => array( + 'type' => 'string' + ) + ) + ), 'description' => __( 'Payment details for the store. E.g., PayPal or bank details.', 'dokan-lite' ), ], 'phone' => [ @@ -92,6 +109,9 @@ public function register_routes() { 'address' => [ 'required' => false, 'type' => 'array', + 'items' => [ + 'type' => 'string' + ], 'description' => __( 'Address details of the store.', 'dokan-lite' ), ], 'location' => [ @@ -132,11 +152,25 @@ public function register_routes() { 'store_seo' => [ 'required' => false, 'type' => 'array', + 'items' => [ + 'type' => 'string' + ], 'description' => __( 'SEO metadata for the store.', 'dokan-lite' ), ], 'store_open_close' => [ 'required' => false, 'type' => 'array', + 'items' => array( + 'type' => 'object', + 'properties' => array( + 'day' => array( + 'type' => 'array', + 'items' => array( + 'type' => 'string' + ) + ) + ) + ), 'description' => __( 'Opening and closing times for the store.', 'dokan-lite' ), ], 'notify_vendor' => [ From aa44814069f8f82657135e381c2ff37c9e8b86b6 Mon Sep 17 00:00:00 2001 From: pronob1010 Date: Tue, 31 Dec 2024 10:00:25 +0600 Subject: [PATCH 5/5] fix: phpcs issues --- includes/REST/StoreController.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/includes/REST/StoreController.php b/includes/REST/StoreController.php index 9c8dd53779..28617e06ac 100644 --- a/includes/REST/StoreController.php +++ b/includes/REST/StoreController.php @@ -73,7 +73,7 @@ public function register_routes() { 'required' => false, 'type' => 'array', 'items' => [ - 'type' => 'string' + 'type' => 'string', ], 'description' => __( 'An array of social media details for the store.', 'dokan-lite' ), ], @@ -84,13 +84,13 @@ public function register_routes() { 'paypal' => array( 'type' => 'array', 'items' => array( - 'type' => 'string' + 'type' => 'string', ) ), 'bank' => array( 'type' => 'array', 'items' => array( - 'type' => 'string' + 'type' => 'string', ) ) ), @@ -166,7 +166,7 @@ public function register_routes() { 'day' => array( 'type' => 'array', 'items' => array( - 'type' => 'string' + 'type' => 'string', ) ) )