From ae968de80c42bb1797aea5b93dff9ac5833a3252 Mon Sep 17 00:00:00 2001 From: Aunshon Date: Wed, 4 Dec 2024 14:33:26 +0600 Subject: [PATCH 01/12] Fix commission upgrader (#2463) * Fix commission upgrader * Add database backup message in upgrade. --- includes/Commission/Upugrader/Update_Category_Commission.php | 4 ++-- includes/Commission/Upugrader/Update_Product_Commission.php | 5 +++-- includes/Commission/Upugrader/Update_Vendor_Commission.php | 4 ++-- includes/Upgrade/AdminNotice.php | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/includes/Commission/Upugrader/Update_Category_Commission.php b/includes/Commission/Upugrader/Update_Category_Commission.php index 4a5affbcae..1e2ea42057 100644 --- a/includes/Commission/Upugrader/Update_Category_Commission.php +++ b/includes/Commission/Upugrader/Update_Category_Commission.php @@ -195,11 +195,11 @@ public function process_single_category( $term_id ) { ]; if ( Flat::SOURCE === $commission_type ) { - $category_commission_item['percentage'] = 0; + $category_commission_item['percentage'] = ''; $category_commission_item['flat'] = $commission; } elseif ( Percentage::SOURCE === $commission_type ) { $category_commission_item['percentage'] = $commission; - $category_commission_item['flat'] = 0; + $category_commission_item['flat'] = ''; } $category_commission['items'][ $term_id ] = $category_commission_item; diff --git a/includes/Commission/Upugrader/Update_Product_Commission.php b/includes/Commission/Upugrader/Update_Product_Commission.php index 1a5c536398..4f86b09b70 100644 --- a/includes/Commission/Upugrader/Update_Product_Commission.php +++ b/includes/Commission/Upugrader/Update_Product_Commission.php @@ -187,13 +187,14 @@ public function process_single_product( $product_id ) { $commission = dokan()->product->get_commission_settings( $product_id ); $commission_type_old = $commission->get_type(); + $commission->set_type( Fixed::SOURCE ); if ( Flat::SOURCE === $commission_type_old ) { $commission->set_flat( $commission->get_percentage() ); - $commission->set_percentage( 0 ); + $commission->set_percentage( '' ); } elseif ( Percentage::SOURCE === $commission_type_old ) { - $commission->set_flat( 0 ); + $commission->set_flat( '' ); } dokan()->product->save_commission_settings( diff --git a/includes/Commission/Upugrader/Update_Vendor_Commission.php b/includes/Commission/Upugrader/Update_Vendor_Commission.php index 7e4bde2cc6..b310fe3cc4 100644 --- a/includes/Commission/Upugrader/Update_Vendor_Commission.php +++ b/includes/Commission/Upugrader/Update_Vendor_Commission.php @@ -143,11 +143,11 @@ public function process_single_vendor( $vendor_id ) { $percentage = $commission->get_percentage(); if ( Flat::SOURCE === $commission_type_old ) { - $commission->set_percentage( 0 ); + $commission->set_percentage( '' ); $commission->set_flat( $percentage ); } elseif ( Percentage::SOURCE === $commission_type_old ) { $commission->set_percentage( $percentage ); - $commission->set_flat( 0 ); + $commission->set_flat( '' ); } $vendor->save_commission_settings( diff --git a/includes/Upgrade/AdminNotice.php b/includes/Upgrade/AdminNotice.php index 258af341f9..abf6c1c0c0 100644 --- a/includes/Upgrade/AdminNotice.php +++ b/includes/Upgrade/AdminNotice.php @@ -37,7 +37,7 @@ public static function show_notice( $notices ) { $notices[] = [ 'type' => 'info', 'title' => __( 'Dokan Data Update Required', 'dokan-lite' ), - 'description' => __( 'Updating your Dokan data is required to continue functional operations.', 'dokan-lite' ), + 'description' => __( 'Updating your Dokan data is required to continue functional operations. Kindly backup your database before running upgrade for safety.', 'dokan-lite' ), 'priority' => 1, 'scope' => 'global', 'actions' => [ From b1dc551e049ada4e8f35967adc972d912858579c Mon Sep 17 00:00:00 2001 From: Aunshon <32583103+Aunshon@users.noreply.github.com> Date: Wed, 4 Dec 2024 15:25:06 +0600 Subject: [PATCH 02/12] chore: Released Version 3.14.1 --- CHANGELOG.md | 13 +++++++++++++ README.md | 21 ++++++--------------- dokan-class.php | 2 +- dokan.php | 2 +- languages/dokan-lite.pot | 7 ++++--- package-lock.json | 4 ++-- package.json | 2 +- readme.txt | 20 ++++++-------------- templates/whats-new.php | 12 ++++++++++++ 9 files changed, 46 insertions(+), 37 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e5dd6fa5f..78b17ea88e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,16 @@ +### v3.12.6 ( Oct 24, 2024 ) ### + +- **fix:** Fixed js error on frontend pages. + +### v3.12.5 ( Oct 16, 2024 ) ### + +- **fix:** Implement order trash and untrash handling for Dokan +- **fix:** Added wordpress native i18n support + +### v3.12.4 ( Oct 03, 2024 ) ### + +- **update:** Added `$data` parameter to `dokan_update_vendor` hook. + ### v3.12.3 ( Sep 30, 2024 ) ### - **update:** Added compatibility with RFQ state field ui. diff --git a/README.md b/README.md index 6529ad0246..f582e1a184 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ **WC requires at least:** 8.0.0 **WC tested up to:** 9.4.2 **Requires PHP:** 7.4 -**Stable tag:** 3.14.0 +**Stable tag:** 3.14.1 **License:** GPLv2 or later **License URI:** http://www.gnu.org/licenses/gpl-2.0.html @@ -347,6 +347,10 @@ A. Just install and activate the PRO version without deleting the free plugin. A ## Changelog ## +### v3.14.1 ( Dec 04, 2024 ) ### + +- **fix:** Fixed a issue in the commission upgrader to deal with empty values for product and vendor. + ### v3.14.0 ( Dec 02, 2024 ) ### - **new:** Commission amount now displayed in the product list within the admin dashboard. @@ -355,7 +359,6 @@ A. Just install and activate the PRO version without deleting the free plugin. A - **new:** Commission details metabox on the order details page in the admin dashboard is now visible for child orders or orders without a parent. - **new:** Related order metabox on the order details page in the admin dashboard, displaying sibling orders for child orders and child orders for parent orders. - **new:** Backward compatibility for flat, percentage, and combine commission types for older orders. -- **new:** A new color palette is introduced for store color "Purple Pulse" - **update:** Updated commission types from flat, percentage, and combine to fixed and category-based commissions. - **update:** Overhauled the commission UI across Dokan global settings, vendor settings, product settings, Dokan subscription product settings, and the admin setup wizard. - **update:** Updated the commission settings in the admin setup wizard. @@ -375,20 +378,8 @@ A. Just install and activate the PRO version without deleting the free plugin. A - **feat:** Replaced the Dokan array container with the League Container, ensuring backward compatibility for seamless performance and enhanced flexibility. - **feat:** Updated Dokan to be fully compatible with WooCommerce Analytics Reports -### v3.12.6 ( Oct 24, 2024 ) ### - -- **fix:** Fixed js error on frontend pages. - -### v3.12.5 ( Oct 16, 2024 ) ### - -- **fix:** Implement order trash and untrash handling for Dokan -- **fix:** Added wordpress native i18n support - -### v3.12.4 ( Oct 03, 2024 ) ### - -- **update:** Added `$data` parameter to `dokan_update_vendor` hook. -[CHECK THE FULL CHANGELOG](https://github.com/getdokan/dokan/blob/ac8cfe42ed6d13a34572571728281591ebbf706f/CHANGELOG.md). +[CHECK THE FULL CHANGELOG](https://github.com/getdokan/dokan/blob/develop/CHANGELOG.md). ## Upgrade Notice ## diff --git a/dokan-class.php b/dokan-class.php index 681a7d3dba..c7f539bcd4 100755 --- a/dokan-class.php +++ b/dokan-class.php @@ -23,7 +23,7 @@ final class WeDevs_Dokan { * * @var string */ - public $version = '3.14.0'; + public $version = '3.14.1'; /** * Instance of self diff --git a/dokan.php b/dokan.php index b9152f0f0c..3e3ba008e1 100755 --- a/dokan.php +++ b/dokan.php @@ -3,7 +3,7 @@ * Plugin Name: Dokan * Plugin URI: https://dokan.co/wordpress/ * Description: An e-commerce marketplace plugin for WordPress. Powered by WooCommerce and weDevs. - * Version: 3.14.0 + * Version: 3.14.1 * Author: weDevs * Author URI: https://dokan.co/ * Text Domain: dokan-lite diff --git a/languages/dokan-lite.pot b/languages/dokan-lite.pot index c4848307b2..a059f9ce65 100644 --- a/languages/dokan-lite.pot +++ b/languages/dokan-lite.pot @@ -1,14 +1,14 @@ # Copyright (c) 2024 weDevs Pte. Ltd. All Rights Reserved. msgid "" msgstr "" -"Project-Id-Version: Dokan 3.14.0\n" +"Project-Id-Version: Dokan 3.14.1\n" "Report-Msgid-Bugs-To: https://dokan.co/contact/\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"POT-Creation-Date: 2024-11-29T10:41:37+00:00\n" +"POT-Creation-Date: 2024-12-04T09:23:45+00:00\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "X-Generator: WP-CLI 2.11.0\n" "X-Domain: dokan-lite\n" @@ -6827,7 +6827,7 @@ msgid "Dokan Data Update Required" msgstr "" #: includes/Upgrade/AdminNotice.php:40 -msgid "Updating your Dokan data is required to continue functional operations." +msgid "Updating your Dokan data is required to continue functional operations. Kindly backup your database before running upgrade for safety." msgstr "" #: includes/Upgrade/AdminNotice.php:46 @@ -8275,6 +8275,7 @@ msgstr "" msgid "Your product %s" msgstr "" +#. translators: 1) product title #: templates/emails/plain/product-published.php:25 msgid "has been approved by one of our admin, congrats!" msgstr "" diff --git a/package-lock.json b/package-lock.json index 14fae69cf8..18e8330e45 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "dokan", - "version": "3.14.0", + "version": "3.14.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "dokan", - "version": "3.14.0", + "version": "3.14.1", "license": "GPL", "dependencies": { "@wordpress/i18n": "^5.8.0" diff --git a/package.json b/package.json index 310456449d..d7685fb8b6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dokan", - "version": "3.14.0", + "version": "3.14.1", "description": "A WordPress marketplace plugin", "author": "weDevs", "license": "GPL", diff --git a/readme.txt b/readme.txt index a92676bd8e..be19c55156 100644 --- a/readme.txt +++ b/readme.txt @@ -7,7 +7,7 @@ Tested up to: 6.7.1 WC requires at least: 8.0.0 WC tested up to: 9.4.2 Requires PHP: 7.4 -Stable tag: 3.14.0 +Stable tag: 3.14.1 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -347,6 +347,10 @@ A. Just install and activate the PRO version without deleting the free plugin. A == Changelog == += v3.14.1 ( Dec 04, 2024 ) = + +- **fix:** Fixed a issue in the commission upgrader to deal with empty values for product and vendor. + = v3.14.0 ( Dec 02, 2024 ) = - **new:** Commission amount now displayed in the product list within the admin dashboard. @@ -374,20 +378,8 @@ A. Just install and activate the PRO version without deleting the free plugin. A - **feat:** Replaced the Dokan array container with the League Container, ensuring backward compatibility for seamless performance and enhanced flexibility. - **feat:** Updated Dokan to be fully compatible with WooCommerce Analytics Reports -= v3.12.6 ( Oct 24, 2024 ) = - -- **fix:** Fixed js error on frontend pages. - -= v3.12.5 ( Oct 16, 2024 ) = - -- **fix:** Implement order trash and untrash handling for Dokan -- **fix:** Added wordpress native i18n support - -= v3.12.4 ( Oct 03, 2024 ) = - -- **update:** Added `$data` parameter to `dokan_update_vendor` hook. -[CHECK THE FULL CHANGELOG](https://github.com/getdokan/dokan/blob/ac8cfe42ed6d13a34572571728281591ebbf706f/CHANGELOG.md). +[CHECK THE FULL CHANGELOG](https://github.com/getdokan/dokan/blob/develop/CHANGELOG.md). == Upgrade Notice == diff --git a/templates/whats-new.php b/templates/whats-new.php index 9bb7a617af..8d47de38a5 100644 --- a/templates/whats-new.php +++ b/templates/whats-new.php @@ -3,6 +3,18 @@ * When you are adding new version please follow this sequence for changes: New Feature, New, Improvement, Fix... */ $changelog = [ + [ + 'version' => 'Version 3.14.1', + 'released' => '2024-12-04', + 'changes' => [ + 'Fix' => [ + [ + 'title' => 'Fixed a issue in the commission upgrader to deal with empty values for product and vendor.', + 'description' => '', + ], + ], + ], + ], [ 'version' => 'Version 3.14.0', 'released' => '2024-12-02', From 90dd109dd8c7842c3584ecc45fef645dd458bc7a Mon Sep 17 00:00:00 2001 From: shashwata Halder Date: Thu, 5 Dec 2024 08:50:27 +0600 Subject: [PATCH 03/12] Fix skipped product tests (#2457) * Fix and update skipped product tests * Update a variable --- tests/pw/feature-map/feature-map.yml | 6 +- tests/pw/pages/productsPage.ts | 113 ++++++++++++++++----------- tests/pw/pages/selectors.ts | 4 + tests/pw/tests/e2e/_env.setup.ts | 4 + tests/pw/tests/e2e/products.spec.ts | 8 +- tests/pw/utils/interfaces.ts | 2 + tests/pw/utils/testData.ts | 2 + 7 files changed, 87 insertions(+), 52 deletions(-) diff --git a/tests/pw/feature-map/feature-map.yml b/tests/pw/feature-map/feature-map.yml index 1b6367e91f..9d0642af45 100644 --- a/tests/pw/feature-map/feature-map.yml +++ b/tests/pw/feature-map/feature-map.yml @@ -84,11 +84,11 @@ admin can add product category [lite]: true admin can add product attribute [lite]: true admin can add simple product [lite]: true - admin can add variable product: false + admin can add variable product: true admin can add simple subscription product: true - admin can add variable subscription product: false + admin can add variable subscription product: true admin can add external product [lite]: true - admin can add vendor subscription: false + admin can add vendor subscription: true vendor: vendor can view product menu page [lite]: true vendor can view add new product page [lite]: true diff --git a/tests/pw/pages/productsPage.ts b/tests/pw/pages/productsPage.ts index 434ff4ac8c..eef071e8ea 100644 --- a/tests/pw/pages/productsPage.ts +++ b/tests/pw/pages/productsPage.ts @@ -44,16 +44,37 @@ export class ProductsPage extends AdminPage { } } + // admin add product name and type + async addProductNameAndType(productName: string, productType: string) { + await this.clearAndType(productsAdmin.product.productName, productName); + await this.selectByValue(productsAdmin.product.productType, productType); + } + + // admin assign category to product + async assignCategoryToProduct(categoryName: string) { + await this.click(productsAdmin.product.category(categoryName)); + } + + // admin assign vendor to product + async assignVendorToProduct(vendorName: string) { + await this.select2ByText(productsAdmin.product.storeName, productsAdmin.product.storeNameInput, vendorName); + } + + // admin publish product + async publishProduct() { + await this.clickAndWaitForResponseAndLoadState(data.subUrls.post, productsAdmin.product.publish, 302); + await this.toBeVisible(productsAdmin.product.productPublishSuccessMessage); + } + // admin add simple product async addSimpleProduct(product: product['simple']) { await this.goIfNotThere(data.subUrls.backend.wc.addNewProducts); // product basic info - await this.type(productsAdmin.product.productName, product.productName()); - await this.selectByValue(productsAdmin.product.productType, product.productType); + await this.addProductNameAndType(product.productName(), product.productType); await this.click(productsAdmin.product.subMenus.general); await this.type(productsAdmin.product.regularPrice, product.regularPrice()); - await this.click(productsAdmin.product.category(product.category)); + await this.assignCategoryToProduct(product.category); // stock status if (product.stockStatus) { @@ -62,7 +83,7 @@ export class ProductsPage extends AdminPage { } // vendor Store Name - await this.select2ByText(productsAdmin.product.storeName, productsAdmin.product.storeNameInput, product.storeName); + await this.assignVendorToProduct(product.storeName); await this.scrollToTop(); switch (product.status) { @@ -92,17 +113,18 @@ export class ProductsPage extends AdminPage { async addVariableProduct(product: product['variable']) { await this.goIfNotThere(data.subUrls.backend.wc.addNewProducts); - // name - await this.type(productsAdmin.product.productName, product.productName()); - await this.selectByValue(productsAdmin.product.productType, product.productType); + // name and type + await this.addProductNameAndType(product.productName(), product.productType); // add attributes - await this.click(productsAdmin.product.subMenus.attributes); + await this.clickAndWaitForResponse(data.subUrls.ajax, productsAdmin.product.subMenus.attributes); if (await this.isVisibleLocator(productsAdmin.product.customProductAttribute)) { + // new attribute await this.selectByValue(productsAdmin.product.customProductAttribute, `pa_${product.attribute}`); await this.click(productsAdmin.product.addAttribute); } else { + // existing attribute await this.clickAndWaitForResponse(data.subUrls.backend.wc.searchAttribute, productsAdmin.product.addExistingAttribute); await this.typeAndWaitForResponse(data.subUrls.backend.wc.term, productsAdmin.product.addExistingAttributeInput, product.attribute); await this.pressAndWaitForResponse(data.subUrls.ajax, data.key.enter); @@ -113,30 +135,31 @@ export class ProductsPage extends AdminPage { await this.clickAndWaitForResponse(data.subUrls.ajax, productsAdmin.product.saveAttributes); // add variations - await this.click(productsAdmin.product.subMenus.variations); + await this.clickAndWaitForResponse(data.subUrls.ajax, productsAdmin.product.subMenus.variations); await this.clickAndAcceptAndWaitForResponse(data.subUrls.ajax, productsAdmin.product.subMenus.generateVariations); - this.fillAlert('100'); - await this.selectByValue(productsAdmin.product.addVariations, product.variations.variableRegularPrice); + + // add variation price + await this.click(productsAdmin.product.addVariationPrice); + await this.type(productsAdmin.product.variationPriceInput, product.variationPrice()); + await this.clickAndWaitForResponse(data.subUrls.ajax, productsAdmin.product.addPrice); // category - await this.click(productsAdmin.product.category(product.category)); + await this.assignCategoryToProduct(product.category); // Vendor Store Name - await this.select2ByText(productsAdmin.product.storeName, productsAdmin.product.storeNameInput, product.storeName); + await this.assignVendorToProduct(product.storeName); await this.scrollToTop(); // Publish - await this.clickAndWaitForResponseAndLoadState(data.subUrls.post, productsAdmin.product.publish, 302); - await this.toContainText(productsAdmin.product.updatedSuccessMessage, data.product.publishSuccessMessage); + await this.publishProduct(); } // Admin Add Simple Subscription Product async addSimpleSubscription(product: product['simpleSubscription']) { await this.goIfNotThere(data.subUrls.backend.wc.addNewProducts); - // Name - await this.type(productsAdmin.product.productName, product.productName()); - await this.selectByValue(productsAdmin.product.productType, product.productType); + // name and type + await this.addProductNameAndType(product.productName(), product.productType); await this.click(productsAdmin.product.subMenus.general); await this.type(productsAdmin.product.subscriptionPrice, product.subscriptionPrice()); await this.selectByValue(productsAdmin.product.subscriptionPeriodInterval, product.subscriptionPeriodInterval); @@ -146,25 +169,22 @@ export class ProductsPage extends AdminPage { await this.selectByValue(productsAdmin.product.subscriptionTrialPeriod, product.subscriptionTrialPeriod); // Category - await this.click(productsAdmin.product.category(product.category)); + await this.assignCategoryToProduct(product.category); // Vendor Store Name - await this.select2ByText(productsAdmin.product.storeName, productsAdmin.product.storeNameInput, product.storeName); + await this.assignVendorToProduct(product.storeName); await this.scrollToTop(); // Publish - await this.clickAndWaitForResponseAndLoadState(data.subUrls.post, productsAdmin.product.publish, 302); - - await this.toContainText(productsAdmin.product.updatedSuccessMessage, data.product.publishSuccessMessage); + await this.publishProduct(); } // admin add variable product async addVariableSubscription(product: product['variableSubscription']) { await this.goIfNotThere(data.subUrls.backend.wc.addNewProducts); - // name - await this.type(productsAdmin.product.productName, product.productName()); - await this.selectByValue(productsAdmin.product.productType, product.productType); + // name and type + await this.addProductNameAndType(product.productName(), product.productType); // add attributes await this.click(productsAdmin.product.subMenus.attributes); @@ -183,59 +203,58 @@ export class ProductsPage extends AdminPage { await this.clickAndWaitForResponse(data.subUrls.ajax, productsAdmin.product.saveAttributes); // add variations - await this.click(productsAdmin.product.subMenus.variations); + await this.clickAndWaitForResponse(data.subUrls.ajax, productsAdmin.product.subMenus.variations); await this.clickAndAcceptAndWaitForResponse(data.subUrls.ajax, productsAdmin.product.subMenus.generateVariations); - this.fillAlert('100'); - await this.selectByValue(productsAdmin.product.addVariations, product.variations.variableRegularPrice); + + // add variation price + await this.click(productsAdmin.product.addVariationPrice); + await this.type(productsAdmin.product.variationPriceInput, product.variationPrice()); + await this.clickAndWaitForResponse(data.subUrls.ajax, productsAdmin.product.addPrice); // category - await this.click(productsAdmin.product.category(product.category)); + await this.assignCategoryToProduct(product.category); // Vendor Store Name - await this.select2ByText(productsAdmin.product.storeName, productsAdmin.product.storeNameInput, product.storeName); + await this.assignVendorToProduct(product.storeName); await this.scrollToTop(); // Publish - await this.clickAndWaitForResponseAndLoadState(data.subUrls.post, productsAdmin.product.publish, 302); - await this.toContainText(productsAdmin.product.updatedSuccessMessage, data.product.publishSuccessMessage); + await this.publishProduct(); } // Admin Add External Product async addExternalProduct(product: product['external']) { await this.goIfNotThere(data.subUrls.backend.wc.addNewProducts); - // Name - await this.type(productsAdmin.product.productName, product.productName()); - await this.selectByValue(productsAdmin.product.productType, product.productType); + // name and type + await this.addProductNameAndType(product.productName(), product.productType); await this.click(productsAdmin.product.subMenus.general); await this.type(productsAdmin.product.productUrl, this.getBaseUrl() + product.productUrl); await this.type(productsAdmin.product.buttonText, product.buttonText); await this.type(productsAdmin.product.regularPrice, product.regularPrice()); // Category - await this.click(productsAdmin.product.category(product.category)); + await this.assignCategoryToProduct(product.category); // Vendor Store Name - await this.select2ByText(productsAdmin.product.storeName, productsAdmin.product.storeNameInput, product.storeName); + await this.assignVendorToProduct(product.storeName); await this.scrollToTop(); // Publish - await this.clickAndWaitForResponseAndLoadState(data.subUrls.post, productsAdmin.product.publish, 302); - await this.toContainText(productsAdmin.product.updatedSuccessMessage, data.product.publishSuccessMessage); + await this.publishProduct(); } // Admin Add Dokan Subscription Product async addDokanSubscription(product: product['vendorSubscription']) { await this.goIfNotThere(data.subUrls.backend.wc.addNewProducts); - // Name - await this.type(productsAdmin.product.productName, product.productName()); - await this.selectByValue(productsAdmin.product.productType, product.productType); + // name and type + await this.addProductNameAndType(product.productName(), product.productType); await this.click(productsAdmin.product.subMenus.general); await this.type(productsAdmin.product.regularPrice, product.regularPrice()); // Category - await this.click(productsAdmin.product.category(product.category)); + await this.assignCategoryToProduct(product.category); // Subscription Details await this.type(productsAdmin.product.numberOfProducts, product.numberOfProducts); @@ -244,9 +263,11 @@ export class ProductsPage extends AdminPage { await this.type(productsAdmin.product.expireAfterDays, product.expireAfterDays); await this.click(productsAdmin.product.recurringPayment); + // commission + // todo: add commission + // Publish - await this.clickAndWaitForResponseAndLoadState(data.subUrls.post, productsAdmin.product.publish, 302); - await this.toContainText(productsAdmin.product.updatedSuccessMessage, data.product.publishSuccessMessage); + await this.publishProduct(); } // vendor diff --git a/tests/pw/pages/selectors.ts b/tests/pw/pages/selectors.ts index 9d534059c0..9d09061295 100644 --- a/tests/pw/pages/selectors.ts +++ b/tests/pw/pages/selectors.ts @@ -3155,6 +3155,9 @@ export const selector = { productVariations: '.woocommerce_variation', addVariations: '#field_to_edit', go: '.bulk_edit', // invokes default js alert + addVariationPrice: 'button.add_price_for_variations', + variationPriceInput: 'input.wc_input_variations_price', + addPrice: 'button.add_variations_price_button', // Advanced advanced: { @@ -3199,6 +3202,7 @@ export const selector = { preview: '#post-preview', publish: '#publishing-action #publish', updatedSuccessMessage: '.updated.notice.notice-success p', + productPublishSuccessMessage: '//p[contains(.,"Product published. View Product")]', }, // Categories diff --git a/tests/pw/tests/e2e/_env.setup.ts b/tests/pw/tests/e2e/_env.setup.ts index 76d1214ec0..33cbc196d9 100644 --- a/tests/pw/tests/e2e/_env.setup.ts +++ b/tests/pw/tests/e2e/_env.setup.ts @@ -112,6 +112,10 @@ setup.describe('setup woocommerce settings', () => { await dbUtils.setOptionValue('woocommerce_task_list_reminder_bar_hidden', 'yes', false); }); + setup('disable woocommerce variable product tour', { tag: ['@lite'] }, async () => { + await dbUtils.setUserMeta('1','woocommerce_admin_variable_product_tour_shown', 'yes', false); + }); + setup('disable storefront sticky add to cart', { tag: ['@lite'] }, async () => { await dbUtils.updateOptionValue('theme_mods_storefront', { storefront_sticky_add_to_cart: false }); }); diff --git a/tests/pw/tests/e2e/products.spec.ts b/tests/pw/tests/e2e/products.spec.ts index a7386b30b0..d27d2f1684 100644 --- a/tests/pw/tests/e2e/products.spec.ts +++ b/tests/pw/tests/e2e/products.spec.ts @@ -45,7 +45,8 @@ test.describe('Product functionality test', () => { await admin.addSimpleProduct(data.product.simple); }); - test.skip('admin can add variable product', { tag: ['@pro', '@admin'] }, async () => { + test('admin can add variable product', { tag: ['@pro', '@admin'] }, async () => { + test.slow(); await admin.addVariableProduct(data.product.variable); }); @@ -53,7 +54,8 @@ test.describe('Product functionality test', () => { await admin.addSimpleSubscription(data.product.simpleSubscription); }); - test.skip('admin can add variable subscription product', { tag: ['@pro', '@admin'] }, async () => { + test('admin can add variable subscription product', { tag: ['@pro', '@admin'] }, async () => { + test.slow(); await admin.addVariableSubscription(data.product.variableSubscription); }); @@ -61,7 +63,7 @@ test.describe('Product functionality test', () => { await admin.addExternalProduct(data.product.external); }); - test.skip('admin can add vendor subscription', { tag: ['@pro', '@admin'] }, async () => { + test('admin can add vendor subscription', { tag: ['@pro', '@admin'] }, async () => { await admin.addDokanSubscription(data.product.vendorSubscription); }); diff --git a/tests/pw/utils/interfaces.ts b/tests/pw/utils/interfaces.ts index 2fa542188b..0a219466a6 100644 --- a/tests/pw/utils/interfaces.ts +++ b/tests/pw/utils/interfaces.ts @@ -166,6 +166,7 @@ export interface product { stockStatus: boolean; attribute: string; attributeTerms: string[]; + variationPrice: () => string; variations: { linkAllVariation: string; variableRegularPrice: string; @@ -230,6 +231,7 @@ export interface product { status: string; attribute: string; attributeTerms: string[]; + variationPrice: () => string; variations: { linkAllVariation: string; variableRegularPrice: string; diff --git a/tests/pw/utils/testData.ts b/tests/pw/utils/testData.ts index a66f123b08..c6144ef024 100644 --- a/tests/pw/utils/testData.ts +++ b/tests/pw/utils/testData.ts @@ -278,6 +278,7 @@ export const data = { stockStatus: false, attribute: 'sizes', attributeTerms: ['s', 'l', 'm'], + variationPrice: () => faker.finance.amount({ min: 100, max: 200, dec: faker.helpers.arrayElement([1, 2]) }).replace('.', ','), variations: { linkAllVariation: 'link_all_variations', variableRegularPrice: 'variable_regular_price', @@ -342,6 +343,7 @@ export const data = { status: 'publish', attribute: 'sizes', attributeTerms: ['s', 'l', 'm'], + variationPrice: () => faker.finance.amount({ min: 100, max: 200, dec: faker.helpers.arrayElement([1, 2]) }).replace('.', ','), variations: { linkAllVariation: 'link_all_variations', variableRegularPrice: 'variable_regular_price', From 490a380861a4b546a9932de9ca65749e2c48b170 Mon Sep 17 00:00:00 2001 From: shashwata Halder Date: Thu, 5 Dec 2024 10:48:46 +0600 Subject: [PATCH 04/12] Add store list & reviews test (#2460) * Fix skipped store tests * Add store reviews tests * Update comment * skipped a test --- tests/pw/feature-map/feature-map.yml | 10 ++++----- tests/pw/pages/basePage.ts | 8 +++++++ tests/pw/pages/selectors.ts | 7 +++--- tests/pw/pages/storeListingPage.ts | 13 +++++++++++ tests/pw/pages/storeReviewsPage.ts | 26 +++++++++++++++++++++- tests/pw/tests/api/modules.spec.ts | 2 +- tests/pw/tests/e2e/modules.spec.ts | 2 +- tests/pw/tests/e2e/singleStore.spec.ts | 1 - tests/pw/tests/e2e/storeReviews.spec.ts | 10 +++++++++ tests/pw/tests/e2e/storelisting.spec.ts | 7 +++--- tests/pw/utils/apiUtils.ts | 10 +++++++-- tests/pw/utils/interfaces.ts | 2 +- tests/pw/utils/payloads.ts | 29 +++++++++++++------------ tests/pw/utils/testData.ts | 2 +- 14 files changed, 95 insertions(+), 34 deletions(-) diff --git a/tests/pw/feature-map/feature-map.yml b/tests/pw/feature-map/feature-map.yml index 9d0642af45..22dadc5420 100644 --- a/tests/pw/feature-map/feature-map.yml +++ b/tests/pw/feature-map/feature-map.yml @@ -286,7 +286,7 @@ features: customer: customer can view single store page [lite]: true - customer can view store open-close time on single store [lite]: false + customer can view store open-close time on single store [lite]: true customer can search product on single store [lite]: true customer can sort products on single store [lite]: true customer can view store terms and conditions [lite]: true @@ -308,9 +308,9 @@ customer can search store [lite]: true customer can filter stores by category: true customer can filter stores by location: true - customer can filter stores by ratings: false + customer can filter stores by ratings: true customer can filter featured stores: true - customer can filter open now stores: false + customer can filter open now stores: true customer can view stores on map: true customer can go to single store from store list [lite]: true @@ -1298,8 +1298,8 @@ - page: 'Store Reviews' features: admin: - admin can enable store reviews module: false - admin can disable store reviews module: false + admin can enable store reviews module: true + admin can disable store reviews module: true admin can view store reviews menu page: true admin can view store review: true admin can edit store review: true diff --git a/tests/pw/pages/basePage.ts b/tests/pw/pages/basePage.ts index 948e21662c..0b9eb7fbf8 100644 --- a/tests/pw/pages/basePage.ts +++ b/tests/pw/pages/basePage.ts @@ -1598,6 +1598,14 @@ export class BasePage { .toBe(200); } + // assert two element to have same count + async toHaveEqualCount(selector1: string, selector2: string, options?: { timeout?: number; intervals?: number[] }) { + await this.toPass(async () => { + const [selector1Count, selector2Count] = await Promise.all([await this.getElementCount(selector1), await this.getElementCount(selector2)]); + expect(selector1Count).toBe(selector2Count); + }, options); + } + // assert element not to be visible async notToBeVisible(selector: string) { await expect(this.page.locator(selector)).toBeHidden(); diff --git a/tests/pw/pages/selectors.ts b/tests/pw/pages/selectors.ts index 9d09061295..b536bdd386 100644 --- a/tests/pw/pages/selectors.ts +++ b/tests/pw/pages/selectors.ts @@ -800,6 +800,7 @@ export const selector = { // Store Reviews storeReviews: { + storeReviewsDiv: 'div.dokan-store-reviews', storeReviewsText: '.dokan-store-reviews h1', // Nav Tabs @@ -7466,10 +7467,10 @@ export const selector = { // Pagination pagination: '.dokan-pagination', - // Review - review: { + // Reviews + reviews: { close: 'button.icon-close', - noReviewsFound: '//span[normalize-space()="No Reviews found"]', + noReviewsFound: '//span[normalize-space()="No Reviews Found"]', write: '//button[normalize-space()="Write a Review"]', // write: '.add-review-btn', edit: '.edit-review-btn', diff --git a/tests/pw/pages/storeListingPage.ts b/tests/pw/pages/storeListingPage.ts index 0c818ebdfb..b08ab2f58e 100644 --- a/tests/pw/pages/storeListingPage.ts +++ b/tests/pw/pages/storeListingPage.ts @@ -137,6 +137,19 @@ export class StoreListingPage extends CustomerPage { await this.clickAndWaitForResponse(data.subUrls.frontend.storeListing, storeList.filters.filterDetails.apply); await this.notToHaveCount(storeList.storeCard.storeCardDiv, 0); + + switch (filterBy) { + case 'featured': + await this.toHaveEqualCount(storeList.storeCard.storeCardDiv, storeList.storeCard.featuredLabel); + break; + + case 'open-now': + await this.toHaveEqualCount(storeList.storeCard.storeCardDiv, storeList.storeCard.openCloseStatus); + break; + + default: + break; + } } // stores on map diff --git a/tests/pw/pages/storeReviewsPage.ts b/tests/pw/pages/storeReviewsPage.ts index 0706664ca2..65d3a0ce8f 100644 --- a/tests/pw/pages/storeReviewsPage.ts +++ b/tests/pw/pages/storeReviewsPage.ts @@ -6,8 +6,9 @@ import { data } from '@utils/testData'; import { storeReview } from '@utils/interfaces'; // selectors +const dokanAdmin = selector.admin.dokan; const storeReviewsAdmin = selector.admin.dokan.storeReviews; -const storeReviewsCustomer = selector.customer.cSingleStore.review; +const storeReviewsCustomer = selector.customer.cSingleStore.reviews; export class StoreReviewsPage extends AdminPage { constructor(page: Page) { @@ -16,6 +17,29 @@ export class StoreReviewsPage extends AdminPage { // store reviews + // enable store reviews + async enableStoreReviewsModule(storeName: string) { + await this.goto(data.subUrls.backend.dokan.dokan); + await this.toBeVisible(dokanAdmin.menus.storeReviews); + + await this.goIfNotThere(data.subUrls.frontend.vendorDetails(helpers.slugify(storeName)), 'networkidle'); + await this.toBeVisible(selector.customer.cSingleStore.storeTabs.reviews); + } + + // disable store reviews + async disableStoreReviewsModule(storeName: string) { + await this.goto(data.subUrls.backend.dokan.dokan, { waitUntil: 'domcontentloaded' }, true); + await this.notToBeVisible(dokanAdmin.menus.storeReviews); + + // no reviews table is visible + await this.goIfNotThere(data.subUrls.backend.dokan.storeReviews); + await this.notToBeVisible(dokanAdmin.storeReviews.storeReviewsDiv); + + // reviews is visible + await this.goIfNotThere(data.subUrls.frontend.storeReviews(helpers.slugify(storeName))); + await this.toBeVisible(selector.customer.cSingleStore.reviews.noReviewsFound); + } + // store reviews render properly async adminStoreReviewsRenderProperly() { await this.goIfNotThere(data.subUrls.backend.dokan.storeReviews); diff --git a/tests/pw/tests/api/modules.spec.ts b/tests/pw/tests/api/modules.spec.ts index d5522df733..c4caa8a082 100644 --- a/tests/pw/tests/api/modules.spec.ts +++ b/tests/pw/tests/api/modules.spec.ts @@ -18,7 +18,7 @@ test.describe('modules api test', () => { }); test.afterAll(async () => { - await apiUtils.activateModules([randomModule]); + await apiUtils.activateModules(randomModule); await apiUtils.dispose(); }); diff --git a/tests/pw/tests/e2e/modules.spec.ts b/tests/pw/tests/e2e/modules.spec.ts index 8848c3ba64..5d63815d9e 100644 --- a/tests/pw/tests/e2e/modules.spec.ts +++ b/tests/pw/tests/e2e/modules.spec.ts @@ -41,7 +41,7 @@ test.describe('Modules test', () => { }); test('admin can activate module', { tag: ['@pro', '@admin'] }, async () => { - await apiUtils.deactivateModules([payloads.moduleIds.auction], payloads.adminAuth); + await apiUtils.deactivateModules(payloads.moduleIds.auction, payloads.adminAuth); await admin.activateDeactivateModule(data.modules.modulesName.auctionIntegration); }); diff --git a/tests/pw/tests/e2e/singleStore.spec.ts b/tests/pw/tests/e2e/singleStore.spec.ts index 78b3cd50eb..5d869639e1 100644 --- a/tests/pw/tests/e2e/singleStore.spec.ts +++ b/tests/pw/tests/e2e/singleStore.spec.ts @@ -23,7 +23,6 @@ test.describe('Single store functionality test', () => { }); test.skip('customer can view store open-close time on single store', { tag: ['@lite', '@customer'] }, async () => { - // todo: pre: need store open close time await customer.storeOpenCloseTime(data.predefined.vendorStores.vendor1); }); diff --git a/tests/pw/tests/e2e/storeReviews.spec.ts b/tests/pw/tests/e2e/storeReviews.spec.ts index 83d67b2525..f1b4f37665 100644 --- a/tests/pw/tests/e2e/storeReviews.spec.ts +++ b/tests/pw/tests/e2e/storeReviews.spec.ts @@ -35,6 +35,7 @@ test.describe('Store Reviews test', () => { }); test.afterAll(async () => { + await apiUtils.activateModules(payloads.moduleIds.storeReviews, payloads.adminAuth); await aPage.close(); await vPage.close(); await cPage.close(); @@ -43,6 +44,10 @@ test.describe('Store Reviews test', () => { //admin + test('admin can enable store reviews module', { tag: ['@pro', '@exploratory', '@admin'] }, async () => { + await admin.enableStoreReviewsModule(data.predefined.vendorStores.vendor1); + }); + test('admin can view store reviews menu page', { tag: ['@pro', '@exploratory', '@admin'] }, async () => { await admin.adminStoreReviewsRenderProperly(); }); @@ -95,4 +100,9 @@ test.describe('Store Reviews test', () => { test("vendor can't review own store", { tag: ['@pro', '@vendor'] }, async () => { await vendor.cantReviewOwnStore(data.predefined.vendorStores.vendor1); }); + + test('admin can disable store reviews module', { tag: ['@pro', '@exploratory', '@admin'] }, async () => { + await apiUtils.deactivateModules(payloads.moduleIds.storeReviews, payloads.adminAuth); + await admin.disableStoreReviewsModule(data.predefined.vendorStores.vendor1); + }); }); diff --git a/tests/pw/tests/e2e/storelisting.spec.ts b/tests/pw/tests/e2e/storelisting.spec.ts index b61454c97b..eb2ab4bf76 100644 --- a/tests/pw/tests/e2e/storelisting.spec.ts +++ b/tests/pw/tests/e2e/storelisting.spec.ts @@ -42,20 +42,19 @@ test.describe('Store list functionality test', () => { await customer.filterStores('by-location', 'New York, NY, USA'); }); - test.skip('customer can filter stores by ratings', { tag: ['@pro', '@customer'] }, async () => { - await customer.filterStores('by-ratings', '1'); + test('customer can filter stores by ratings', { tag: ['@pro', '@customer'] }, async () => { + await customer.filterStores('by-ratings', '5'); }); test('customer can filter featured stores', { tag: ['@pro', '@customer'] }, async () => { await customer.filterStores('featured'); }); - test.skip('customer can filter open now stores', { tag: ['@pro', '@customer'] }, async () => { + test('customer can filter open now stores', { tag: ['@pro', '@customer'] }, async () => { await customer.filterStores('open-now'); }); test('customer can view stores on map', { tag: ['@pro', '@customer'] }, async () => { - // test.skip(true, '@todo fix this test'); await customer.storeOnMap(); }); diff --git a/tests/pw/utils/apiUtils.ts b/tests/pw/utils/apiUtils.ts index 84d3e99fe6..13fb66ca80 100644 --- a/tests/pw/utils/apiUtils.ts +++ b/tests/pw/utils/apiUtils.ts @@ -864,13 +864,19 @@ export class ApiUtils { } // get activate modules - async activateModules(moduleIds: string[], auth?: auth): Promise<[APIResponse, responseBody]> { + async activateModules(moduleIds: string | string[], auth?: auth): Promise<[APIResponse, responseBody]> { + if (!Array.isArray(moduleIds)) { + moduleIds = [moduleIds]; + } const [response, responseBody] = await this.put(endPoints.activateModule, { data: { module: moduleIds }, headers: auth }); return [response, responseBody]; } // get deactivated modules - async deactivateModules(moduleIds: string[], auth?: auth): Promise<[APIResponse, responseBody]> { + async deactivateModules(moduleIds: string | string[], auth?: auth): Promise<[APIResponse, responseBody]> { + if (!Array.isArray(moduleIds)) { + moduleIds = [moduleIds]; + } const [response, responseBody] = await this.put(endPoints.deactivateModule, { data: { module: moduleIds }, headers: auth }); return [response, responseBody]; } diff --git a/tests/pw/utils/interfaces.ts b/tests/pw/utils/interfaces.ts index 0a219466a6..7e2d615641 100644 --- a/tests/pw/utils/interfaces.ts +++ b/tests/pw/utils/interfaces.ts @@ -1514,7 +1514,7 @@ export interface modules { modulesName: { auctionIntegration: string; - colorSchemeCustomize: string; + colorSchemeCustomizer: string; deliveryTime: string; elementor: string; eUComplianceFields: string; diff --git a/tests/pw/utils/payloads.ts b/tests/pw/utils/payloads.ts index 4016105b53..f53b3fa258 100644 --- a/tests/pw/utils/payloads.ts +++ b/tests/pw/utils/payloads.ts @@ -3558,8 +3558,9 @@ export const payloads = { // module moduleIds: { + auction: 'auction', booking: 'booking', - colorSchemeCustomize: 'color_scheme_customizer', + colorSchemeCustomizer: 'color_scheme_customizer', deliveryTime: 'delivery_time', elementor: 'elementor', exportImport: 'export_import', @@ -3568,41 +3569,41 @@ export const payloads = { germanized: 'germanized', liveChat: 'live_chat', liveSearch: 'live_search', + mangopay: 'mangopay', moip: 'moip', + orderMinMax: 'order_min_max', paypalMarketplace: 'paypal_marketplace', + printful: 'printful', productAddon: 'product_addon', + productAdvertising: 'product_advertising', productEnquiry: 'product_enquiry', + productSubscription: 'product_subscription', + rankMath: 'rank_math', reportAbuse: 'report_abuse', + requestForQuotation: 'request_for_quotation', rma: 'rma', + sellerBadge: 'seller_badge', sellerVacation: 'seller_vacation', shipStation: 'shipstation', - auction: 'auction', spmv: 'spmv', storeReviews: 'store_reviews', storeSupport: 'store_support', stripe: 'stripe', - productAdvertising: 'product_advertising', - productSubscription: 'product_subscription', + stripeExpress: 'stripe_express', + tableRateShipping: 'table_rate_shipping', vendorAnalytics: 'vendor_analytics', vendorStaff: 'vendor_staff', - vsp: 'vsp', vendorVerification: 'vendor_verification', + vsp: 'vsp', wholesale: 'wholesale', - rankMath: 'rank_math', - tableRateShipping: 'table_rate_shipping', - mangopay: 'mangopay', - orderMinMax: 'order_min_max', - sellerBadge: 'seller_badge', - stripeExpress: 'stripe_express', - requestForQuotation: 'request_for_quotation', }, deactivateModule: { - module: ['booking'], + module: 'booking', }, activateModule: { - module: ['booking'], + module: 'booking', }, // announcement diff --git a/tests/pw/utils/testData.ts b/tests/pw/utils/testData.ts index c6144ef024..ad4135ea55 100644 --- a/tests/pw/utils/testData.ts +++ b/tests/pw/utils/testData.ts @@ -2093,7 +2093,7 @@ export const data = { modulesName: { auctionIntegration: 'Auction Integration', - colorSchemeCustomize: 'Color Scheme Customize', + colorSchemeCustomizer: 'Color Scheme Customize', deliveryTime: 'Delivery Time', elementor: 'Elementor', eUComplianceFields: 'EU Compliance Fields', From 608d1269bcf2432fde64b763ff5fcc7d72617028 Mon Sep 17 00:00:00 2001 From: Aunshon Date: Fri, 6 Dec 2024 17:12:51 +0600 Subject: [PATCH 05/12] Enhancement: product commission bulk edit (#2464) * Remove $commission_type variable it was not used * Save fixed as default commission type * Save bulk product commission. * Update bulk edit ui Skip reverse withdrawal and advertisement product id * Update bulk edit ui Skip reverse withdrawal and advertisement product id * Revert alignment --- includes/Admin/Hooks.php | 46 +++++++++++++++++++ includes/Product/Hooks.php | 35 ++++++++------ .../dokan-products-edit-bulk-commission.php | 42 +++++++++++++++++ 3 files changed, 110 insertions(+), 13 deletions(-) create mode 100644 templates/products/dokan-products-edit-bulk-commission.php diff --git a/includes/Admin/Hooks.php b/includes/Admin/Hooks.php index 6c17da500c..3c9a8e34a6 100644 --- a/includes/Admin/Hooks.php +++ b/includes/Admin/Hooks.php @@ -2,6 +2,7 @@ namespace WeDevs\Dokan\Admin; +use WeDevs\Dokan\Product\Hooks as ProductHooks; use WP_Post; // don't call the file directly @@ -35,6 +36,9 @@ public function __construct() { // Ajax hooks add_action( 'wp_ajax_dokan_product_search_author', [ $this, 'search_vendors' ] ); + + add_action( 'woocommerce_product_bulk_edit_end', [ $this, 'add_product_commission_bulk_edit_field' ] ); + add_action( 'woocommerce_product_bulk_edit_save', [ $this, 'save_custom_bulk_edit_field' ], 10, 1 ); } /** @@ -223,4 +227,46 @@ public function update_pages( $value, $name ) { return array_replace_recursive( $current_settings, $value ); } + + /** + * Add commission settings in bulk product edit. + * + * @since DOKAN_SINCE + * + * @return void + */ + public function add_product_commission_bulk_edit_field() { + dokan_get_template_part( 'products/dokan-products-edit-bulk-commission', '', [] ); + } + + /** + * Save commission settings from bulk product edit + * + * @since DOKAN_SINCE + * + * @param \WC_Product $product + * + * @return void + */ + public function save_custom_bulk_edit_field( $product ) { + $excluded_product_types = apply_filters( 'dokan_excluded_product_types_for_bulk_edit', [ 'product_pack', 'external', 'grouped' ] ); + $dokan_advertisement_product_id = intval( get_option( 'dokan_advertisement_product_id', '' ) ); + $dokan_reverse_withdrawal_product_id = intval( get_option( 'dokan_reverse_withdrawal_product_id', '' ) ); + $product_id = $product->get_id(); + + if ( + ! current_user_can( 'manage_woocommerce' ) || + in_array( $product->get_type(), $excluded_product_types, true ) || + $product_id === $dokan_advertisement_product_id || + $product_id === $dokan_reverse_withdrawal_product_id + ) { + return; + } + + if ( ! isset( $_REQUEST['dokan_override_bulk_product_commission'] ) || intval( sanitize_text_field( $_REQUEST['dokan_override_bulk_product_commission'] ) ) !== 1 ) { // phpcs:ignore + return; + } + + ProductHooks::save_per_product_commission_options( $product->get_id(), $_REQUEST ); // phpcs:ignore + } } diff --git a/includes/Product/Hooks.php b/includes/Product/Hooks.php index d0b6c326e5..f200d67136 100644 --- a/includes/Product/Hooks.php +++ b/includes/Product/Hooks.php @@ -2,6 +2,7 @@ namespace WeDevs\Dokan\Product; +use WeDevs\Dokan\Commission\Formula\Fixed; use WeDevs\Dokan\ProductCategory\Helper; use WC_Product; @@ -521,37 +522,45 @@ class="woocommerce-help-tip" * * @since 2.4.12 * - * @param integer $post_id + * @param integer $post_id + * @param array $data * * @return void */ - public static function save_per_product_commission_options( $post_id ) { + public static function save_per_product_commission_options( $post_id, $data = [] ) { if ( ! current_user_can( 'manage_woocommerce' ) ) { return; } - $commission_type = ''; + $commission_type = Fixed::SOURCE; $admin_commission = ''; $additional_fee = ''; + $data = empty( $data ) ? $_POST : $data; // phpcs:ignore - if ( isset( $_POST['_per_product_admin_commission_type'] ) ) { // phpcs:ignore - $commission_type = ! empty( $_POST['_per_product_admin_commission_type'] ) ? sanitize_text_field( $_POST['_per_product_admin_commission_type'] ) : 'percentage'; // phpcs:ignore - update_post_meta( $post_id, '_per_product_admin_commission_type', $commission_type ); + if ( isset( $data['_per_product_admin_commission_type'] ) ) { + $commission_type = ! empty( $data['_per_product_admin_commission_type'] ) ? sanitize_text_field( $data['_per_product_admin_commission_type'] ) : Fixed::SOURCE; } - if ( isset( $_POST['_per_product_admin_commission'] ) ) { // phpcs:ignore - $_per_product_admin_commission = wc_format_decimal( sanitize_text_field( $_POST['_per_product_admin_commission'] ) ); // phpcs:ignore + if ( isset( $data['_per_product_admin_commission'] ) ) { + $_per_product_admin_commission = wc_format_decimal( sanitize_text_field( $data['_per_product_admin_commission'] ) ); if ( 0 <= $_per_product_admin_commission && 100 >= $_per_product_admin_commission ) { - $admin_commission = ( '' === $_POST['_per_product_admin_commission'] ) ? '' : $_per_product_admin_commission; // phpcs:ignore + $admin_commission = ( '' === $data['_per_product_admin_commission'] ) ? '' : $_per_product_admin_commission; } } - if ( isset( $_POST['_per_product_admin_additional_fee'] ) ) { // phpcs:ignore - $additional_fee = ( '' === $_POST['_per_product_admin_additional_fee'] ) ? '' : sanitize_text_field( $_POST['_per_product_admin_additional_fee'] ); // phpcs:ignore + if ( isset( $data['_per_product_admin_additional_fee'] ) ) { + $additional_fee = ( '' === $data['_per_product_admin_additional_fee'] ) ? '' : sanitize_text_field( $data['_per_product_admin_additional_fee'] ); + $additional_fee = wc_format_decimal( $additional_fee ); } - update_post_meta( $post_id, '_per_product_admin_commission', $admin_commission ); - update_post_meta( $post_id, '_per_product_admin_additional_fee', wc_format_decimal( $additional_fee ) ); + dokan()->product->save_commission_settings( + $post_id, + [ + 'type' => $commission_type, + 'percentage' => $admin_commission, + 'flat' => $additional_fee, + ] + ); } } diff --git a/templates/products/dokan-products-edit-bulk-commission.php b/templates/products/dokan-products-edit-bulk-commission.php new file mode 100644 index 0000000000..13ab6b5f88 --- /dev/null +++ b/templates/products/dokan-products-edit-bulk-commission.php @@ -0,0 +1,42 @@ + + +
+

+
+ +
+
+ + + + + + %  + + + + +
+
+
+
From e7c16b9520b911a8b7b2616ee5b2bb0e1aafce17 Mon Sep 17 00:00:00 2001 From: Aunshon <32583103+Aunshon@users.noreply.github.com> Date: Fri, 6 Dec 2024 18:35:54 +0600 Subject: [PATCH 06/12] chore: bump version to v3.14.2 --- CHANGELOG.md | 5 +++ README.md | 11 +++--- dokan-class.php | 2 +- dokan.php | 2 +- includes/Admin/Hooks.php | 4 +- includes/Product/Hooks.php | 5 +++ languages/dokan-lite.pot | 37 +++++++++++-------- package-lock.json | 4 +- package.json | 2 +- readme.txt | 11 +++--- .../dokan-products-edit-bulk-commission.php | 5 +-- templates/whats-new.php | 12 ++++++ 12 files changed, 63 insertions(+), 37 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 78b17ea88e..4d98bffc74 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +### v3.13.0 ( Nov 06, 2024 ) ### + +- **feat:** Replaced the Dokan array container with the League Container, ensuring backward compatibility for seamless performance and enhanced flexibility. +- **feat:** Updated Dokan to be fully compatible with WooCommerce Analytics Reports +- ### v3.12.6 ( Oct 24, 2024 ) ### - **fix:** Fixed js error on frontend pages. diff --git a/README.md b/README.md index f582e1a184..aed7c1679f 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ **WC requires at least:** 8.0.0 **WC tested up to:** 9.4.2 **Requires PHP:** 7.4 -**Stable tag:** 3.14.1 +**Stable tag:** 3.14.2 **License:** GPLv2 or later **License URI:** http://www.gnu.org/licenses/gpl-2.0.html @@ -347,6 +347,10 @@ A. Just install and activate the PRO version without deleting the free plugin. A ## Changelog ## +### v3.14.2 ( Dec 06, 2024 ) ### + +- **update:** Added commission setting option in product bulk edit for Admin. + ### v3.14.1 ( Dec 04, 2024 ) ### - **fix:** Fixed a issue in the commission upgrader to deal with empty values for product and vendor. @@ -373,11 +377,6 @@ A. Just install and activate the PRO version without deleting the free plugin. A - **update:** Compatibility with the Printful Integration Module added. - **fix:** Improved logic to ensure the `add new category` button only appears when appropriate conditions are met, enhancing user experience. -### v3.13.0 ( Nov 06, 2024 ) ### - -- **feat:** Replaced the Dokan array container with the League Container, ensuring backward compatibility for seamless performance and enhanced flexibility. -- **feat:** Updated Dokan to be fully compatible with WooCommerce Analytics Reports - [CHECK THE FULL CHANGELOG](https://github.com/getdokan/dokan/blob/develop/CHANGELOG.md). diff --git a/dokan-class.php b/dokan-class.php index c7f539bcd4..13a21016e8 100755 --- a/dokan-class.php +++ b/dokan-class.php @@ -23,7 +23,7 @@ final class WeDevs_Dokan { * * @var string */ - public $version = '3.14.1'; + public $version = '3.14.2'; /** * Instance of self diff --git a/dokan.php b/dokan.php index 3e3ba008e1..d8b9eeae37 100755 --- a/dokan.php +++ b/dokan.php @@ -3,7 +3,7 @@ * Plugin Name: Dokan * Plugin URI: https://dokan.co/wordpress/ * Description: An e-commerce marketplace plugin for WordPress. Powered by WooCommerce and weDevs. - * Version: 3.14.1 + * Version: 3.14.2 * Author: weDevs * Author URI: https://dokan.co/ * Text Domain: dokan-lite diff --git a/includes/Admin/Hooks.php b/includes/Admin/Hooks.php index 3c9a8e34a6..8d83e0af8a 100644 --- a/includes/Admin/Hooks.php +++ b/includes/Admin/Hooks.php @@ -231,7 +231,7 @@ public function update_pages( $value, $name ) { /** * Add commission settings in bulk product edit. * - * @since DOKAN_SINCE + * @since 3.14.2 * * @return void */ @@ -242,7 +242,7 @@ public function add_product_commission_bulk_edit_field() { /** * Save commission settings from bulk product edit * - * @since DOKAN_SINCE + * @since 3.14.2 * * @param \WC_Product $product * diff --git a/includes/Product/Hooks.php b/includes/Product/Hooks.php index f200d67136..02f45a9847 100644 --- a/includes/Product/Hooks.php +++ b/includes/Product/Hooks.php @@ -551,6 +551,11 @@ public static function save_per_product_commission_options( $post_id, $data = [] if ( isset( $data['_per_product_admin_additional_fee'] ) ) { $additional_fee = ( '' === $data['_per_product_admin_additional_fee'] ) ? '' : sanitize_text_field( $data['_per_product_admin_additional_fee'] ); + + if ( 0 > $additional_fee ) { + $additional_fee = ''; + } + $additional_fee = wc_format_decimal( $additional_fee ); } diff --git a/languages/dokan-lite.pot b/languages/dokan-lite.pot index a059f9ce65..38cbe1e473 100644 --- a/languages/dokan-lite.pot +++ b/languages/dokan-lite.pot @@ -1,14 +1,14 @@ # Copyright (c) 2024 weDevs Pte. Ltd. All Rights Reserved. msgid "" msgstr "" -"Project-Id-Version: Dokan 3.14.1\n" +"Project-Id-Version: Dokan 3.14.2\n" "Report-Msgid-Bugs-To: https://dokan.co/contact/\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"POT-Creation-Date: 2024-12-04T09:23:45+00:00\n" +"POT-Creation-Date: 2024-12-06T12:33:06+00:00\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "X-Generator: WP-CLI 2.11.0\n" "X-Domain: dokan-lite\n" @@ -195,7 +195,7 @@ msgstr "" msgid "Commision: " msgstr "" -#: includes/Admin/Hooks.php:66 +#: includes/Admin/Hooks.php:70 #: includes/Admin/Settings.php:590 #: includes/Admin/Settings.php:601 #: includes/Admin/Settings.php:612 @@ -212,16 +212,16 @@ msgstr "" msgid "Vendor" msgstr "" -#: includes/Admin/Hooks.php:93 +#: includes/Admin/Hooks.php:97 #: assets/js/vue-admin.js:2 msgid "Select vendor" msgstr "" -#: includes/Admin/Hooks.php:99 +#: includes/Admin/Hooks.php:103 msgid "You can search vendors and assign them." msgstr "" -#: includes/Admin/Hooks.php:112 +#: includes/Admin/Hooks.php:116 msgid "Unauthorized operation" msgstr "" @@ -698,6 +698,7 @@ msgstr "" #: includes/Order/Admin/Hooks.php:95 #: includes/ReverseWithdrawal/Helper.php:65 #: templates/orders/commission-meta-box-html.php:66 +#: templates/products/dokan-products-edit-bulk-commission.php:17 msgid "Commission" msgstr "" @@ -719,7 +720,7 @@ msgstr "" #: includes/Admin/Settings.php:523 #: includes/Admin/Settings.php:563 -#: includes/Product/Hooks.php:483 +#: includes/Product/Hooks.php:484 #: assets/js/vue-admin.js:2 msgid "Admin Commission" msgstr "" @@ -1840,7 +1841,7 @@ msgid "Delete" msgstr "" #: includes/Ajax.php:529 -#: includes/Product/Hooks.php:58 +#: includes/Product/Hooks.php:59 msgid "Error: Nonce verification failed" msgstr "" @@ -3899,6 +3900,7 @@ msgid "privacy policy" msgstr "" #: includes/functions.php:3256 +#: templates/products/dokan-products-edit-bulk-commission.php:28 msgid "Fixed" msgstr "" @@ -4556,7 +4558,7 @@ msgid "Catalog" msgstr "" #: includes/Product/functions.php:363 -#: includes/Product/Hooks.php:195 +#: includes/Product/Hooks.php:196 #: templates/products/listing-filter.php:85 msgid "Search" msgstr "" @@ -4606,29 +4608,29 @@ msgstr "" msgid "Relevance" msgstr "" -#: includes/Product/Hooks.php:65 +#: includes/Product/Hooks.php:66 msgid "Products not found with this search" msgstr "" -#: includes/Product/Hooks.php:154 +#: includes/Product/Hooks.php:155 #: templates/orders/commission-meta-box-html.php:111 msgid "SKU:" msgstr "" -#: includes/Product/Hooks.php:191 +#: includes/Product/Hooks.php:192 msgid "Enter product name" msgstr "" -#: includes/Product/Hooks.php:199 +#: includes/Product/Hooks.php:200 msgid "Shop order" msgstr "" -#: includes/Product/Hooks.php:417 +#: includes/Product/Hooks.php:418 msgid "As this is your own product, the \"Add to Cart\" button has been removed. Please visit as a guest to view it." msgstr "" -#: includes/Product/Hooks.php:487 #: includes/Product/Hooks.php:488 +#: includes/Product/Hooks.php:489 #: assets/js/vue-admin.js:2 msgid "When the value is 0, no commissions will be deducted from this vendor." msgstr "" @@ -7465,6 +7467,7 @@ msgid "Reviews cannot be posted for products that you own." msgstr "" #: includes/wc-template.php:171 +#: templates/products/dokan-products-edit-bulk-commission.php:20 msgid "— No change —" msgstr "" @@ -9065,6 +9068,10 @@ msgstr "" msgid "Done" msgstr "" +#: templates/products/dokan-products-edit-bulk-commission.php:21 +msgid "Change to:" +msgstr "" + #: templates/products/download-virtual.php:4 #: templates/products/products-listing-row.php:245 msgid "Downloadable" diff --git a/package-lock.json b/package-lock.json index 18e8330e45..e17fefd003 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "dokan", - "version": "3.14.1", + "version": "3.14.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "dokan", - "version": "3.14.1", + "version": "3.14.2", "license": "GPL", "dependencies": { "@wordpress/i18n": "^5.8.0" diff --git a/package.json b/package.json index d7685fb8b6..de816eff8e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dokan", - "version": "3.14.1", + "version": "3.14.2", "description": "A WordPress marketplace plugin", "author": "weDevs", "license": "GPL", diff --git a/readme.txt b/readme.txt index be19c55156..e64a4c436e 100644 --- a/readme.txt +++ b/readme.txt @@ -7,7 +7,7 @@ Tested up to: 6.7.1 WC requires at least: 8.0.0 WC tested up to: 9.4.2 Requires PHP: 7.4 -Stable tag: 3.14.1 +Stable tag: 3.14.2 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -347,6 +347,10 @@ A. Just install and activate the PRO version without deleting the free plugin. A == Changelog == += v3.14.2 ( Dec 06, 2024 ) = + +- **update:** Added commission setting option in product bulk edit for Admin. + = v3.14.1 ( Dec 04, 2024 ) = - **fix:** Fixed a issue in the commission upgrader to deal with empty values for product and vendor. @@ -373,11 +377,6 @@ A. Just install and activate the PRO version without deleting the free plugin. A - **update:** Compatibility with the Printful Integration Module added. - **fix:** Improved logic to ensure the `add new category` button only appears when appropriate conditions are met, enhancing user experience. -= v3.13.0 ( Nov 06, 2024 ) = - -- **feat:** Replaced the Dokan array container with the League Container, ensuring backward compatibility for seamless performance and enhanced flexibility. -- **feat:** Updated Dokan to be fully compatible with WooCommerce Analytics Reports - [CHECK THE FULL CHANGELOG](https://github.com/getdokan/dokan/blob/develop/CHANGELOG.md). diff --git a/templates/products/dokan-products-edit-bulk-commission.php b/templates/products/dokan-products-edit-bulk-commission.php index 13ab6b5f88..1d14c5be80 100644 --- a/templates/products/dokan-products-edit-bulk-commission.php +++ b/templates/products/dokan-products-edit-bulk-commission.php @@ -3,7 +3,7 @@ /** * Template Name: Dokan commission setting bulk product edit * - * @since DOKAN_SINCE + * @since 3.14.2 * * @package Dokan */ @@ -11,8 +11,7 @@ use WeDevs\Dokan\Commission\Formula\Fixed; ?> -
-

+