Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module/form manager #2098

Open
wants to merge 126 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 121 commits
Commits
Show all changes
126 commits
Select commit Hold shift + click to select a range
f0d6e79
feat: Product form custom validation. Added support to settings secti…
devAsadNur Sep 1, 2023
2dbcde1
enhance: Added reset all button to the admin settings component
devAsadNur Sep 4, 2023
bedbe32
fix: Action button was not working
devAsadNur Sep 4, 2023
440dac1
Merge branch 'develop' into feat/product-form-custom-validation
devAsadNur Sep 5, 2023
a55be72
enhance: Added admin settings sub-section column heading support
devAsadNur Sep 7, 2023
bc789b4
enahnce: Added support for disabling field for Switches component
devAsadNur Sep 11, 2023
18057d7
fix: Styling for the settings sub heading column styles
devAsadNur Sep 11, 2023
c391f7b
Updated admin setting reset all link with button
devAsadNur Sep 20, 2023
2f430c9
Added admin settings sub-section toggle button label
devAsadNur Sep 20, 2023
3eb324c
Merge branch 'feat/product-form-custom-validation' into module/form_m…
devAsadNur Oct 9, 2023
9ada0e4
Removed extra sub-sections and moved form manager block to a separete…
devAsadNur Oct 13, 2023
7b36504
Cleaned up some unused codes
devAsadNur Oct 16, 2023
50402b0
refactor: Form manager settings section moved to Dokan Pro
devAsadNur Oct 16, 2023
d17cb3d
fix: Console error on field toggle switching
devAsadNur Nov 6, 2023
d8edffa
Added product types to the admin localized script
devAsadNur Nov 22, 2023
6f0e7f7
Added support for settings section repeater
devAsadNur Nov 28, 2023
9d90ea6
new: added skeleton for product fields feature
nurul-umbhiya Dec 1, 2023
63d0b60
Merge remote-tracking branch 'origin/develop' into refactor/dashboard…
nurul-umbhiya Dec 1, 2023
af756c6
refactor: removed `Add New Product` page and modal related codebase a…
nurul-umbhiya Dec 7, 2023
a634761
refactor: replace action hook: dokan_product_updated with filter hook…
nurul-umbhiya Dec 7, 2023
b869ff8
fix: fixed some minor issues
nurul-umbhiya Dec 7, 2023
2e410e6
Merge remote-tracking branch 'origin/develop' into refactor/dashboard…
nurul-umbhiya Dec 7, 2023
fc5ff41
🔒 chore(Product): add defined( 'ABSPATH' ) || exit; to Hooks.php and …
nurul-umbhiya Dec 8, 2023
62aa976
Merge remote-tracking branch 'origin/develop' into module/form_manager
nurul-umbhiya Dec 11, 2023
70553c5
Merge remote-tracking branch 'origin/refactor/dashboard_products' int…
nurul-umbhiya Dec 11, 2023
bb27153
update: Made general product section mandatory for product form custo…
devAsadNur Dec 12, 2023
7f2f9fb
Localized product fields data and get those from the product editor s…
devAsadNur Dec 15, 2023
dc0d791
enhance: Added asterisk symbol markup for required fields
devAsadNur Dec 26, 2023
870738d
Added missing required asterisk symbol on various fields and removed …
devAsadNur Dec 28, 2023
7475c22
update: Included argument to the 'dokan_product_form_item_created' f…
devAsadNur Dec 28, 2023
7961933
Made the input fields required from HTML end based on admin settings
devAsadNur Dec 29, 2023
f1890fa
Added support for the custom product form fields
devAsadNur Dec 29, 2023
ecdf1c4
fix: Updated input value for product title not remaining if product f…
devAsadNur Jan 3, 2024
00fe573
Added JS support for the image and other media file upload and select
devAsadNur Jan 4, 2024
aee9ca2
Enhance: Added support for date range picker for custom product fields
devAsadNur Jan 8, 2024
04239aa
Fixed date range picker desappearing issue and added support for both…
devAsadNur Jan 9, 2024
19731cb
refactor: Moved scripts related to product custom fields from Dokan L…
devAsadNur Jan 9, 2024
400cc06
new: Added some hooks in vendor dashboard product form templates
devAsadNur Jan 10, 2024
b41f4ea
enhance: Added custom fields support to the predefined product form s…
devAsadNur Jan 10, 2024
0746cd1
enahnce: Added mechanism for preserveform submission data for general…
devAsadNur Jan 11, 2024
0254f10
enhance: Added mechanism for inventory section form data upon product…
devAsadNur Jan 12, 2024
08090af
fix: Wrong value showing on date from, date to, and image thumbnil field
devAsadNur Jan 12, 2024
39ffc81
enhance: Added mechanism for Other Options section form data upon pr…
devAsadNur Jan 12, 2024
8945cb8
enhance: Added mechanism to keep downloadable section form data upon …
devAsadNur Jan 15, 2024
2598b21
Fixed styling issue of vendor dashboard product form shipping section…
devAsadNur Jan 17, 2024
a8491c0
chore: merged develop branch
devAsadNur Jan 18, 2024
889449d
fix: Missing help text for the Others section fields on vendor dashbo…
devAsadNur Jan 22, 2024
c27a0eb
Merge remote-tracking branch 'upstream/develop' into module/form_manager
devAsadNur Feb 2, 2024
afa7080
enhance: Added support for conditional dependent blocks and fields
devAsadNur Feb 9, 2024
e13028e
enhance: Made fields under inventory section conditinally dependent
devAsadNur Feb 9, 2024
acb81d2
fix: Broken style for the custom fields under downloadable section on…
devAsadNur Feb 13, 2024
581a09c
fix: Missing 'Downloadable Options' section on vendor dashboard singl…
devAsadNur Feb 13, 2024
69b8a12
fix: Disappeared price and dolownlad related input fields from vendor…
devAsadNur Feb 14, 2024
645a7ba
enhance: Added support to render product form sections based on produ…
devAsadNur Feb 15, 2024
1e399eb
enhance: Category based custom section support for vendor dashboard p…
devAsadNur Feb 16, 2024
0198461
fix: Rendering category selector multiple times on vendor dashboard p…
devAsadNur Feb 16, 2024
633b521
enhance: Added searching support to the multi-step categories API
devAsadNur Feb 20, 2024
a743cd1
fix: Caching issue for the multi-step categories seaching through API
devAsadNur Feb 22, 2024
929f5bc
refactor: Reverted searching mechanism from the multi-step categories…
devAsadNur Feb 22, 2024
70e2ea0
fix: Wrongly placed asterisk sign for requried general product fields…
devAsadNur Mar 7, 2024
58cbdba
fix: Missing help texts and some styling issues on vendor dashboard g…
devAsadNur Mar 7, 2024
239f504
fix: Tooltip issues on vendor dashboard product form fields
devAsadNur Mar 7, 2024
fa3fb9b
Merge branch 'develop' into module/form_manager
nurul-umbhiya Mar 8, 2024
8b66e38
Merge branch 'develop' into module/form_manager
devAsadNur Mar 20, 2024
1376cc7
enhance: Integrated frontend form validation to the vendor dashboard …
devAsadNur Mar 22, 2024
c4cbc84
fix: Switches on admin settings were can't be enabled after merging w…
devAsadNur Mar 25, 2024
c96ee57
fix: Error message on vendor dashboard product form frontend validation
devAsadNur Mar 29, 2024
dd45805
Remove product create popup javascript code.
Aunshon Apr 2, 2024
8d666bd
Merge branch 'develop' into module/form_manager
devAsadNur Apr 2, 2024
d4563c6
enhance: Handled backend validation for discount schedule date from a…
devAsadNur Apr 2, 2024
c72fef6
Handled downloadable options section fields backend validation based …
devAsadNur Apr 2, 2024
f1f48a9
Handled virtual and shipping related fields backend validation
devAsadNur Apr 2, 2024
ee58880
fix: Discounted price date schedule fields validation issue
devAsadNur Apr 2, 2024
d45b8e7
enhance: Integrated backend conditional validation for stock manager …
devAsadNur Apr 3, 2024
f7ce607
Merge remote-tracking branch 'upstream/module/form_manager' into modu…
devAsadNur Apr 3, 2024
bf36c8d
fix: Product form customizer settings reset button not reseting field…
devAsadNur Apr 15, 2024
a434e13
chore: variation product rewrite
nurul-umbhiya Apr 15, 2024
88cc82b
chore: rewritten product variation related php codes
nurul-umbhiya Apr 18, 2024
229139f
Merge remote-tracking branch 'origin/develop' into module/form_manager
nurul-umbhiya Apr 18, 2024
9e08b18
chore: added assets/js/dokan-tailwind.js file to gitignore
nurul-umbhiya Apr 18, 2024
5750393
Merge remote-tracking branch 'origin/develop' into module/form_manager
nurul-umbhiya Apr 18, 2024
daaaa26
chore: fixed some phpcs related issues
nurul-umbhiya Apr 19, 2024
2c42450
update: added a new property for component class to conditionally hid…
nurul-umbhiya Apr 22, 2024
ec88e80
fix: product type id doesn't match with existing source code, hence P…
nurul-umbhiya Apr 22, 2024
531bc8b
chore: moved attribute related js code to dokan pro
nurul-umbhiya Apr 24, 2024
985684f
fix: textarea populating multiple white spaces
nurul-umbhiya Apr 26, 2024
0c7d55f
Merge remote-tracking branch 'origin/develop' into module/form_manager
nurul-umbhiya Apr 26, 2024
64e16f2
fix: product status not updating according to the admin settings
nurul-umbhiya Apr 26, 2024
599d413
fix: simple subscription product type data not saving to database
nurul-umbhiya Apr 26, 2024
34029c7
core: added a new filter to escape required fields validation
nurul-umbhiya Apr 30, 2024
8082724
chore: removed one step product form notice from admin panel
nurul-umbhiya Apr 30, 2024
e6ea576
fix: Reset all button was not workingon product form admin settings
devAsadNur Apr 30, 2024
cb51e17
Merge branch 'develop' into module/form_manager
devAsadNur Jun 26, 2024
aaee6a1
fix: Modified based on PR review request
devAsadNur Aug 27, 2024
8ee16c2
Merge branch 'develop' into module/form_manager
devAsadNur Aug 27, 2024
693c6de
fix: Fatal error error on activating product form module
devAsadNur Aug 28, 2024
374c796
Merge branch 'develop' into module/form_manager
shashwatahalder01 Aug 28, 2024
3c175da
Update tests for form manager
shashwatahalder01 Aug 28, 2024
654614a
Fix a test
shashwatahalder01 Aug 28, 2024
59aa377
fix: Default category not auto selecting on creating new product
devAsadNur Sep 2, 2024
659e645
Merge remote-tracking branch 'upstream/module/form_manager' into modu…
devAsadNur Sep 2, 2024
02adcbf
Merge branch 'develop' into module/form_manager
devAsadNur Sep 2, 2024
6043469
fix: Return type was incorrect for product manager delete method
devAsadNur Sep 2, 2024
935f03e
Merge branch 'develop' into module/form_manager
devAsadNur Sep 2, 2024
7c0c718
Fix failed test locator
shashwatahalder01 Sep 9, 2024
40b08c6
Merge remote-tracking branch 'upstream/module/form_manager' into modu…
devAsadNur Oct 29, 2024
49825ee
fix: Layout breaking issue of vendor dashboard product shipping input
devAsadNur Oct 30, 2024
e2ef682
update: Product SKU field title in vendor dashboard single product ed…
devAsadNur Oct 30, 2024
4b33118
fix: Product edit page shipping dimension input fields styling issues…
devAsadNur Oct 31, 2024
dd6f3db
refactor: Reverted product variation related dokan pro i18n strings t…
devAsadNur Oct 31, 2024
0e05b17
fix: Product type dropdown was missing on vendor dashboard product ed…
devAsadNur Nov 11, 2024
78eaa59
fix: Vendor dashboard product edit page data saving issues of Dokan P…
devAsadNur Nov 12, 2024
fabbc1a
fix: Undefined variable warning on vendor dashboard product category …
devAsadNur Nov 18, 2024
ec05bc8
refactor: dokan_product_form_fields filter hook moved to product fact…
devAsadNur Nov 22, 2024
cd745e8
Merge branch 'develop' into module/form_manager
devAsadNur Nov 26, 2024
36f4fc2
refactor: Registered ProductForm service provider to container common…
devAsadNur Nov 26, 2024
faae548
new: Introduced DOKAN_TEMPLATE_DIR constant
devAsadNur Nov 26, 2024
38556db
Merge branch 'develop' into module/form_manager
devAsadNur Nov 26, 2024
1c91942
refactor: Action hooks to the edit-product-single template after reso…
devAsadNur Nov 26, 2024
b92694d
fix: Removed extra ending sign of PHP form product edit title
devAsadNur Nov 26, 2024
cd4c744
refactor: Featured image preview on vendor dashbaord product edit page
devAsadNur Nov 27, 2024
2af1fbb
Merge branch 'develop' into module/form_manager
devAsadNur Dec 5, 2024
b13cd3b
refactor: Price and category fiels on vendor dashbaord product edit p…
devAsadNur Dec 5, 2024
a04c74b
Merge remote-tracking branch 'origin/develop' into module/form_manager
devAsadNur Dec 17, 2024
0ecb790
fix: Gallery image restriction was not working
devAsadNur Dec 20, 2024
1c36c1c
refactor: Product meta processor method for gallery image restriction
devAsadNur Dec 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ assets/js/style.js
assets/js/vue-admin.js.LICENSE.txt
assets/js/vue-bootstrap.js.LICENSE.txt
assets/js/vue-frontend.js.LICENSE.txt
assets/js/dokan-tailwind.js
449 changes: 47 additions & 402 deletions assets/src/js/product-editor.js

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions assets/src/less/dashboard.less
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,14 @@ div.media-sidebar a.edit-attachment{
margin-bottom: 10px;
}
}

.product-edit-container {
span {
&.validation-error {
display: block;
}
}
}
}

div.chart-container > div.chart-placeholder > div.legend {
Expand Down
34 changes: 30 additions & 4 deletions assets/src/less/products.less
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,10 @@
}

.product-edit-new-container {
.dokan-hide {
display: none;
}

.dokan-edit-row {
&.dokan-other-options {
margin-bottom: 20px;
Expand Down Expand Up @@ -465,14 +469,36 @@

.dokan-shipping-container {
.dokan-shipping-dimention-options {
margin-bottom: 20px;
input {
margin-bottom: 5px;

.dokan-form-group {
width: 23.3%;
float: left;
margin-right: 2%;

&#dokan-form-group-height {
margin-right: 0;
}

input {
&.dokan-form-control {
width: 100%;
margin-right: 0;
margin-bottom: 0;
}
}
}

input {
&.dokan-form-control {
float: left;
width: 23.3%;
margin-right: 2%;
margin-bottom: 15px;
}

&#_height {
margin-right: 0px;
margin-right: 0;
}
}
}
Expand Down Expand Up @@ -972,7 +998,7 @@

.instruction-inside {
text-align: center;
padding-top: 40px;
padding-top: 80px;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Padding change appears inconsistent with responsive design patterns

The codebase shows multiple declarations of .instruction-inside with different padding approaches:

  • One instance uses percentage-based padding (20% top, 30% bottom)
  • Another uses the new fixed 80px padding-top
  • These different padding styles appear in the same file without clear responsive breakpoints

The change from percentage-based padding to fixed pixels could cause layout issues across different viewport sizes, especially since the file already contains mobile-specific media queries (@media max-width: 430px).

Recommend:

  • Maintain consistent padding strategy (either percentage or fixed)
  • If fixed padding is required, add appropriate media queries for smaller screens
  • Consider reverting to percentage-based padding for better responsiveness
🔗 Analysis chain

Verify the increased padding impact on layout.

The padding-top has been significantly increased from 20px to 80px. While this might improve visual spacing, please verify that it doesn't cause any layout issues or excessive whitespace in different viewport sizes.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any responsive design considerations for the instruction-inside class
# Look for media queries or responsive adjustments that might affect this padding

rg -A 5 "instruction-inside.*{" --type less
rg "@media.*{" --type less

Length of output: 262


Script:

#!/bin/bash
# Fix the regex syntax and search for instruction-inside class and media queries
rg -A 5 "instruction-inside" --type less
rg "@media" --type less

Length of output: 4309

color: #aaa;
}

Expand Down
2 changes: 2 additions & 0 deletions dokan-class.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* @property WeDevs\Dokan\BackgroundProcess\Manager $bg_process Instance of WeDevs\Dokan\BackgroundProcess\Manager class
* @property WeDevs\Dokan\Withdraw\Manager $withdraw Instance of WeDevs\Dokan\Withdraw\Manager class
* @property WeDevs\Dokan\Frontend\Frontend $frontend_manager Instance of \WeDevs\Dokan\Frontend\Frontend class
* @property WeDevs\Dokan\Dashboard\Manager $dashboard Instance of \WeDevs\Dokan\Dashboard\Manager class
* @property WeDevs\Dokan\Registration $registration Instance of WeDevs\Dokan\Registration class
*/
final class WeDevs_Dokan {
Expand Down Expand Up @@ -214,6 +215,7 @@ public function define_constants() {
defined( 'DOKAN_PLUGIN_VERSION' ) || define( 'DOKAN_PLUGIN_VERSION', $this->version );
defined( 'DOKAN_DIR' ) || define( 'DOKAN_DIR', __DIR__ );
defined( 'DOKAN_INC_DIR' ) || define( 'DOKAN_INC_DIR', __DIR__ . '/includes' );
defined( 'DOKAN_TEMPLATE_DIR' ) || define( 'DOKAN_TEMPLATE_DIR', __DIR__ . '/templates' );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Template directory constant needs to be used consistently

The verification reveals inconsistent template path handling across the codebase:

  • Most template loading is handled through functions like dokan_locate_template() and dokan_get_template() which use dynamic path resolution
  • Email templates use DOKAN_DIR . '/templates/'
  • Only one direct usage of DOKAN_TEMPLATE_DIR found in templates/products/edit/edit-product-single.php

For consistency and maintainability:

  • Replace DOKAN_DIR . '/templates/' usage in email classes with DOKAN_TEMPLATE_DIR
  • Consider updating the direct include in edit-product-single.php to use template loading functions instead
🔗 Analysis chain

Verify template directory constant usage

The constant definition looks good, but let's ensure it's being used consistently across the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for existing usages of hardcoded template paths that should use DOKAN_TEMPLATE_DIR

# Search for hardcoded template paths
rg -g '*.php' "(?i)(templates?.*directory|template.*path|template.*dir)"

# Search for current usage of the new constant
rg "DOKAN_TEMPLATE_DIR"

Length of output: 6453

defined( 'DOKAN_LIB_DIR' ) || define( 'DOKAN_LIB_DIR', __DIR__ . '/lib' );
defined( 'DOKAN_PLUGIN_ASSEST' ) || define( 'DOKAN_PLUGIN_ASSEST', plugins_url( 'assets', DOKAN_FILE ) );

Expand Down
50 changes: 0 additions & 50 deletions includes/Admin/Notices/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ private function init_hooks() {
add_action( 'admin_notices', [ $this, 'render_missing_woocommerce_notice' ] );
add_action( 'admin_notices', [ $this, 'render_global_admin_notices_html' ] );
add_filter( 'dokan_admin_notices', [ $this, 'show_permalink_setting_notice' ] );
add_filter( 'dokan_admin_notices', [ $this, 'show_one_step_product_add_notice' ] );
add_action( 'wp_ajax_dismiss_dokan_one_step_product_notice', [ $this, 'dismiss_dokan_one_step_product_notice' ] );
}

/**
Expand Down Expand Up @@ -126,52 +124,4 @@ public function show_permalink_setting_notice( $notices ) {

return $notices;
}

/**
* Display single page product page create notice.
*
* @since 3.8.2
*
* @param array $notices
*
* @return array
*/
public function show_one_step_product_add_notice( $notices ) {
if ( 'yes' !== get_option( 'dismiss_dokan_one_step_product_nonce', 'no' ) ) {
$notices[] = [
'type' => 'alert',
'title' => __( 'New One-Step Product Form', 'dokan-lite' ),
'description' => __( 'Try it now to enhance your vendor\'s product upload experience, the older two-step version will be retired in one month.', 'dokan-lite' ),
'priority' => 1,
'show_close_button' => true,
'ajax_data' => [
'action' => 'dismiss_dokan_one_step_product_notice',
'nonce' => wp_create_nonce( 'dismiss_dokan_one_step_product_nonce' ),
],
];
}

return $notices;
}

/**
* Dismisses one-step product create notice.
*
* @since 3.8.2
*
* @return void
*/
public function dismiss_dokan_one_step_product_notice() {
if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( sanitize_key( wp_unslash( $_POST['nonce'] ) ), 'dismiss_dokan_one_step_product_nonce' ) ) {
wp_send_json_error( __( 'Invalid nonce', 'dokan-lite' ) );
}

// phpcs:ignore
if ( ! current_user_can( 'manage_woocommerce' ) ) {
wp_send_json_error( __( 'You have no permission to do that', 'dokan-lite' ) );
}

update_option( 'dismiss_dokan_one_step_product_nonce', 'yes' );
wp_send_json_success();
}
}
19 changes: 0 additions & 19 deletions includes/Admin/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -557,25 +557,6 @@ public function get_settings_fields() {
'default' => 'on',
'tooltip' => __( 'If checked, vendors will have permission to sell immediately after registration. If unchecked, newly registered vendors cannot add products until selling capability is activated manually from admin dashboard.', 'dokan-lite' ),
],
'one_step_product_create' => [
'name' => 'one_step_product_create',
'label' => __( 'One Page Product Creation', 'dokan-lite' ),
'desc' => __( 'Add new product in single page view', 'dokan-lite' ),
'type' => 'switcher',
'default' => 'on',
'tooltip' => __( 'If disabled, instead of a single add product page it will open a pop up window or vendor will redirect to product page when adding new product.', 'dokan-lite' ),
],
'disable_product_popup' => [
'name' => 'disable_product_popup',
'label' => __( 'Disable Product Popup', 'dokan-lite' ),
'desc' => __( 'Disable add new product in popup view', 'dokan-lite' ),
'type' => 'switcher',
'default' => 'off',
'show_if' => [
'dokan_selling.one_step_product_create' => [ 'equal' => 'off' ],
],
'tooltip' => __( 'If disabled, instead of a pop up window vendor will redirect to product page when adding new product.', 'dokan-lite' ),
],
'order_status_change' => [
'name' => 'order_status_change',
'label' => __( 'Order Status Change', 'dokan-lite' ),
Expand Down
39 changes: 0 additions & 39 deletions includes/Ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ public function __construct() {
add_action( 'wp_ajax_dokan_seller_listing_search', [ $this, 'seller_listing_search' ] );
add_action( 'wp_ajax_nopriv_dokan_seller_listing_search', [ $this, 'seller_listing_search' ] );

add_action( 'wp_ajax_dokan_create_new_product', [ $this, 'create_product' ] );

add_action( 'wp_ajax_custom-header-crop', [ $this, 'crop_store_banner' ] );

add_action( 'wp_ajax_dokan_json_search_products_tags', [ $this, 'dokan_json_search_products_tags' ] );
Expand All @@ -57,43 +55,6 @@ public function __construct() {
add_action( 'wp_ajax_dokan-upgrade-dissmiss', [ $this, 'dismiss_pro_notice' ] );
}

/**
* Create product from popup submission
*
* @since 2.5.0
*
* @return void
*/
public function create_product() {
check_ajax_referer( 'dokan_reviews' );

if ( ! current_user_can( 'dokan_add_product' ) ) {
wp_send_json_error( __( 'You have no permission to do this action', 'dokan-lite' ) );
}

$submited_data = isset( $_POST['postdata'] ) ? wp_unslash( $_POST['postdata'] ) : ''; //phpcs:ignore

parse_str( $submited_data, $postdata );

$response = dokan_save_product( $postdata );

if ( is_wp_error( $response ) ) {
wp_send_json_error( $response->get_error_message() );
}

if ( is_int( $response ) ) {
if ( current_user_can( 'dokan_edit_product' ) ) {
$redirect = dokan_edit_product_url( $response );
} else {
$redirect = dokan_get_navigation_url( 'products' );
}

wp_send_json_success( $redirect );
} else {
wp_send_json_error( __( 'Something wrong, please try again later', 'dokan-lite' ) );
}
}

/**
* Check the availability of shop name.
*
Expand Down
Loading