diff --git a/CHANGELOG.md b/CHANGELOG.md index da33e70173..0d3b55d005 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +### v3.14.10 ( Feb 28, 2025 ) ### + +- **fix:** Prevented wrong store URL generation for staff managers on admin dashboard. +- **fix:** Restoring parent order with restore related child orders. +- **fix:** Store settings API data storing inconsistencies. + ### v3.14.9 ( Feb 12, 2025 ) ### - **fix:** Fix earning suggestion in vendor dashboard when product edit page loads initially. diff --git a/README.md b/README.md index 88ea6b1124..402b35a84c 100644 --- a/README.md +++ b/README.md @@ -3,11 +3,11 @@ **Donate Link:** https://dokan.co/wordpress/pricing/ **Tags:** WooCommerce multivendor marketplace, multi seller, multi vendor, multivendor, multivendor marketplace **Requires at least:** 6.5 -**Tested up to:** 6.7.1 +**Tested up to:** 6.7.2 **WC requires at least:** 8.5.0 -**WC tested up to:** 9.6.1 +**WC tested up to:** 9.7.0 **Requires PHP:** 7.4 -**Stable tag:** 3.14.9 +**Stable tag:** 3.14.10 **License:** GPLv2 or later **License URI:** http://www.gnu.org/licenses/gpl-2.0.html @@ -344,6 +344,12 @@ A. Just install and activate the PRO version without deleting the free plugin. A ## Changelog ## +### v3.14.10 ( Feb 28, 2025 ) ### + +- **fix:** Prevented wrong store URL generation for staff managers on admin dashboard. +- **fix:** Restoring parent order with restore related child orders. +- **fix:** Store settings API data storing inconsistencies. + ### v3.14.9 ( Feb 12, 2025 ) ### - **fix:** Fix earning suggestion in vendor dashboard when product edit page loads initially. @@ -371,10 +377,6 @@ A. Just install and activate the PRO version without deleting the free plugin. A - **update:** Improvement withdraw approved email template. - **update:** Dokan admin settings page responsive & update ui design. -### v3.14.4 ( Dec 27, 2024 ) ### - -- **fix:** Added tweaks to improve system stability and smoothness. - [CHECK THE FULL CHANGELOG](https://github.com/getdokan/dokan/blob/develop/CHANGELOG.md). ## Upgrade Notice ## diff --git a/assets/src/js/helper.js b/assets/src/js/helper.js index d0d2c5ea41..f640940aea 100644 --- a/assets/src/js/helper.js +++ b/assets/src/js/helper.js @@ -3,7 +3,7 @@ /** * Gets i18n date format * - * @since DOKAN_PRO_SINCE + * @since 3.2.7 */ window.dokan_get_i18n_date_format = function ( format = true ) { if( ! format ) { @@ -46,7 +46,7 @@ /** * Get i18n time format. * - * @since DOKAN_PRO_SINCE + * @since 3.3.7 * * @param {string|boolean} format Time format. * @@ -110,7 +110,7 @@ /** * Get formatted time. * - * @since DOKAN_PRO_SINCE + * @since 3.3.7 * * @param {string} time Time. * @param {string} format Time format type. diff --git a/assets/src/js/product-editor.js b/assets/src/js/product-editor.js index 8e2b35efae..ed41237a2d 100755 --- a/assets/src/js/product-editor.js +++ b/assets/src/js/product-editor.js @@ -980,7 +980,7 @@ symbol: dokan.currency_format_symbol, decimal: dokan.currency_format_decimal_sep, thousand: dokan.currency_format_thousand_sep, - precision: 4, + precision: dokan.currency_format_num_decimals, format: dokan.currency_format, } ); }, diff --git a/assets/src/less/login-form-popup.less b/assets/src/less/login-form-popup.less index 96d67ad051..8cfc9abaee 100644 --- a/assets/src/less/login-form-popup.less +++ b/assets/src/less/login-form-popup.less @@ -41,4 +41,8 @@ p.vendor-customer-registration { cursor: pointer; color: #526b6f; } -} \ No newline at end of file +} + +.woocommerce-form-register:has(.vendor-customer-registration) { + height: fit-content !important; +} diff --git a/bin/version-replace.js b/bin/version-replace.js index 0550986012..0e35efe680 100644 --- a/bin/version-replace.js +++ b/bin/version-replace.js @@ -16,6 +16,6 @@ const { version } = JSON.parse( fs.readFileSync( 'package.json' ) ); replace( { files: pluginFiles, - from: /DOKAN_SINCE/g, + from: [ /DOKAN_SINCE/g, /DOKAN_PRO_SINCE/g ], to: version, } ); diff --git a/composer.lock b/composer.lock index 46acd14a6f..6a28de2128 100644 --- a/composer.lock +++ b/composer.lock @@ -540,12 +540,12 @@ "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "4764e040f8743e92b86c36f488f32d0265dd1dae" + "reference": "024473a478be9df5fdaca2c793f2232fe788e414" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/4764e040f8743e92b86c36f488f32d0265dd1dae", - "reference": "4764e040f8743e92b86c36f488f32d0265dd1dae", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/024473a478be9df5fdaca2c793f2232fe788e414", + "reference": "024473a478be9df5fdaca2c793f2232fe788e414", "shasum": "" }, "require": { @@ -585,7 +585,7 @@ ], "support": { "issues": "https://github.com/myclabs/DeepCopy/issues", - "source": "https://github.com/myclabs/DeepCopy/tree/1.x" + "source": "https://github.com/myclabs/DeepCopy/tree/1.13.0" }, "funding": [ { @@ -593,7 +593,7 @@ "type": "tidelift" } ], - "time": "2024-11-26T13:04:49+00:00" + "time": "2025-02-12T12:17:51+00:00" }, { "name": "nikic/php-parser", @@ -973,6 +973,10 @@ { "url": "https://opencollective.com/php_codesniffer", "type": "open_collective" + }, + { + "url": "https://thanks.dev/phpcompatibility", + "type": "thanks_dev" } ], "time": "2025-01-16T22:34:19+00:00" @@ -1052,6 +1056,10 @@ { "url": "https://opencollective.com/php_codesniffer", "type": "open_collective" + }, + { + "url": "https://thanks.dev/phpcsstandards", + "type": "thanks_dev" } ], "time": "2024-11-11T18:03:33+00:00" @@ -1062,12 +1070,12 @@ "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHPCSUtils.git", - "reference": "8ef592afe141d07ab178ca85dca0853d35fbd61a" + "reference": "060222e14c567c00fc4fd056ec7af809810c1fbc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHPCSUtils/zipball/8ef592afe141d07ab178ca85dca0853d35fbd61a", - "reference": "8ef592afe141d07ab178ca85dca0853d35fbd61a", + "url": "https://api.github.com/repos/PHPCSStandards/PHPCSUtils/zipball/060222e14c567c00fc4fd056ec7af809810c1fbc", + "reference": "060222e14c567c00fc4fd056ec7af809810c1fbc", "shasum": "" }, "require": { @@ -1147,7 +1155,7 @@ "type": "thanks_dev" } ], - "time": "2025-01-24T10:57:08+00:00" + "time": "2025-02-15T23:56:59+00:00" }, { "name": "phpunit/php-code-coverage", @@ -1474,12 +1482,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "ef7f9eecb0042f842b1ee755a48bef81ebcc6623" + "reference": "5375e77dc94f0b4824b9d01330314fe29069c894" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/ef7f9eecb0042f842b1ee755a48bef81ebcc6623", - "reference": "ef7f9eecb0042f842b1ee755a48bef81ebcc6623", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/5375e77dc94f0b4824b9d01330314fe29069c894", + "reference": "5375e77dc94f0b4824b9d01330314fe29069c894", "shasum": "" }, "require": { @@ -1490,7 +1498,7 @@ "ext-mbstring": "*", "ext-xml": "*", "ext-xmlwriter": "*", - "myclabs/deep-copy": "^1.12.1", + "myclabs/deep-copy": "^1.13.0", "phar-io/manifest": "^2.0.4", "phar-io/version": "^3.2.1", "php": ">=7.3", @@ -1569,7 +1577,7 @@ "type": "tidelift" } ], - "time": "2025-02-08T09:10:46+00:00" + "time": "2025-02-25T13:33:21+00:00" }, { "name": "sebastian/cli-parser", @@ -2541,12 +2549,12 @@ "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", - "reference": "d694aea3ba403e171f4f32cbdc68dd580f98a355" + "reference": "bf2b64d008ce8ed1f8cf83c4042571f1109969d2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/d694aea3ba403e171f4f32cbdc68dd580f98a355", - "reference": "d694aea3ba403e171f4f32cbdc68dd580f98a355", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/bf2b64d008ce8ed1f8cf83c4042571f1109969d2", + "reference": "bf2b64d008ce8ed1f8cf83c4042571f1109969d2", "shasum": "" }, "require": { @@ -2614,11 +2622,11 @@ "type": "open_collective" }, { - "url": "https://thanks.dev/phpcsstandards", + "url": "https://thanks.dev/u/gh/phpcsstandards", "type": "thanks_dev" } ], - "time": "2025-02-10T15:23:50+00:00" + "time": "2025-02-24T11:14:14+00:00" }, { "name": "tareq1988/wp-php-cs-fixer", @@ -2714,12 +2722,12 @@ "source": { "type": "git", "url": "https://github.com/WordPress/WordPress-Coding-Standards.git", - "reference": "c028f329aadd97788288c5cb4d1884eca50b954d" + "reference": "38c00390317f4018c56e0892e5e7b414039f8426" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/WordPress/WordPress-Coding-Standards/zipball/c028f329aadd97788288c5cb4d1884eca50b954d", - "reference": "c028f329aadd97788288c5cb4d1884eca50b954d", + "url": "https://api.github.com/repos/WordPress/WordPress-Coding-Standards/zipball/38c00390317f4018c56e0892e5e7b414039f8426", + "reference": "38c00390317f4018c56e0892e5e7b414039f8426", "shasum": "" }, "require": { @@ -2773,7 +2781,7 @@ "type": "custom" } ], - "time": "2024-12-27T12:57:17+00:00" + "time": "2025-02-25T19:39:55+00:00" }, { "name": "wp-phpunit/wp-phpunit", diff --git a/deprecated/Singleton.php b/deprecated/Singleton.php index 4cf2ce369c..eda1fdb274 100644 --- a/deprecated/Singleton.php +++ b/deprecated/Singleton.php @@ -6,8 +6,11 @@ * Singleton Trait * * @since 1.0.0 + * + * @deprecated 2.9.30 Use `WeDevs\Dokan\Traits\Singleton` instead of this. */ -trait Singleton { +trait Singleton +{ /** * Singleton class instance holder @@ -25,11 +28,12 @@ trait Singleton { * * @return object */ - public static function instance() { - if ( ! isset( static::$instance ) && ! ( static::$instance instanceof static ) ) { + public static function instance() + { + if (! isset(static::$instance) && ! (static::$instance instanceof static)) { static::$instance = new static(); - if ( method_exists( static::$instance, 'boot' ) ) { + if (method_exists(static::$instance, 'boot')) { static::$instance->boot(); } } diff --git a/deprecated/class-abstract-class-dokan-background-processes.php b/deprecated/class-abstract-class-dokan-background-processes.php index 599fb31c26..9135274ace 100644 --- a/deprecated/class-abstract-class-dokan-background-processes.php +++ b/deprecated/class-abstract-class-dokan-background-processes.php @@ -4,5 +4,6 @@ /** * Abstract Dokan_Background_Processes class + * @deprecated 2.9.30 Use `WeDevs\Dokan\Abstracts\DokanBackgroundProcesses` instead of `WeDevs\Dokan\Abstracts\Abstract_Dokan_Background_Processes` */ abstract class Abstract_Dokan_Background_Processes extends DokanBackgroundProcesses {} diff --git a/deprecated/class-abstrct-dokan-rest-store-controller.php b/deprecated/class-abstrct-dokan-rest-store-controller.php index c2afdc7139..f86652ab22 100644 --- a/deprecated/class-abstrct-dokan-rest-store-controller.php +++ b/deprecated/class-abstrct-dokan-rest-store-controller.php @@ -2,4 +2,10 @@ use WeDevs\Dokan\Abstracts\DokanRESTAdminController; +/** + * Dokan REST Admin Controller + * + * @deprecated 2.9.30 Use `WeDevs\Dokan\Abstracts\DokanRESTAdminController` instead of `WeDevs\Dokan\Abstracts\Dokan_REST_Admin_Controller` + */ + abstract class Dokan_REST_Admin_Controller extends DokanRESTAdminController {} diff --git a/deprecated/class-dokan-email.php b/deprecated/class-dokan-email.php index 61142025a1..d997246d23 100644 --- a/deprecated/class-dokan-email.php +++ b/deprecated/class-dokan-email.php @@ -1,8 +1,10 @@ email instead of Dokan_Email */ class Dokan_Email { diff --git a/deprecated/class-dokan-rest-controller.php b/deprecated/class-dokan-rest-controller.php index 52ce8a5f48..02f60dc2f3 100644 --- a/deprecated/class-dokan-rest-controller.php +++ b/deprecated/class-dokan-rest-controller.php @@ -2,4 +2,9 @@ use WeDevs\Dokan\Abstracts\DokanRESTController; +/** + * Dokan REST Admin Controller + * + * @deprecated 2.9.30 Use `WeDevs\Dokan\REST\DokanBaseController` instead of `WeDevs\Dokan\Abstracts\Dokan_REST_Controller` + */ class Dokan_REST_Controller extends DokanRESTController {} diff --git a/deprecated/class-dokan-rest-product-controller.php b/deprecated/class-dokan-rest-product-controller.php index 3d1e36ffbb..00bf57f014 100644 --- a/deprecated/class-dokan-rest-product-controller.php +++ b/deprecated/class-dokan-rest-product-controller.php @@ -2,7 +2,11 @@ use WeDevs\Dokan\REST\ProductController; +/** + * Dokan REST Product Controller + * + * @deprecated 2.9.30 Use `WeDevs\Dokan\REST\ProductController` instead of `Dokan_REST_Product_Controller` + */ class Dokan_REST_Product_Controller extends ProductController { - public function __construct() {} } diff --git a/deprecated/class-dokan-rest-store-controller.php b/deprecated/class-dokan-rest-store-controller.php index 3fb383f227..0029f91632 100644 --- a/deprecated/class-dokan-rest-store-controller.php +++ b/deprecated/class-dokan-rest-store-controller.php @@ -2,4 +2,11 @@ use WeDevs\Dokan\REST\StoreController; +/** + * Dokan REST Store Controller + * + * @deprecated 2.9.30 Use `WeDevs\Dokan\REST\StoreController` instead of `Dokan_REST_Store_Controller` + */ + + class Dokan_REST_Store_Controller extends StoreController {} diff --git a/deprecated/class-dokan-seller-setup-wizard.php b/deprecated/class-dokan-seller-setup-wizard.php index 8f9c00a724..56cde84053 100644 --- a/deprecated/class-dokan-seller-setup-wizard.php +++ b/deprecated/class-dokan-seller-setup-wizard.php @@ -1,4 +1,10 @@ namespace, - '/' . $this->rest_base, - [ - [ - 'methods' => WP_REST_Server::READABLE, - 'callback' => [ $this, 'get_items' ], - 'permission_callback' => [ $this, 'check_permission' ], - 'args' => $this->get_collection_params(), - ] - ] - ); - } - - public function get_items( $request ) { - $items = []; // Your implementation - $total = count( $items ); - - $response = rest_ensure_response( $items ); - return $this->format_collection_response( $response, $request, $total ); - } +/** + * Prepares the item for the REST response. + * + * @since DOKAN_SINCE + * + * @param mixed $item WordPress representation of the item. + * @param WP_REST_Request $request Request object. + * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure. + */ +public function prepare_item_for_response( $item, $request ) { + return new WP_Error( + 'invalid-method', + sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), + array( 'status' => 405 ) + ); } ``` -### Override Admin REST Controller permission - -```php -class ExampleAdminController extends DokanRESTAdminController { - protected $namespace = 'dokan/v1'; - protected $rest_base = 'example-admin'; - - public function register_routes() { - register_rest_route( - $this->namespace, - '/' . $this->rest_base, - [ - [ - 'methods' => WP_REST_Server::READABLE, - 'callback' => [ $this, 'get_items' ], - 'permission_callback' => [ $this, 'check_permission' ], - 'args' => $this->get_collection_params(), - ] - ] - ); - } - - public function check_permission() { - // Custom permission check for multiple roles - return current_user_can( 'dokandar' ) || current_user_can( 'manage_woocommerce' ); - } +### Extending Other Controllers - public function get_items( $request ) { - $items = []; // Your implementation - $total = count( $items ); - - $response = rest_ensure_response( $items ); - return $this->format_collection_response( $response, $request, $total ); - } -} -``` +Dokan provides the `VendorAuthorizable` trait, which can be used to check vendor capabilities in custom controllers that do not directly extend a Dokan base controller. -### Vendor REST Controller Implementation +## VendorAuthorizable Trait -```php -abstract class DokanRESTVendorController extends DokanRESTBaseController { - protected $rest_base = 'vendor'; - - public function check_permission() { - return current_user_can( 'dokandar' ); - } -} -``` +The `VendorAuthorizable` trait provides a way to check vendor permissions in REST controllers. It ensures that only authorized vendors can access or modify specific resources. -### How to extend the Vendor REST Controller +### Usage +To use the `VendorAuthorizable` trait, simply include it in your controller class: ```php -class ExampleVendorController extends DokanRESTVendorController { - // protected $namespace = 'dokan/v1'; (namespace will be inherited from the parent class) - protected $rest_base = 'example-vendor'; - - public function register_routes() { - register_rest_route( - $this->namespace, - '/' . $this->rest_base, - [ - [ - 'methods' => WP_REST_Server::READABLE, - 'callback' => [ $this, 'get_items' ], - 'permission_callback' => [ $this, 'check_permission' ], - 'args' => $this->get_collection_params(), - ] - ] - ); - } +use WeDevs\Dokan\Traits\VendorAuthorizable; - public function get_items( $request ) { - $items = []; // Your implementation - $total = count( $items ); - - $response = rest_ensure_response( $items ); - return $this->format_collection_response( $response, $request, $total ); - } +class VendorProductController extends \WC_REST_Products_Controller { + use VendorAuthorizable; } ``` -### Override Vendor REST Controller permission - -```php -class ExampleVendorController extends DokanRESTVendorController { - // protected $namespace = 'dokan/v1'; (namespace will be inherited from the parent class) - protected $rest_base = 'example-vendor'; +This trait provides a `check_permission` method, which can be used to verify if a user has the vendor(`dokandar`) capabilities to perform a given action. - public function register_routes() { - register_rest_route( - $this->namespace, - '/' . $this->rest_base, - [ - [ - 'methods' => WP_REST_Server::READABLE, - 'callback' => [ $this, 'get_items' ], - 'permission_callback' => [ $this, 'check_permission' ], - 'args' => $this->get_collection_params(), - ] - ] - ); - } - - public function check_permission() { - // Custom permission check. - return current_user_can( 'dokandar' ) || is_user_logged_in(); - } - - public function get_items( $request ) { - $items = []; // Your implementation - $total = count( $items ); - - $response = rest_ensure_response( $items ); - return $this->format_collection_response( $response, $request, $total ); - } -} -``` +## Example Implementations -### Customer REST Controller Implementation +### Admin Controller Example ```php -abstract class DokanRESTCustomerController extends DokanRESTBaseController { - // protected $namespace = 'dokan/v1'; (namespace will be inherited from the parent class) - protected $rest_base = 'customer'; - - public function check_permission() { - return is_user_logged_in(); - } -} -``` - -### How to extend the Customer REST Controller +use WeDevs\Dokan\REST\DokanBaseAdminController; -```php -class ExampleCustomerController extends DokanRESTCustomerController { - // protected $namespace = 'dokan/v1'; (namespace will be inherited from the parent class) - protected $rest_base = 'example-customer'; +class ExampleAdminController extends DokanBaseAdminController { + protected $namespace = 'dokan/v1'; // default namespace is 'dokan/v1/admin' in `DokanBaseAdminController` + protected $rest_base = 'example-admin'; public function register_routes() { register_rest_route( @@ -223,49 +95,37 @@ class ExampleCustomerController extends DokanRESTCustomerController { ); } - public function get_items( $request ) { - $items = []; // Your implementation - $total = count( $items ); - - $response = rest_ensure_response( $items ); - return $this->format_collection_response( $response, $request, $total ); - } -} -``` + /** + * Retrieve a single customer. + * + * @param WP_REST_Request $request Request details. + * @return WP_Error|WP_REST_Response + */ + public function get_item( $request ) { + $id = (int) $request['id']; + $user_data = get_userdata( $id ); -### Override Customer REST Controller permission + if ( empty( $id ) || empty( $user_data->ID ) ) { + return new WP_Error( 'woocommerce_rest_invalid_id', __( 'Invalid resource ID.', 'woocommerce' ), [ 'status' => 404 ] ); + } -```php -class ExampleCustomerController extends DokanRESTCustomerController { - // protected $namespace = 'dokan/v1'; (namespace will be inherited from the parent class) - protected $rest_base = 'example-customer'; - - public function register_routes() { - register_rest_route( - $this->namespace, - '/' . $this->rest_base, - [ - [ - 'methods' => WP_REST_Server::READABLE, - 'callback' => [ $this, 'get_items' ], - 'permission_callback' => [ $this, 'check_permission' ], - 'args' => $this->get_collection_params(), - ] - ] - ); - } - - public function check_permission() { - // Custom permission check. - return is_user_logged_in() || dokan_is_seller_enabled( get_current_user_id() );; + $customer = $this->prepare_item_for_response( $user_data, $request ); + return rest_ensure_response( $customer ); } - public function get_items( $request ) { - $items = []; // Your implementation - $total = count( $items ); - - $response = rest_ensure_response( $items ); - return $this->format_collection_response( $response, $request, $total ); + /** + * Formats a single customer for response output. + * + * @param WP_User $user_data User object. + * @param WP_REST_Request $request Request object. + * @return WP_REST_Response Response data. + */ + public function prepare_item_for_response( $user_data, $request ) { + // TODO: Implement API response formatting + return apply_filters( 'dokan_rest_prepare_admin', $response, $user_data, $request ); } } ``` + +This structure ensures that all controllers follow a standardized format while allowing flexibility and extendability. + diff --git a/dokan-class.php b/dokan-class.php index 183baae3da..6f32ef4e6f 100755 --- a/dokan-class.php +++ b/dokan-class.php @@ -25,7 +25,7 @@ final class WeDevs_Dokan { * * @var string */ - public $version = '3.14.9'; + public $version = '3.14.10'; /** * Instance of self diff --git a/dokan.php b/dokan.php index e721aeb2b7..486e01d107 100755 --- a/dokan.php +++ b/dokan.php @@ -3,13 +3,13 @@ * 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.9 + * Version: 3.14.10 * Author: Dokan Inc. * Author URI: https://dokan.co/wordpress/ * Text Domain: dokan-lite * Requires Plugins: woocommerce * WC requires at least: 8.5.0 - * WC tested up to: 9.6.1 + * WC tested up to: 9.7.0 * Domain Path: /languages/ * License: GPL2 */ diff --git a/includes/Abstracts/DokanRESTAdminController.php b/includes/Abstracts/DokanRESTAdminController.php index 16f0307161..79c524514a 100644 --- a/includes/Abstracts/DokanRESTAdminController.php +++ b/includes/Abstracts/DokanRESTAdminController.php @@ -2,30 +2,15 @@ namespace WeDevs\Dokan\Abstracts; +use WeDevs\Dokan\REST\DokanBaseAdminController; + /** * Admin Dashboard * * @since 2.8.0 +* @deprecated DOKAN_SINCE Use \WeDevs\Dokan\REST\DokanBaseAdminController instead. * * @package dokan */ -abstract class DokanRESTAdminController extends DokanRESTBaseController { - - /** - * Endpoint namespace. - * - * @var string - */ - protected $namespace = 'dokan/v1/admin'; - - /** - * Check if user has admin permission. - * - * @since 2.8.0 - * - * @return bool - */ - public function check_permission() { - return current_user_can( 'manage_woocommerce' ); - } +abstract class DokanRESTAdminController extends DokanBaseAdminController { } diff --git a/includes/Abstracts/DokanRESTBaseController.php b/includes/Abstracts/DokanRESTBaseController.php index 16485fe422..e6046b2553 100644 --- a/includes/Abstracts/DokanRESTBaseController.php +++ b/includes/Abstracts/DokanRESTBaseController.php @@ -2,66 +2,15 @@ namespace WeDevs\Dokan\Abstracts; -use WP_REST_Controller; +use WeDevs\Dokan\REST\DokanBaseController; /** * Base REST Controller for Dokan * - * @since DOKAN_PRO_SINCE + * @since 3.14.4 + * @deprecated DOKAN_SINCE Use \WeDevs\Dokan\REST\DokanBaseController instead. * * @package dokan */ -abstract class DokanRESTBaseController extends WP_REST_Controller { - - /** - * Endpoint namespace - * - * @var string - */ - protected $namespace = 'dokan/v1'; - - /** - * Format item's collection for response - * - * @since DOKAN_PRO_SINCE - * - * @param object $response - * @param object $request - * @param array $items - * @param int $total_items - * - * @return object - */ - public function format_collection_response( $response, $request, $total_items ) { - if ( $total_items === 0 ) { - return $response; - } - - // Pagination values for headers. - $per_page = (int) ( ! empty( $request['per_page'] ) ? $request['per_page'] : 20 ); - $page = (int) ( ! empty( $request['page'] ) ? $request['page'] : 1 ); - - $response->header( 'X-WP-Total', (int) $total_items ); - - $max_pages = ceil( $total_items / $per_page ); - - $response->header( 'X-WP-TotalPages', (int) $max_pages ); - $base = add_query_arg( $request->get_query_params(), rest_url( sprintf( '/%s/%s', $this->namespace, $this->base ) ) ); - - if ( $page > 1 ) { - $prev_page = $page - 1; - if ( $prev_page > $max_pages ) { - $prev_page = $max_pages; - } - $prev_link = add_query_arg( 'page', $prev_page, $base ); - $response->link_header( 'prev', $prev_link ); - } - if ( $max_pages > $page ) { - $next_page = $page + 1; - $next_link = add_query_arg( 'page', $next_page, $base ); - $response->link_header( 'next', $next_link ); - } - - return $response; - } +abstract class DokanRESTBaseController extends DokanBaseController { } diff --git a/includes/Abstracts/DokanRESTCustomerController.php b/includes/Abstracts/DokanRESTCustomerController.php index a2c13cc3ea..a57ce27d45 100644 --- a/includes/Abstracts/DokanRESTCustomerController.php +++ b/includes/Abstracts/DokanRESTCustomerController.php @@ -2,30 +2,15 @@ namespace WeDevs\Dokan\Abstracts; +use WeDevs\Dokan\REST\DokanBaseCustomerController; + /** * Customer REST Controller for Dokan * - * @since DOKAN_PRO_SINCE + * @since 3.14.4 + * @deprecated DOKAN_SINCE Use \WeDevs\Dokan\REST\DokanBaseCustomerController instead. * * @package dokan */ -abstract class DokanRESTCustomerController extends DokanRESTBaseController { - - /** - * Endpoint base. - * - * @var string - */ - protected $rest_base = 'customer'; - - /** - * Check if user has customer permission. - * - * @since DOKAN_PRO_SINCE - * - * @return bool - */ - public function check_permission() { - return is_user_logged_in(); - } +abstract class DokanRESTCustomerController extends DokanBaseCustomerController { } diff --git a/includes/Abstracts/DokanRESTVendorController.php b/includes/Abstracts/DokanRESTVendorController.php index 13335afaf2..2de7aa1f5e 100644 --- a/includes/Abstracts/DokanRESTVendorController.php +++ b/includes/Abstracts/DokanRESTVendorController.php @@ -2,30 +2,15 @@ namespace WeDevs\Dokan\Abstracts; +use WeDevs\Dokan\REST\DokanBaseVendorController; + /** * Vendor REST Controller for Dokan * - * @since DOKAN_PRO_SINCE + * @since 3.14.4 + * @deprecated DOKAN_SINCE Use \WeDevs\Dokan\REST\DokanBaseVendorController instead. * * @package dokan */ -abstract class DokanRESTVendorController extends DokanRESTBaseController { - - /** - * Endpoint base. - * - * @var string - */ - protected $rest_base = 'vendor'; - - /** - * Check if user has vendor permission. - * - * @since DOKAN_PRO_SINCE - * - * @return bool - */ - public function check_permission() { - return current_user_can( 'dokandar' ); - } +abstract class DokanRESTVendorController extends DokanBaseVendorController { } diff --git a/includes/Abstracts/DokanShortcode.php b/includes/Abstracts/DokanShortcode.php index 968b4161f1..4d2c5b34e3 100644 --- a/includes/Abstracts/DokanShortcode.php +++ b/includes/Abstracts/DokanShortcode.php @@ -8,7 +8,7 @@ abstract class DokanShortcode { public function __construct() { if ( empty( $this->shortcode ) ) { - dokan_doing_it_wrong( static::class, __( '$shortcode property is empty.', 'dokan-lite' ), '3.0.0' ); + _doing_it_wrong( static::class, __( '$shortcode property is empty.', 'dokan-lite' ), '3.0.0' ); } add_shortcode( $this->shortcode, [ $this, 'render_shortcode' ] ); diff --git a/includes/Admin/Settings.php b/includes/Admin/Settings.php index c60ec94825..8b51536def 100644 --- a/includes/Admin/Settings.php +++ b/includes/Admin/Settings.php @@ -982,7 +982,7 @@ public function add_settings_after( $settings_fields, $section, $option, $additi /** * Add settings nonce to localized vars * - * @since DOKNA_LITE_SINCE + * @since 3.0.6 * * @param array $vars * @@ -997,7 +997,7 @@ public function add_admin_settings_nonce( $vars ) { /** * Get refreshed options for a admin setting * - * @since DOKAN_LITE_SINCE + * @since 3.0.6 * * @return void */ diff --git a/includes/Admin/UserProfile.php b/includes/Admin/UserProfile.php index 3fcfb64cdd..bcee3ca820 100755 --- a/includes/Admin/UserProfile.php +++ b/includes/Admin/UserProfile.php @@ -79,6 +79,12 @@ public function add_meta_fields( $user ) { $banner_width = dokan_get_vendor_store_banner_width(); $banner_height = dokan_get_vendor_store_banner_height(); + $shop_slug = $user->data->user_nicename ?? ''; + if ( user_can( $user->ID, 'vendor_staff' ) ) { + $vendor = new \WP_User( get_user_meta( $user->ID, '_vendor_id', true ) ); + $shop_slug = $vendor->data->user_nicename ?? ''; + } + $country_state = array( 'country' => array( 'label' => __( 'Country', 'dokan-lite' ), @@ -114,7 +120,7 @@ public function add_meta_fields( $user ) {

- - - - -

/data->user_nicename ); ?>

- - + + + + + + +

/

+ + diff --git a/includes/BackgroundProcess/Manager.php b/includes/BackgroundProcess/Manager.php index a147bc7089..b6bccd0f2e 100644 --- a/includes/BackgroundProcess/Manager.php +++ b/includes/BackgroundProcess/Manager.php @@ -10,7 +10,7 @@ /** * Background Process Manager Class. * - * @since DOKAN_LITE_SINCE + * @since 3.7.10 * * @property ChangeVendorProductStatus $change_vendor_product_status Instance of WeDevs\Dokan\Vendor\ChangeProductStatus class */ @@ -29,7 +29,7 @@ public function __construct() { /** * Initialize classes to chainable container. * - * @since DOKAN_LITE_SINCE + * @since 3.7.10 * * @return void */ @@ -43,7 +43,7 @@ public function init_classes() { /** * Initialize hooks. * - * @since DOKAN_LITE_SINCE + * @since 3.7.10 * * @return void */ @@ -54,7 +54,7 @@ public function init_hooks() { /** * Show variable products author updated notice. * - * @since DOKAN_LITE_SINCE + * @since 3.7.10 * * @param array $notices * diff --git a/includes/BackgroundProcess/RewriteVariableProductsAuthor.php b/includes/BackgroundProcess/RewriteVariableProductsAuthor.php index 8154b99257..518dfff502 100644 --- a/includes/BackgroundProcess/RewriteVariableProductsAuthor.php +++ b/includes/BackgroundProcess/RewriteVariableProductsAuthor.php @@ -13,7 +13,7 @@ /** * RewriteVariableProductsAuthor Class. * - * @since DOKAN_LITE_SINCE + * @since 3.7.10 */ class RewriteVariableProductsAuthor extends WC_Background_Process { @@ -31,7 +31,7 @@ public function __construct() { * * Updater will still run via cron job if this fails for any reason. * - * @since DOKAN_LITE_SINCE + * @since 3.7.10 * * @return void */ @@ -49,7 +49,7 @@ public function dispatch() { /** * Perform updates. * - * @since DOKAN_LITE_SINCE + * @since 3.7.10 * * @param array $args * @@ -70,7 +70,7 @@ public function task( $args ) { /** * Rewrite variable product variations author IDs. * - * @since DOKAN_LITE_SINCE + * @since 3.7.10 * * @param int $page * @@ -105,7 +105,7 @@ protected function rewrite_variable_product_variations_author_ids( $page = 1 ) { /** * Complete the process. * - * @since DOKAN_LITE_SINCE + * @since 3.7.10 * * @return void */ diff --git a/includes/Commission.php b/includes/Commission.php index e3db01f01e..19825edf3e 100644 --- a/includes/Commission.php +++ b/includes/Commission.php @@ -260,7 +260,7 @@ public function get_earning_by_order( $order, $context = 'seller' ) { } if ( $context === dokan()->fees->get_shipping_fee_recipient( $order ) ) { - $earning_or_commission += $order->get_shipping_total() - $order->get_total_shipping_refunded(); + $earning_or_commission += floatval( $order->get_shipping_total() ) - $order->get_total_shipping_refunded(); } if ( $context === dokan()->fees->get_tax_fee_recipient( $order->get_id() ) ) { @@ -452,7 +452,7 @@ public function get_total_shipping_tax_refunded( WC_Order $order ): float { * * @deprecated 3.14.0 Use dokan()->fees->get_processing_fee instead. * - * @since DOKAN_LITE_SINCE + * @since 3.0.4 * * @param WC_Order $order * @@ -467,7 +467,7 @@ public function get_processing_fee( $order ) { /** * Get all the orders to be processed * - * @since DOKAN_LITE_SINCE + * @since 3.0.4 * * @param WC_Order $order * diff --git a/includes/Commission/Upugrader/Update_Category_Commission.php b/includes/Commission/Upugrader/Update_Category_Commission.php index 1e2ea42057..552ebf20c0 100644 --- a/includes/Commission/Upugrader/Update_Category_Commission.php +++ b/includes/Commission/Upugrader/Update_Category_Commission.php @@ -10,21 +10,21 @@ class Update_Category_Commission { /** * The batch size for processing categories * - * @since DOKAN_PRO_SINCE + * @since 3.14.0 */ const BATCH_SIZE = 20; /** * The hook name for processing batches * - * @since DOKAN_PRO_SINCE + * @since 3.14.0 */ const PROCESS_BATCH_HOOK = 'process_category_batch'; const PROCESS_BATCH_HOOK_CREATOR = 'process_category_batch_creator'; /** * - * @since DOKAN_PRO_SINCE + * @since 3.14.0 */ const PROCESS_ITEM_HOOK = 'process_category_item'; @@ -40,7 +40,7 @@ public function init_hooks() { /** * Start the batch processing * - * @since DOKAN_PRO_SINCE + * @since 3.14.0 * * @return void */ @@ -81,7 +81,7 @@ public function process_batch_creator() { /** * Process a batch of categories * - * @since DOKAN_PRO_SINCE + * @since 3.14.0 * * @param int $page_number Current page number * @@ -101,7 +101,7 @@ public function process_batch( $offset ) { /** * Schedule the next batch of categories * - * @since DOKAN_PRO_SINCE + * @since 3.14.0 * * @param int $page_number Next page number to process * @@ -135,7 +135,7 @@ private function schedule_cat_item( $term ) { /** * Get a batch of categories. * - * @since DOKAN_PRO_SINCE + * @since 3.14.0 * * @param int $page_number Page number to fetch * @@ -174,7 +174,7 @@ protected function category_count() { /** * Process a single category. * - * @since DOKAN_PRO_SINCE + * @since 3.14.0 * * @param int $term Category term object * @@ -212,7 +212,7 @@ public function process_single_category( $term_id ) { /** * Check if processing is currently running. * - * @since DOKAN_PRO_SINCE + * @since 3.14.0 * * @return bool */ diff --git a/includes/Commission/Upugrader/Update_Product_Commission.php b/includes/Commission/Upugrader/Update_Product_Commission.php index 4f86b09b70..e9f38d36e2 100644 --- a/includes/Commission/Upugrader/Update_Product_Commission.php +++ b/includes/Commission/Upugrader/Update_Product_Commission.php @@ -12,21 +12,21 @@ class Update_Product_Commission { /** * The batch size for processing products * - * @since DOKAN_PRO_SINCE + * @since 3.14.0 */ const BATCH_SIZE = 10; /** * The hook name for processing batches * - * @since DOKAN_PRO_SINCE + * @since 3.14.0 */ const PROCESS_BATCH_HOOK = 'process_product_batch'; const PROCESS_BATCH_HOOK_CREATOR = 'process_product_batch_creator'; /** * - * @since DOKAN_PRO_SINCE + * @since 3.14.0 */ const PROCESS_ITEM_HOOK = 'process_product_item'; @@ -39,7 +39,7 @@ public function init_hooks() { /** * Start the batch processing * - * @since DOKAN_PRO_SINCE + * @since 3.14.0 * * @return void */ @@ -80,7 +80,7 @@ public function process_batch_creator() { /** * Process a batch of products * - * @since DOKAN_PRO_SINCE + * @since 3.14.0 * * @param int $offset Current offset * @param int $total_products Total number of products @@ -99,7 +99,7 @@ public function process_batch( $offset, $total_products ) { /** * Schedule the next batch of products * - * @since DOKAN_PRO_SINCE + * @since 3.14.0 * * @param int $offset Current offset * @param int $total_products Total number of products @@ -136,7 +136,7 @@ private function schedule_item( $item ) { /** * Get a batch of products * - * @since DOKAN_PRO_SINCE + * @since 3.14.0 * * @param int $offset Current offset * @@ -157,7 +157,7 @@ protected function get_products_batch( $offset ) { /** * Get total number of products * - * @since DOKAN_PRO_SINCE + * @since 3.14.0 * * @return int */ @@ -177,7 +177,7 @@ protected function get_total_products() { * Process a single product * Customize this method based on what you need to do with each product * - * @since DOKAN_PRO_SINCE + * @since 3.14.0 * * @param int $product * @@ -210,7 +210,7 @@ public function process_single_product( $product_id ) { /** * Check if processing is currently running * - * @since DOKAN_PRO_SINCE + * @since 3.14.0 * * @return bool */ diff --git a/includes/Commission/Upugrader/Update_Vendor_Commission.php b/includes/Commission/Upugrader/Update_Vendor_Commission.php index b310fe3cc4..37fa25b2f9 100644 --- a/includes/Commission/Upugrader/Update_Vendor_Commission.php +++ b/includes/Commission/Upugrader/Update_Vendor_Commission.php @@ -22,7 +22,7 @@ class Update_Vendor_Commission { /** * Initialize the processor * - * @since DOKAN_PRO_SINCE + * @since 3.14.0 */ public function init_hooks() { add_action( self::PROCESS_BATCH_HOOK_CREATOR, [ $this, 'process_batch_creator' ], 10, 2 ); @@ -33,7 +33,7 @@ public function init_hooks() { /** * Start the batch processing * - * @since DOKAN_PRO_SINCE + * @since 3.14.0 * * @return void */ @@ -71,7 +71,7 @@ public function process_batch_creator() { /** * Process a batch of vendors * - * @since DOKAN_PRO_SINCE + * @since 3.14.0 * * @param int $page_number Current page number * @param int $max_pages Total number of pages @@ -91,7 +91,7 @@ public function process_batch( $page_number, $max_pages ) { // phpcs:ignore /** * Get a batch of vendors * - * @since DOKAN_PRO_SINCE + * @since 3.14.0 * * @param int $page_number Page number to fetch * @@ -109,7 +109,7 @@ protected function get_vendors_batch( $page_number ) { /** * Schedule an individual vendor for processing * - * @since DOKAN_PRO_SINCE + * @since 3.14.0 * * @param int $vendor_id * @@ -126,7 +126,7 @@ private function schedule_item( $vendor_id ) { /** * Process a single vendor * - * @since DOKAN_PRO_SINCE + * @since 3.14.0 * * @param int $vendor_id Vendor ID * @@ -170,7 +170,7 @@ public function process_single_vendor( $vendor_id ) { /** * Log vendor update status * - * @since DOKAN_PRO_SINCE + * @since 3.14.0 * * @param int $vendor_id * @param bool $success @@ -192,7 +192,7 @@ private function log_vendor_update( $vendor_id, $success, $error_message = '' ) /** * Check if processing is currently running * - * @since DOKAN_PRO_SINCE + * @since 3.14.0 * * @return bool */ diff --git a/includes/Dashboard/Templates/Settings.php b/includes/Dashboard/Templates/Settings.php index 43b2f89daf..9ba74dafaa 100644 --- a/includes/Dashboard/Templates/Settings.php +++ b/includes/Dashboard/Templates/Settings.php @@ -723,7 +723,7 @@ private function get_payment_heading( $slug, $heading ) { /** * Check if a seller is connected to a payment method * - * @since DOKAN_PRO_SINCE + * @since 3.5.1 * * @param $payment_method_id * @param $seller_id @@ -775,7 +775,7 @@ public function is_seller_connected( $payment_method_id, $seller_id ) { /** * Get if user with id $seller_id is connected to the payment method having $payment_method_id * - * @since DOKAN_PRO_SINCE + * @since 3.5.1 * * @param bool $is_connected * @param string $payment_method_id diff --git a/includes/Emails/ContactSeller.php b/includes/Emails/ContactSeller.php index 1e39d7b2f3..29d92c61ad 100644 --- a/includes/Emails/ContactSeller.php +++ b/includes/Emails/ContactSeller.php @@ -18,7 +18,7 @@ class ContactSeller extends WC_Email { /** * Reply email * - * @since DOKAN_LITE_SINCE + * @since 3.2.15 * * @var string */ diff --git a/includes/Emails/VendorCompletedOrder.php b/includes/Emails/VendorCompletedOrder.php index 2987874602..7d136959e6 100644 --- a/includes/Emails/VendorCompletedOrder.php +++ b/includes/Emails/VendorCompletedOrder.php @@ -11,7 +11,7 @@ * An email sent to the admin when a order is completed for. * * @class VendorCompletedOrder - * @version DOKAN_LITE_SINCE + * @version 3.2.2 * @package Dokan/Classes/Emails * @author weDevs * @extends WC_Email @@ -48,7 +48,7 @@ public function __construct() { /** * Get email subject. * - * @since DOKAN_LITE_SINCE + * @since 3.2.2 * @return string */ public function get_default_subject() { @@ -58,7 +58,7 @@ public function get_default_subject() { /** * Get email heading. * - * @since DOKAN_LITE_SINCE + * @since 3.2.2 * @return string */ public function get_default_heading() { diff --git a/includes/Emails/VendorWithdrawRequest.php b/includes/Emails/VendorWithdrawRequest.php index e7c55d30ce..ae844f8b9b 100644 --- a/includes/Emails/VendorWithdrawRequest.php +++ b/includes/Emails/VendorWithdrawRequest.php @@ -30,6 +30,7 @@ public function __construct() { $this->placeholders = [ '{store_name}' => '', '{amount}' => '', + '{charge}' => '', '{method}' => '', '{profile_url}' => '', '{withdraw_page}' => '', @@ -39,7 +40,7 @@ public function __construct() { ]; // Triggers for this email - add_action( 'dokan_after_withdraw_request', array( $this, 'trigger' ), 30, 3 ); + add_action( 'dokan_after_withdraw_request', array( $this, 'trigger' ), 30, 4 ); // Call parent constructor parent::__construct(); @@ -71,21 +72,25 @@ public function get_default_heading() { /** * Trigger the sending of this email. * - * @param int $user_id User ID. - * @param mixed $amount Withdrawal amount. - * @param string $method Withdrawal method. + * @param int $user_id User ID. + * @param mixed $amount Withdrawal amount. + * @param string $method Withdrawal method. + * @param int $id Withdrawal id, */ - public function trigger( $user_id, $amount, $method ) { + public function trigger( $user_id, $amount, $method, $id ) { $seller = new Vendor( $user_id ); if ( ! $this->is_enabled() || ! $this->get_recipient() ) { return; } + $withdraw = dokan()->withdraw->get( $id ); + $this->setup_locale(); $this->object = $seller; $this->placeholders['{store_name}'] = $seller->get_shop_name(); $this->placeholders['{amount}'] = dokan()->email->currency_symbol( $amount ); + $this->placeholders['{charge}'] = dokan()->email->currency_symbol( $withdraw->get_charge() ); $this->placeholders['{method}'] = dokan_withdraw_get_method_title( $method ); $this->placeholders['{profile_url}'] = $seller->get_profile_url(); $this->placeholders['{withdraw_page}'] = admin_url( 'admin.php?page=dokan#/withdraw?status=pending' ); diff --git a/includes/Emails/WithdrawApproved.php b/includes/Emails/WithdrawApproved.php index 6ad769f8c8..2146dcf592 100644 --- a/includes/Emails/WithdrawApproved.php +++ b/includes/Emails/WithdrawApproved.php @@ -28,14 +28,15 @@ public function __construct() { $this->template_plain = 'emails/plain/withdraw-approve.php'; $this->template_base = DOKAN_DIR . '/templates/'; $this->placeholders = [ - '{store_name}' => '', - '{amount}' => '', - '{method}' => '', - '{profile_url}' => '', - '{withdraw_page}' => '', + '{store_name}' => '', + '{amount}' => '', + '{receivable_amount}' => '', + '{method}' => '', + '{profile_url}' => '', + '{withdraw_page}' => '', // Only for backward compatibility. - '{user_name}' => '', - '{site_name}' => $this->get_from_name(), + '{user_name}' => '', + '{site_name}' => $this->get_from_name(), ]; // Triggers for this email @@ -83,12 +84,13 @@ public function trigger( $withdraw ) { $this->object = $seller; $amount = wc_format_decimal( $withdraw->get_amount(), false, true ); - $this->placeholders['{store_name}'] = $seller->get_shop_name(); - $this->placeholders['{amount}'] = dokan()->email->currency_symbol( $amount ); - $this->placeholders['{method}'] = dokan_withdraw_get_method_title( $withdraw->get_method() ); - $this->placeholders['{profile_url}'] = esc_url( dokan_get_navigation_url( 'edit-account' ) ); - $this->placeholders['{withdraw_page}'] = esc_url( dokan_get_navigation_url( 'withdraw-requests' ) ); - $this->placeholders['{user_name}'] = $seller->get_shop_name(); // for backward compatibility. + $this->placeholders['{store_name}'] = $seller->get_shop_name(); + $this->placeholders['{amount}'] = dokan()->email->currency_symbol( $amount ); + $this->placeholders['{receivable_amount}'] = dokan()->email->currency_symbol( $withdraw->get_receivable_amount() ); + $this->placeholders['{method}'] = dokan_withdraw_get_method_title( $withdraw->get_method() ); + $this->placeholders['{profile_url}'] = esc_url( dokan_get_navigation_url( 'edit-account' ) ); + $this->placeholders['{withdraw_page}'] = esc_url( dokan_get_navigation_url( 'withdraw-requests' ) ); + $this->placeholders['{user_name}'] = $seller->get_shop_name(); // for backward compatibility. $this->send( $seller->get_email(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() ); $this->restore_locale(); diff --git a/includes/Emails/WithdrawCancelled.php b/includes/Emails/WithdrawCancelled.php index 2e958ced19..e5eaf80925 100644 --- a/includes/Emails/WithdrawCancelled.php +++ b/includes/Emails/WithdrawCancelled.php @@ -28,15 +28,16 @@ public function __construct() { $this->template_plain = 'emails/plain/withdraw-cancel.php'; $this->template_base = DOKAN_DIR . '/templates/'; $this->placeholders = [ - '{store_name}' => '', - '{amount}' => '', - '{method}' => '', - '{profile_url}' => '', - '{withdraw_page}' => dokan_get_navigation_url( 'withdraw' ), - '{note}' => '', + '{store_name}' => '', + '{amount}' => '', + '{receivable_amount}' => '', + '{method}' => '', + '{profile_url}' => '', + '{withdraw_page}' => dokan_get_navigation_url( 'withdraw' ), + '{note}' => '', // Only for backward compatibility. - '{user_name}' => '', - '{site_name}' => $this->get_from_name(), + '{user_name}' => '', + '{site_name}' => $this->get_from_name(), ]; // Triggers for this email @@ -83,12 +84,13 @@ public function trigger( $withdraw ) { $seller = new Vendor( $withdraw->get_user_id() ); $this->object = $seller; - $this->placeholders['{store_name}'] = $seller->get_shop_name(); - $this->placeholders['{amount}'] = dokan()->email->currency_symbol( $withdraw->get_amount() ); - $this->placeholders['{method}'] = dokan_withdraw_get_method_title( $withdraw->get_method() ); - $this->placeholders['{profile_url}'] = dokan_get_navigation_url( 'edit-account' ); - $this->placeholders['{note}'] = $withdraw->get_note(); - $this->placeholders['{user_name}'] = $seller->get_shop_name(); // Only for backward compatibility. + $this->placeholders['{store_name}'] = $seller->get_shop_name(); + $this->placeholders['{amount}'] = dokan()->email->currency_symbol( $withdraw->get_amount() ); + $this->placeholders['{receivable_amount}'] = dokan()->email->currency_symbol( $withdraw->get_receivable_amount() ); + $this->placeholders['{method}'] = dokan_withdraw_get_method_title( $withdraw->get_method() ); + $this->placeholders['{profile_url}'] = dokan_get_navigation_url( 'edit-account' ); + $this->placeholders['{note}'] = $withdraw->get_note(); + $this->placeholders['{user_name}'] = $seller->get_shop_name(); // Only for backward compatibility. $this->send( $seller->get_email(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() ); $this->restore_locale(); diff --git a/includes/Fees.php b/includes/Fees.php index 0132612bdd..c93e552b31 100644 --- a/includes/Fees.php +++ b/includes/Fees.php @@ -124,7 +124,7 @@ public function calculate_gateway_fee( $order_id ) { /** * Get processing fee * - * @since DOKAN_LITE_SINCE + * @since 3.0.4 * * @param WC_Order $order * diff --git a/includes/Order/Admin/Hooks.php b/includes/Order/Admin/Hooks.php index 591334a43b..d6c4bb0cec 100644 --- a/includes/Order/Admin/Hooks.php +++ b/includes/Order/Admin/Hooks.php @@ -382,7 +382,7 @@ function fix_row_css_styles() { /** * Change order item display meta key. * - * @since DOKAN_LITE_SINCE + * @since 3.8.0 * @since 3.8.0 Moved this method from Order/Hooks.php file * * @param string $display_key @@ -400,7 +400,7 @@ public function change_order_item_display_meta_key( $display_key ) { /** * Change order item display meta value. * - * @since DOKAN_LITE_SINCE + * @since 3.8.0 * @since 3.8.0 Moved this method from Order/Hooks.php file * * @param string $display_value @@ -466,7 +466,11 @@ public function admin_on_untrash_order( $post_id ) { return; } - $child_orders = dokan()->order->get_child_orders( $order->get_id() ); + $child_orders = dokan()->order->get_child_orders( + $order->get_id(), [ + 'status' => [ 'trash' ], + ] + ); if ( ! $child_orders ) { return; } diff --git a/includes/Order/Manager.php b/includes/Order/Manager.php index d6efc38305..5370cae52c 100644 --- a/includes/Order/Manager.php +++ b/includes/Order/Manager.php @@ -448,20 +448,28 @@ public function get_customer_order_ids_by_seller( $customer_id, $seller_id ) { } /** + * Get all child orders of a parent order + * * @param int|WC_Order $parent_order + * @param array $args * * @return WC_Order[] */ - public function get_child_orders( $parent_order ) { + public function get_child_orders( $parent_order, array $args = [] ) { $parent_order_id = is_numeric( $parent_order ) ? $parent_order : $parent_order->get_id(); - - return wc_get_orders( - [ - 'type' => 'shop_order', - 'parent' => $parent_order_id, - 'limit' => -1, - ] + $default_args = [ + 'type' => 'shop_order', + 'parent' => $parent_order_id, + 'limit' => -1, + ]; + + $args = apply_filters( + 'dokan_get_child_orders_args', + wp_parse_args( $args, $default_args ), + $parent_order_id ); + + return wc_get_orders( $args ); } /** diff --git a/includes/Product/Hooks.php b/includes/Product/Hooks.php index 02f45a9847..8cb510d158 100644 --- a/includes/Product/Hooks.php +++ b/includes/Product/Hooks.php @@ -51,7 +51,7 @@ public function __construct() { /** * Callback for Ajax Action Initialization * - * @since DOKAN_LITE_SINCE + * @since 3.8.2 * @return void */ public function store_product_search_action() { @@ -172,7 +172,7 @@ public function store_product_search_action() { /** * Output the store product sorting options * - * @since DOKAN_LITE_SINCE + * @since 3.8.2 * @return void */ public function store_products_orderby() { diff --git a/includes/Product/functions.php b/includes/Product/functions.php index 8b2f44bdba..b95d401ed6 100644 --- a/includes/Product/functions.php +++ b/includes/Product/functions.php @@ -592,7 +592,7 @@ function dokan_get_translated_product_stock_status( $stock = false ) { /** * Get dokan store products filter catalog orderby * - * @since DOKAN_LITE_SINCE + * @since 3.2.7 * * @return array */ diff --git a/includes/ProductStatusRollback.php b/includes/ProductStatusRollback.php index fa304832d0..0ab0ddfc90 100644 --- a/includes/ProductStatusRollback.php +++ b/includes/ProductStatusRollback.php @@ -30,7 +30,7 @@ class ProductStatusRollback implements Hookable { /** * Constructor. * - * @since DOKAN_PRO_SINCE + * @since 3.14.9 */ public function __construct() { $this->register_hooks(); @@ -39,7 +39,7 @@ public function __construct() { /** * Set up necessary hooks * - * @since DOKAN_PRO_SINCE + * @since 3.14.9 * * @return void */ @@ -50,7 +50,7 @@ public function register_hooks(): void { /** * Process reject to draft batch operation * - * @since DOKAN_PRO_SINCE + * @since 3.14.9 * * @return void */ @@ -82,7 +82,7 @@ public function process_reject_operation(): void { /** * Filter the target status for product rollback * - * @since DOKAN_PRO_SINCE + * @since 3.14.9 * * @param string $target_status Target rollback status * @param WC_Product $product Product @@ -92,7 +92,7 @@ public function process_reject_operation(): void { /** * Action before product rollback * - * @since DOKAN_PRO_SINCE + * @since 3.14.9 * * @param WC_Product $product Product * @param string $target_status Target rollback status @@ -107,7 +107,7 @@ public function process_reject_operation(): void { /** * Action after product status rollback * - * @since DOKAN_PRO_SINCE + * @since 3.14.9 * * @param WC_Product $product Product * @param string $target_status Target rollback status diff --git a/includes/REST/AdminDashboardController.php b/includes/REST/AdminDashboardController.php index bb8c09212f..51aa389aa8 100644 --- a/includes/REST/AdminDashboardController.php +++ b/includes/REST/AdminDashboardController.php @@ -167,7 +167,7 @@ public function get_feeds( $request ) { /** * Support SimplePie class in WP 5.5+ * - * @since DOKAN_LITE_SINCE + * @since 3.0.10 * * @param array $response HTTP response. * @param array $parsed_args HTTP request arguments. diff --git a/includes/REST/CommissionControllerV1.php b/includes/REST/CommissionControllerV1.php index 4208166516..0907bc65f5 100644 --- a/includes/REST/CommissionControllerV1.php +++ b/includes/REST/CommissionControllerV1.php @@ -140,6 +140,6 @@ public function get_commission( $request ) { $data = 'seller' === $context ? $commission_or_earning->get_vendor_earning() : $commission_or_earning->get_admin_commission(); - return rest_ensure_response( wc_format_decimal( $data, wc_get_price_decimals() + 2 ) ); + return rest_ensure_response( wc_format_decimal( $data, wc_get_price_decimals() ) ); } } diff --git a/includes/REST/DokanBaseAdminController.php b/includes/REST/DokanBaseAdminController.php new file mode 100644 index 0000000000..b62404cdfb --- /dev/null +++ b/includes/REST/DokanBaseAdminController.php @@ -0,0 +1,29 @@ +header( 'X-WP-Total', (int) $total_items ); + + $max_pages = ceil( $total_items / $per_page ); + + $response->header( 'X-WP-TotalPages', (int) $max_pages ); + $base = add_query_arg( $request->get_query_params(), rest_url( sprintf( '/%s/%s', $this->namespace, $this->base ?? $this->rest_base ) ) ); + + if ( $page > 1 ) { + $prev_page = $page - 1; + if ( $prev_page > $max_pages ) { + $prev_page = $max_pages; + } + $prev_link = add_query_arg( 'page', $prev_page, $base ); + $response->link_header( 'prev', $prev_link ); + } + if ( $max_pages > $page ) { + $next_page = $page + 1; + $next_link = add_query_arg( 'page', $next_page, $base ); + $response->link_header( 'next', $next_link ); + } + + return $response; + } +} diff --git a/includes/REST/DokanBaseCustomerController.php b/includes/REST/DokanBaseCustomerController.php new file mode 100644 index 0000000000..807c656ed8 --- /dev/null +++ b/includes/REST/DokanBaseCustomerController.php @@ -0,0 +1,33 @@ +prepare_note_item_for_response( $note, $request ); $response = rest_ensure_response( $response ); $response->set_status( 201 ); - $response->header( 'Location', rest_url( sprintf( '/%s/%s/%d', $this->namespace, str_replace( '(?P[\d]+)', $order->get_id(), $this->rest_base ), $note_id ) ) ); + $response->header( 'Location', rest_url( sprintf( '/%s/%s/%d', $this->namespace, str_replace( '(?P[\d]+)', $order->get_id(), $this->base ), $note_id ) ) ); return $response; } diff --git a/includes/REST/StoreController.php b/includes/REST/StoreController.php index f6d71edafc..0904a215cd 100644 --- a/includes/REST/StoreController.php +++ b/includes/REST/StoreController.php @@ -3,7 +3,6 @@ namespace WeDevs\Dokan\REST; use WeDevs\Dokan\Vendor\Vendor; -use Dokan_REST_Product_Controller; use WP_Error; use WP_Query; use WP_REST_Controller; @@ -87,6 +86,7 @@ public function register_routes() { 'methods' => WP_REST_Server::EDITABLE, 'callback' => [ $this, 'update_store' ], 'permission_callback' => [ $this, 'update_store_permissions_check' ], + 'args' => $this->get_store_update_params(), ], ] ); @@ -433,15 +433,15 @@ public function permission_check_for_manageable_part() { /** * Prepare links for the request. * - * @param \WC_Data $object Object data. + * @param \WC_Data $data Object data. * @param WP_REST_Request $request Request object. * * @return array Links for the given post. */ - protected function prepare_links( $object, $request ) { + protected function prepare_links( $data, $request ) { $links = [ 'self' => [ - 'href' => rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->base, $object['id'] ) ), + 'href' => rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->base, $data['id'] ) ), ], 'collection' => [ 'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $this->base ) ), @@ -510,7 +510,7 @@ public function format_collection_response( $response, $request, $total_items ) * @return WP_Error|WP_REST_Response */ public function get_store_products( $request ) { - $product_controller = new Dokan_REST_Product_Controller(); + $product_controller = new ProductController(); $request->set_param( 'status', [ 'publish' ] ); $request->set_param( 'author', $request['id'] ); @@ -1000,4 +1000,133 @@ public function get_store_collection_params(): array { return array_merge( parent::get_collection_params(), $params ); } + + /** + * Updated query params for the store. + * + * @since 3.14.10 + * + * @return array Query parameters for the store update. + */ + public function get_store_update_params(): array { + $params = [ + 'id' => [ + 'description' => esc_html__( 'Unique identifier for the vendor.', 'dokan-lite' ), + 'type' => 'integer', + 'required' => true, + 'sanitize_callback' => 'absint', + ], + 'first_name' => [ + 'description' => esc_html__( 'Store owner first name.', 'dokan-lite' ), + 'type' => 'string', + 'sanitize_callback' => 'sanitize_text_field', + ], + 'last_name' => [ + 'description' => esc_html__( 'Store owner last name.', 'dokan-lite' ), + 'type' => 'string', + 'sanitize_callback' => 'sanitize_text_field', + ], + 'user_nicename' => [ + 'description' => esc_html__( 'User nice name.', 'dokan-lite' ), + 'type' => 'string', + 'sanitize_callback' => 'sanitize_text_field', + ], + 'user_pass' => [ + 'description' => esc_html__( 'User password.', 'dokan-lite' ), + 'type' => 'string', + ], + 'email' => [ + 'description' => esc_html__( 'Store email address.', 'dokan-lite' ), + 'type' => 'string', + 'format' => 'email', + 'validate_callback' => 'sanitize_email', + ], + 'store_name' => [ + 'description' => esc_html__( 'Store name.', 'dokan-lite' ), + 'type' => 'string', + 'sanitize_callback' => 'sanitize_text_field', + ], + 'phone' => [ + 'description' => esc_html__( 'Store phone number.', 'dokan-lite' ), + 'type' => 'string', + 'sanitize_callback' => 'sanitize_text_field', + ], + 'show_email' => [ + 'description' => esc_html__( 'Show email in store.', 'dokan-lite' ), + 'type' => 'boolean', + 'default' => false, + ], + 'gravatar_id' => [ + 'description' => esc_html__( 'Gravatar ID.', 'dokan-lite' ), + 'type' => 'integer', + ], + 'banner_id' => [ + 'description' => esc_html__( 'Banner ID.', 'dokan-lite' ), + 'type' => 'integer', + ], + 'enable_tnc' => [ + 'description' => esc_html__( 'Enable terms and conditions.', 'dokan-lite' ), + 'type' => 'boolean', + ], + 'store_tnc' => [ + 'description' => esc_html__( 'Store terms and conditions.', 'dokan-lite' ), + 'type' => 'string', + ], + 'icon' => [ + 'description' => esc_html__( 'Store icon.', 'dokan-lite' ), + 'type' => 'string', + ], + 'social' => [ + 'description' => esc_html__( 'Social profiles.', 'dokan-lite' ), + 'type' => 'object', + 'properties' => [ + 'fb' => [ 'type' => 'string' ], + 'twitter' => [ 'type' => 'string' ], + 'pinterest' => [ 'type' => 'string' ], + 'linkedin' => [ 'type' => 'string' ], + 'youtube' => [ 'type' => 'string' ], + 'instagram' => [ 'type' => 'string' ], + ], + ], + 'address' => [ + 'description' => esc_html__( 'Store address.', 'dokan-lite' ), + 'type' => 'object', + 'properties' => [ + 'street_1' => [ 'type' => 'string' ], + 'street_2' => [ 'type' => 'string' ], + 'city' => [ 'type' => 'string' ], + 'zip' => [ 'type' => 'string' ], + 'state' => [ 'type' => 'string' ], + 'country' => [ 'type' => 'string' ], + ], + ], + // Admin only fields + 'enabled' => [ + 'description' => esc_html__( 'Enable selling.', 'dokan-lite' ), + 'type' => 'boolean', + ], + 'featured' => [ + 'description' => esc_html__( 'Featured vendor.', 'dokan-lite' ), + 'type' => 'boolean', + ], + 'trusted' => [ + 'description' => esc_html__( 'Trusted vendor.', 'dokan-lite' ), + 'type' => 'boolean', + ], + 'admin_commission' => [ + 'description' => esc_html__( 'Admin commission amount.', 'dokan-lite' ), + 'type' => [ 'number', 'string' ], + ], + 'admin_additional_fee' => [ + 'description' => esc_html__( 'Admin additional fee.', 'dokan-lite' ), + 'type' => [ 'number', 'string' ], + ], + 'admin_category_commission' => [ + 'description' => esc_html__( 'Category wise commission.', 'dokan-lite' ), + 'type' => 'object', + ], + ]; + + return apply_filters( 'dokan_rest_api_store_update_params', $params ); + } } diff --git a/includes/REST/StoreSettingController.php b/includes/REST/StoreSettingController.php index 47a0abf5c3..4af45690ee 100644 --- a/includes/REST/StoreSettingController.php +++ b/includes/REST/StoreSettingController.php @@ -56,7 +56,7 @@ public function register_routes() { * * @param \WP_REST_Request $request * - * @since DOKAN_LITE_SINCE + * @since 3.2.12 * * @return WP_Error|\WP_REST_Response */ diff --git a/includes/Rewrites.php b/includes/Rewrites.php index 542473ab45..e231e7cf0a 100755 --- a/includes/Rewrites.php +++ b/includes/Rewrites.php @@ -382,7 +382,7 @@ public function store_query_filter( $query ) { /** * Returns an array of arguments for ordering products based on the selected values. * - * @since DOKAN_LITE_SINCE + * @since 3.2.7 * * @param string $orderby Order by param * @param string $order Order param @@ -458,7 +458,7 @@ public function get_catalog_ordering_args( $orderby = '', $order = '' ) { /** * Handle numeric price sorting * - * @since DOKAN_LITE_SINCE + * @since 3.2.7 * * @param array $args Query args * @@ -473,7 +473,7 @@ public function order_by_price_asc_post_clauses( $args ) { /** * Handle numeric price sorting * - * @since DOKAN_LITE_SINCE + * @since 3.2.7 * * @param array $args Query args * @@ -490,7 +490,7 @@ public function order_by_price_desc_post_clauses( $args ) { * * This lets us sort by meta value desc, and have a second orderby param * - * @since DOKAN_LITE_SINCE + * @since 3.2.7 * * @param array $args Query args * @@ -505,7 +505,7 @@ public function order_by_popularity_post_clauses( $args ) { /** * Order by rating post clauses * - * @since DOKAN_LITE_SINCE + * @since 3.2.7 * * @param array $args Query args * @@ -520,7 +520,7 @@ public function order_by_rating_post_clauses( $args ) { /** * Join wc_product_meta_lookup to posts if not already joined. * - * @since DOKAN_LITE_SINCE + * @since 3.2.7 * * @param string $sql SQL join * diff --git a/includes/Shortcodes/CustomerMigration.php b/includes/Shortcodes/CustomerMigration.php new file mode 100644 index 0000000000..9c02ca5e05 --- /dev/null +++ b/includes/Shortcodes/CustomerMigration.php @@ -0,0 +1,39 @@ +get( 'frontend_manager' )->become_a_vendor->load_customer_to_vendor_update_template(); + wp_enqueue_script( 'dokan-vendor-registration' ); + return ob_get_clean(); + } +} diff --git a/includes/Shortcodes/Shortcodes.php b/includes/Shortcodes/Shortcodes.php index 5bc55fbf76..5b91a62923 100644 --- a/includes/Shortcodes/Shortcodes.php +++ b/includes/Shortcodes/Shortcodes.php @@ -17,6 +17,7 @@ class Shortcodes { * Register Dokan shortcodes * * @since 3.0.0 + * @since 3.14.10 Added dokan-customer-migration shortcode. * * @return void */ @@ -29,6 +30,7 @@ public function __construct() { 'dokan-my-orders' => new MyOrders(), 'dokan-stores' => new Stores(), 'dokan-vendor-registration' => new VendorRegistration(), + 'dokan-customer-migration' => new CustomerMigration(), ] ); } diff --git a/includes/ThemeSupport/Divi.php b/includes/ThemeSupport/Divi.php index e86357c81f..f4a1649154 100644 --- a/includes/ThemeSupport/Divi.php +++ b/includes/ThemeSupport/Divi.php @@ -88,7 +88,7 @@ public function full_width_page( $classes ) { /** * Set current page for the query * - * @since DOKAN_LITE_SINCE + * @since 3.0.5 * * @see https://github.com/weDevsOfficial/dokan/issues/838 * diff --git a/includes/Traits/VendorAuthorizable.php b/includes/Traits/VendorAuthorizable.php new file mode 100644 index 0000000000..ca09adc500 --- /dev/null +++ b/includes/Traits/VendorAuthorizable.php @@ -0,0 +1,16 @@ + 0; - $state_is_empty = empty( $state ); // Validating fileds. - // Validating fileds. + $country_has_states = isset( $states[ $country ] ); + $state_is_empty = empty( $state ); // Validating filed. + // Validating filed. $is_valid_form = true; if ( empty( $dokan_settings['address']['street_1'] ) ) { $is_valid_form = false; @@ -506,11 +506,13 @@ public function dokan_setup_store_save() { if ( empty( $dokan_settings['address']['country'] ) ) { $is_valid_form = false; $_POST['error_address[country]'] = 'error'; - } elseif ( ( $country_has_states && $state_is_empty ) || ( ! $country_has_states && $state_is_empty ) ) { + } elseif ( ( $country_has_states && count( $states[ $country ] ) > 0 && $state_is_empty ) ) { + $is_valid_form = false; + $_POST['error_address[state]'] = 'error'; + } elseif ( ! $country_has_states && $state_is_empty ) { $is_valid_form = false; $_POST['error_address[state]'] = 'error'; } - if ( ! $is_valid_form ) { return; } diff --git a/includes/Vendor/UserSwitch.php b/includes/Vendor/UserSwitch.php index 5609969819..2316fabc8b 100644 --- a/includes/Vendor/UserSwitch.php +++ b/includes/Vendor/UserSwitch.php @@ -10,14 +10,14 @@ /** * User Switching functionality * -* @since DOKAN_LITE_SINCE +* @since 3.0.6 */ class UserSwitch { /** * Load automatically when class initiate * - * @since DOKAN_LITE_SINCE + * @since 3.0.6 */ public function __construct() { add_filter( 'dokan_admin_localize_script', [ $this, 'add_localize_data' ], 15 ); @@ -28,7 +28,7 @@ public function __construct() { /** * Is feature active or not * - * @since DOKAN_LITE_SINCE + * @since 3.0.6 * * @return boolean */ @@ -45,7 +45,7 @@ public function is_feature_active() { /** * Add localize scription for loading if feature available or not * - * @since DOKAN_LITE_SINCE + * @since 3.0.6 * * @return array */ @@ -58,7 +58,7 @@ public function add_localize_data( $localize_data ) { /** * Populate switch url for user * - * @since DOKAN_LITE_SINCE + * @since 3.0.6 * * @return array */ @@ -85,7 +85,7 @@ public function populate_switch_url( $data, $store, $request ) { /** * Switch to or Switch Back to user message in vendor dashboard * - * @since DOKAN_LITE_SINCE + * @since 3.0.6 * * @return void */ diff --git a/includes/Widgets/FilterByAttributes.php b/includes/Widgets/FilterByAttributes.php index 1045290d1b..2c7a3bea05 100755 --- a/includes/Widgets/FilterByAttributes.php +++ b/includes/Widgets/FilterByAttributes.php @@ -23,7 +23,7 @@ public function __construct() { /** * Front-end display of widget. * - * @since DOKAN_PRO_SINCE + * @since 3.5.0 * * @param array $args Widget arguments. * @param array $instance Saved values from database. @@ -72,7 +72,7 @@ public function widget( $args, $instance ) { /** * Back-end widget form. * - * @since DOKAN_PRO_SINCE + * @since 3.5.0 * * @param array $instance Previously saved values from database. * @@ -132,7 +132,7 @@ public function form( $instance ) { /** * Sanitize widget form values as they are saved. * - * @since DOKAN_PRO_SINCE + * @since 3.5.0 * * @param array $new_instance Values just sent to be saved. * @param array $old_instance Previously saved values from database. @@ -155,7 +155,7 @@ public function update( $new_instance, $old_instance ) { /** * Get this widget taxonomy. * - * @since DOKAN_PRO_SINCE + * @since 3.5.0 * * @param array $instance Array of instance options. * diff --git a/includes/Withdraw/Hooks.php b/includes/Withdraw/Hooks.php index 23acb51a9c..2613ae410c 100644 --- a/includes/Withdraw/Hooks.php +++ b/includes/Withdraw/Hooks.php @@ -201,7 +201,7 @@ public function ajax_handle_withdraw_request() { wp_send_json_error( $result->get_error_message(), $result->get_error_code() ); } - do_action( 'dokan_after_withdraw_request', $user_id, $amount, $method ); + do_action( 'dokan_after_withdraw_request', $user_id, $amount, $method, $result->get_id() ); wp_send_json_success( __( 'Withdraw request successful.', 'dokan-lite' ) ); } diff --git a/includes/Withdraw/Manager.php b/includes/Withdraw/Manager.php index 0d87f8cc14..69638f0033 100644 --- a/includes/Withdraw/Manager.php +++ b/includes/Withdraw/Manager.php @@ -191,6 +191,8 @@ public function insert_withdraw( $args = [] ) { return new WP_Error( 'dokan_withdraw_unable_to_insert', __( 'Could not add new withdraw approval request.', 'dokan-lite' ) ); } + $withdraw_id = $wpdb->insert_id; + /** * After completed withdraw request * @@ -202,7 +204,7 @@ public function insert_withdraw( $args = [] ) { * @param float $amount * @param string $method */ - do_action( 'dokan_after_withdraw_request', $data['user_id'], $data['amount'], $data['method'] ); + do_action( 'dokan_after_withdraw_request', $data['user_id'], $data['amount'], $data['method'], $withdraw_id ); return true; } @@ -374,7 +376,7 @@ public function all( $args = [] ) { } /** - * @since DOKAN_LITE_SINCE + * @since 3.2.0 * * @return int|null */ diff --git a/includes/Withdraw/Withdraw.php b/includes/Withdraw/Withdraw.php index 9c818c6c29..510b12c7e7 100644 --- a/includes/Withdraw/Withdraw.php +++ b/includes/Withdraw/Withdraw.php @@ -152,7 +152,7 @@ public function get_note() { /** * Get details * - * @since DOKAN_LITE_SINCE + * @since 3.2.12 * * @return string */ @@ -303,7 +303,7 @@ public function set_note( $note ) { /** * Set details * - * @since DOKAN_LITE_SINCE + * @since 3.2.12 * * @param string $details * diff --git a/includes/functions-dashboard-navigation.php b/includes/functions-dashboard-navigation.php index 97301b5af5..f194aed2f6 100644 --- a/includes/functions-dashboard-navigation.php +++ b/includes/functions-dashboard-navigation.php @@ -210,7 +210,7 @@ function dokan_dashboard_nav( $active_menu = '' ) { /** * Filters a menu key according to slug if needed. * - * @since DOKAN_PRO_SINCE + * @since 3.10.0 * * @param string $menu_key */ diff --git a/includes/functions.php b/includes/functions.php index f6605fe5a2..5fa665d131 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -203,14 +203,14 @@ function dokan_redirect_if_not_seller( $redirect = '' ) { */ function dokan_count_posts( $post_type, $user_id, $exclude_product_types = [ 'booking', 'auction' ] ) { // get all function arguments as key => value pairs - $args = get_defined_vars(); + $args = apply_filters( 'dokan_count_posts_args', get_defined_vars() ); $cache_group = "seller_product_data_$user_id"; $cache_key = 'count_posts_' . md5( wp_json_encode( $args ) ); $counts = Cache::get( $cache_key, $cache_group ); if ( false === $counts ) { - $results = apply_filters( 'dokan_count_posts', null, $post_type, $user_id ); + $results = apply_filters( 'dokan_count_posts', null, $post_type, $user_id, $exclude_product_types ); if ( ! $results ) { global $wpdb; @@ -262,7 +262,7 @@ function dokan_count_posts( $post_type, $user_id, $exclude_product_types = [ 'bo /** * Count stock product type from a user * - * @since DOKAN_LITE_SINCE + * @since 3.2.5 * * @param string $post_type * @param int $user_id @@ -275,11 +275,11 @@ function dokan_count_stock_posts( $post_type, $user_id, $stock_type, $exclude_pr global $wpdb; $cache_group = 'seller_product_stock_data_' . $user_id; - $cache_key = "count_stock_posts_{$user_id}_{$post_type}_{$stock_type}"; + $cache_key = apply_filters( 'dokan_count_stock_posts_cache_key', "count_stock_posts_{$user_id}_{$post_type}_{$stock_type}", $post_type, $user_id, $stock_type ); $counts = Cache::get( $cache_key, $cache_group ); if ( false === $counts ) { - $results = apply_filters( 'dokan_count_posts_' . $stock_type, null, $post_type, $user_id ); + $results = apply_filters( 'dokan_count_posts_' . $stock_type, null, $post_type, $user_id, $stock_type, $exclude_product_types ); $exclude_product_types_text = "'" . implode( "', '", esc_sql( $exclude_product_types ) ) . "'"; if ( ! $results ) { @@ -2676,7 +2676,7 @@ function dokan_delete_user_details( $user_id, $reassign ) { * * @param int $vendor_id * - * @return \Dokan_Vendor + * @return WeDevs\Dokan\Vendor\Vendor */ function dokan_get_vendor( $vendor_id = null ) { if ( ! $vendor_id ) { @@ -3575,7 +3575,7 @@ function dokan_clear_product_caches( $product ) { /** * Check which vendor info should be hidden * - * @since DOKAN_LITE_SINCE + * @since 3.0.4 * * @param string $option * @@ -3849,7 +3849,7 @@ function dokan_date_time_format( $time, $date_only = false ) { /** * Get threshold day for a user * - * @since DOKAN_LITE_SINCE + * @since 3.2.2 * * @param int $user_id * @@ -4123,7 +4123,7 @@ function dokan_bool_to_on_off( $bool ) { /** * Check is 12-hour format in current setup. * - * @since DOKAN_PRO_SINCE + * @since 3.6.0 * * @return bool */ diff --git a/includes/store-functions.php b/includes/store-functions.php index 021c63ea86..79412d6dde 100644 --- a/includes/store-functions.php +++ b/includes/store-functions.php @@ -3,7 +3,7 @@ /** * Checks if the theme sidebar is enabled on store page * - * @since DOKAN_LITE_SINCE + * @since 3.1.0 * * @return bool */ diff --git a/includes/template-tags.php b/includes/template-tags.php index 9a5e08fbec..b798e768d8 100755 --- a/includes/template-tags.php +++ b/includes/template-tags.php @@ -445,6 +445,9 @@ function dokan_seller_reg_form_fields() { $role = $data['role']; $role_style = ( $role === 'customer' ) ? 'display:none' : ''; + // Load vendor registration scripts in the registration form. + wp_enqueue_script( 'dokan-vendor-registration' ); + dokan_get_template_part( 'global/seller-registration-form', '', [ 'data' => $data, diff --git a/includes/wc-functions.php b/includes/wc-functions.php index 91fa6fae21..34b1d5de45 100755 --- a/includes/wc-functions.php +++ b/includes/wc-functions.php @@ -302,7 +302,7 @@ function ( $value ) { $manage_stock = $data['_manage_stock']; $backorders = wc_clean( $data['_backorders'] ); } - + update_post_meta( $post_id, '_manage_stock', $manage_stock ); update_post_meta( $post_id, '_backorders', $backorders ); if ( $stock_status ) { @@ -312,7 +312,7 @@ function ( $value ) { dokan_log( 'product stock update exception' ); } } - + // Retrieve original stock value from the hidden field $original_stock = isset( $data['_original_stock'] ) ? wc_stock_amount( wc_clean( $data['_original_stock'] ) ) : ''; // Clean the current stock value @@ -326,7 +326,7 @@ function ( $value ) { wc_update_product_stock( $post_id, $stock_amount ); } } - + // Update low stock amount regardless of stock changes $_low_stock_amount = isset( $data['_low_stock_amount'] ) ? wc_clean( $data['_low_stock_amount'] ) : ''; $_low_stock_amount = 'yes' === $manage_stock ? wc_stock_amount( wp_unslash( $_low_stock_amount ) ) : ''; @@ -939,7 +939,7 @@ function dokan_set_more_from_seller_tab( $tabs ) { * Show more products from current seller * * @since 2.5 - * @since DOKAN_LITE_SINCE added filter 'dokan_get_more_products_per_page' + * @since 3.2.2 added filter 'dokan_get_more_products_per_page' * * @param int|string $seller_id * @param int|string $posts_per_page diff --git a/languages/dokan-lite.pot b/languages/dokan-lite.pot index 6e53c1b635..36dff3d579 100644 --- a/languages/dokan-lite.pot +++ b/languages/dokan-lite.pot @@ -1,14 +1,14 @@ # Copyright (c) 2025 Dokan Inc. All Rights Reserved. msgid "" msgstr "" -"Project-Id-Version: Dokan 3.14.9\n" +"Project-Id-Version: Dokan 3.14.10\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: 2025-02-11T05:20:49+00:00\n" +"POT-Creation-Date: 2025-02-28T09:11:24+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" @@ -1085,7 +1085,7 @@ msgid "Email Address" msgstr "" #: includes/Admin/Settings.php:915 -#: includes/Admin/UserProfile.php:208 +#: includes/Admin/UserProfile.php:216 #: templates/account/update-customer-to-vendor.php:48 #: templates/account/vendor-registration.php:45 #: templates/global/seller-registration-form.php:54 @@ -1225,7 +1225,7 @@ msgid "Store" msgstr "" #: includes/Admin/SetupWizard.php:197 -#: includes/Admin/UserProfile.php:298 +#: includes/Admin/UserProfile.php:306 msgid "Selling" msgstr "" @@ -1463,7 +1463,7 @@ msgstr "" msgid "Not Available" msgstr "" -#: includes/Admin/UserProfile.php:84 +#: includes/Admin/UserProfile.php:90 #: includes/Privacy.php:226 #: includes/Vendor/SettingsApi/Settings/Pages/Store.php:218 #: includes/Vendor/SetupWizard.php:277 @@ -1473,98 +1473,98 @@ msgstr "" msgid "Country" msgstr "" -#: includes/Admin/UserProfile.php:88 +#: includes/Admin/UserProfile.php:94 #: includes/Vendor/SettingsApi/Settings/Pages/Store.php:222 msgid "Select a country…" msgstr "" -#: includes/Admin/UserProfile.php:91 +#: includes/Admin/UserProfile.php:97 msgid "State/County" msgstr "" -#: includes/Admin/UserProfile.php:92 +#: includes/Admin/UserProfile.php:98 msgid "State/County or state code" msgstr "" -#: includes/Admin/UserProfile.php:97 +#: includes/Admin/UserProfile.php:103 msgid "Dokan Options" msgstr "" -#: includes/Admin/UserProfile.php:102 +#: includes/Admin/UserProfile.php:108 msgid "Banner" msgstr "" -#: includes/Admin/UserProfile.php:114 +#: includes/Admin/UserProfile.php:120 #: templates/settings/store-form.php:72 msgid "Upload banner" msgstr "" #. translators: %1$s: banner width, %2$s: banner height in integers #. translators: 1) store banner width 2) store banner height -#: includes/Admin/UserProfile.php:119 +#: includes/Admin/UserProfile.php:125 #: templates/settings/store-form.php:86 msgid "Upload a banner for your store. Banner size is (%1$sx%2$s) pixels." msgstr "" -#: includes/Admin/UserProfile.php:131 +#: includes/Admin/UserProfile.php:137 #: includes/REST/ReverseWithdrawalController.php:681 msgid "Store name" msgstr "" -#: includes/Admin/UserProfile.php:138 +#: includes/Admin/UserProfile.php:144 #: assets/js/vue-admin.js:2 #: assets/js/vue-bootstrap.js:2 msgid "Store URL" msgstr "" -#: includes/Admin/UserProfile.php:146 +#: includes/Admin/UserProfile.php:154 #: includes/Privacy.php:222 msgid "Address 1" msgstr "" -#: includes/Admin/UserProfile.php:153 +#: includes/Admin/UserProfile.php:161 #: includes/Privacy.php:223 msgid "Address 2" msgstr "" -#: includes/Admin/UserProfile.php:160 +#: includes/Admin/UserProfile.php:168 msgid "Town/City" msgstr "" -#: includes/Admin/UserProfile.php:167 +#: includes/Admin/UserProfile.php:175 #: includes/Vendor/SettingsApi/Settings/Pages/Store.php:210 msgid "Zip Code" msgstr "" -#: includes/Admin/UserProfile.php:233 +#: includes/Admin/UserProfile.php:241 msgid "Payment Options : " msgstr "" -#: includes/Admin/UserProfile.php:238 +#: includes/Admin/UserProfile.php:246 msgid "Paypal Email " msgstr "" -#: includes/Admin/UserProfile.php:246 +#: includes/Admin/UserProfile.php:254 msgid "Skrill Email " msgstr "" -#: includes/Admin/UserProfile.php:255 +#: includes/Admin/UserProfile.php:263 msgid "Bank name " msgstr "" -#: includes/Admin/UserProfile.php:261 +#: includes/Admin/UserProfile.php:269 msgid "Account Name " msgstr "" -#: includes/Admin/UserProfile.php:267 +#: includes/Admin/UserProfile.php:275 msgid "Account Number " msgstr "" -#: includes/Admin/UserProfile.php:273 +#: includes/Admin/UserProfile.php:281 msgid "Bank Address " msgstr "" -#: includes/Admin/UserProfile.php:279 +#: includes/Admin/UserProfile.php:287 #: includes/Privacy.php:278 #: includes/Vendor/SettingsApi/Settings/Pages/Payments/Gateways/Bank.php:83 #: includes/Withdraw/functions.php:297 @@ -1574,43 +1574,43 @@ msgstr "" msgid "Routing Number" msgstr "" -#: includes/Admin/UserProfile.php:285 +#: includes/Admin/UserProfile.php:293 msgid "Bank IBAN " msgstr "" -#: includes/Admin/UserProfile.php:291 +#: includes/Admin/UserProfile.php:299 msgid "Bank Swift " msgstr "" -#: includes/Admin/UserProfile.php:303 +#: includes/Admin/UserProfile.php:311 msgid "Enable Adding Products" msgstr "" -#: includes/Admin/UserProfile.php:306 +#: includes/Admin/UserProfile.php:314 msgid "Enable or disable product adding capability" msgstr "" -#: includes/Admin/UserProfile.php:311 +#: includes/Admin/UserProfile.php:319 msgid "Publishing" msgstr "" -#: includes/Admin/UserProfile.php:316 +#: includes/Admin/UserProfile.php:324 msgid "Publish product directly" msgstr "" -#: includes/Admin/UserProfile.php:319 +#: includes/Admin/UserProfile.php:327 msgid "Bypass pending, publish products directly" msgstr "" -#: includes/Admin/UserProfile.php:324 +#: includes/Admin/UserProfile.php:332 msgid "Featured vendor" msgstr "" -#: includes/Admin/UserProfile.php:329 +#: includes/Admin/UserProfile.php:337 msgid "Mark as featured vendor" msgstr "" -#: includes/Admin/UserProfile.php:332 +#: includes/Admin/UserProfile.php:340 msgid "This vendor will be marked as a featured vendor." msgstr "" @@ -1815,7 +1815,7 @@ msgid "reCAPTCHA verification failed!" msgstr "" #: includes/Ajax.php:359 -#: includes/REST/StoreController.php:838 +#: includes/REST/StoreController.php:839 msgid "Email sent successfully!" msgstr "" @@ -3950,19 +3950,19 @@ msgstr "" msgid "(no name)" msgstr "" -#: includes/Order/Admin/Hooks.php:532 +#: includes/Order/Admin/Hooks.php:536 msgid "Toggle Sub-orders" msgstr "" -#: includes/Order/Admin/Hooks.php:558 +#: includes/Order/Admin/Hooks.php:562 msgid "Commissions" msgstr "" -#: includes/Order/Admin/Hooks.php:568 +#: includes/Order/Admin/Hooks.php:572 msgid "Sub orders" msgstr "" -#: includes/Order/Admin/Hooks.php:568 +#: includes/Order/Admin/Hooks.php:572 msgid "Related orders" msgstr "" @@ -5422,11 +5422,11 @@ msgstr "" #: includes/REST/ProductController.php:91 #: includes/REST/ProductController.php:136 #: includes/REST/StoreController.php:63 -#: includes/REST/StoreController.php:98 -#: includes/REST/StoreController.php:115 -#: includes/REST/StoreController.php:142 -#: includes/REST/StoreController.php:176 -#: includes/REST/StoreController.php:208 +#: includes/REST/StoreController.php:99 +#: includes/REST/StoreController.php:116 +#: includes/REST/StoreController.php:143 +#: includes/REST/StoreController.php:177 +#: includes/REST/StoreController.php:209 #: includes/REST/WithdrawController.php:90 #: includes/REST/WithdrawController.php:947 msgid "Unique identifier for the object." @@ -6215,75 +6215,163 @@ msgstr "" msgid "Reassign the deleted user's posts and links to this user ID." msgstr "" -#: includes/REST/StoreController.php:152 +#: includes/REST/StoreController.php:153 #: templates/widgets/store-contact-form.php:15 #: assets/js/vue-admin.js:2 msgid "Your Name" msgstr "" -#: includes/REST/StoreController.php:158 +#: includes/REST/StoreController.php:159 msgid "Your email" msgstr "" -#: includes/REST/StoreController.php:163 +#: includes/REST/StoreController.php:164 msgid "Your Message" msgstr "" -#: includes/REST/StoreController.php:181 +#: includes/REST/StoreController.php:182 msgid "Status for the store object." msgstr "" -#: includes/REST/StoreController.php:212 +#: includes/REST/StoreController.php:213 msgid "Get Best Selling Products Category." msgstr "" -#: includes/REST/StoreController.php:339 +#: includes/REST/StoreController.php:340 msgid "Invalid user ID for reassignment." msgstr "" -#: includes/REST/StoreController.php:538 -#: includes/REST/StoreController.php:941 +#: includes/REST/StoreController.php:539 +#: includes/REST/StoreController.php:942 msgid "No store found" msgstr "" -#: includes/REST/StoreController.php:556 -#: includes/REST/StoreController.php:575 +#: includes/REST/StoreController.php:557 +#: includes/REST/StoreController.php:576 msgid "No reviews found" msgstr "" -#: includes/REST/StoreController.php:767 +#: includes/REST/StoreController.php:768 msgid "This email address is not valid" msgstr "" -#: includes/REST/StoreController.php:810 +#: includes/REST/StoreController.php:811 msgid "No vendor is found to be send an email." msgstr "" -#: includes/REST/StoreController.php:857 +#: includes/REST/StoreController.php:858 msgid "Status parameter must be active or inactive" msgstr "" -#: includes/REST/StoreController.php:863 +#: includes/REST/StoreController.php:864 msgid "No vendor found for updating status" msgstr "" -#: includes/REST/StoreController.php:891 +#: includes/REST/StoreController.php:892 msgid "No items found for bulk updating" msgstr "" -#: includes/REST/StoreController.php:975 +#: includes/REST/StoreController.php:976 msgid "Status of the store" msgstr "" -#: includes/REST/StoreController.php:982 +#: includes/REST/StoreController.php:983 msgid "Store List Order By" msgstr "" -#: includes/REST/StoreController.php:988 -#: includes/REST/StoreController.php:994 +#: includes/REST/StoreController.php:989 +#: includes/REST/StoreController.php:995 msgid "Store List Order" msgstr "" +#: includes/REST/StoreController.php:1015 +msgid "Unique identifier for the vendor." +msgstr "" + +#: includes/REST/StoreController.php:1021 +msgid "Store owner first name." +msgstr "" + +#: includes/REST/StoreController.php:1026 +msgid "Store owner last name." +msgstr "" + +#: includes/REST/StoreController.php:1031 +msgid "User nice name." +msgstr "" + +#: includes/REST/StoreController.php:1036 +msgid "User password." +msgstr "" + +#: includes/REST/StoreController.php:1040 +msgid "Store email address." +msgstr "" + +#: includes/REST/StoreController.php:1046 +msgid "Store name." +msgstr "" + +#: includes/REST/StoreController.php:1051 +msgid "Store phone number." +msgstr "" + +#: includes/REST/StoreController.php:1056 +msgid "Show email in store." +msgstr "" + +#: includes/REST/StoreController.php:1061 +msgid "Gravatar ID." +msgstr "" + +#: includes/REST/StoreController.php:1065 +msgid "Banner ID." +msgstr "" + +#: includes/REST/StoreController.php:1069 +msgid "Enable terms and conditions." +msgstr "" + +#: includes/REST/StoreController.php:1073 +msgid "Store terms and conditions." +msgstr "" + +#: includes/REST/StoreController.php:1077 +msgid "Store icon." +msgstr "" + +#: includes/REST/StoreController.php:1081 +msgid "Social profiles." +msgstr "" + +#: includes/REST/StoreController.php:1093 +msgid "Store address." +msgstr "" + +#: includes/REST/StoreController.php:1106 +msgid "Enable selling." +msgstr "" + +#: includes/REST/StoreController.php:1110 +msgid "Featured vendor." +msgstr "" + +#: includes/REST/StoreController.php:1114 +msgid "Trusted vendor." +msgstr "" + +#: includes/REST/StoreController.php:1118 +msgid "Admin commission amount." +msgstr "" + +#: includes/REST/StoreController.php:1122 +msgid "Admin additional fee." +msgstr "" + +#: includes/REST/StoreController.php:1126 +msgid "Category wise commission." +msgstr "" + #: includes/REST/StoreSettingController.php:110 #: includes/REST/WithdrawController.php:327 #: includes/REST/WithdrawController.php:455 diff --git a/package-lock.json b/package-lock.json index 9dfaa4fcdd..8c710d9816 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "dokan", - "version": "3.14.9", + "version": "3.14.10", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "dokan", - "version": "3.14.9", + "version": "3.14.10", "license": "GPL", "dependencies": { "@wordpress/i18n": "^5.8.0" diff --git a/package.json b/package.json index bdeab86c32..fad2d75222 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dokan", - "version": "3.14.9", + "version": "3.14.10", "description": "A WordPress marketplace plugin", "author": "Dokan Inc.", "license": "GPL", diff --git a/readme.txt b/readme.txt index 65237b023a..e346b48643 100644 --- a/readme.txt +++ b/readme.txt @@ -3,11 +3,11 @@ Contributors: tareq1988, dokaninc, wedevs, nizamuddinbabu Donate Link: https://dokan.co/wordpress/pricing/ Tags: WooCommerce multivendor marketplace, multi seller, multi vendor, multivendor, multivendor marketplace Requires at least: 6.5 -Tested up to: 6.7.1 +Tested up to: 6.7.2 WC requires at least: 8.5.0 -WC tested up to: 9.6.1 +WC tested up to: 9.7.0 Requires PHP: 7.4 -Stable tag: 3.14.9 +Stable tag: 3.14.10 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -344,6 +344,12 @@ A. Just install and activate the PRO version without deleting the free plugin. A == Changelog == += v3.14.10 ( Feb 28, 2025 ) = + +- **fix:** Prevented wrong store URL generation for staff managers on admin dashboard. +- **fix:** Restoring parent order with restore related child orders. +- **fix:** Store settings API data storing inconsistencies. + = v3.14.9 ( Feb 12, 2025 ) = - **fix:** Fix earning suggestion in vendor dashboard when product edit page loads initially. @@ -371,10 +377,6 @@ A. Just install and activate the PRO version without deleting the free plugin. A - **update:** Improvement withdraw approved email template. - **update:** Dokan admin settings page responsive & update ui design. -= v3.14.4 ( Dec 27, 2024 ) = - -- **fix:** Added tweaks to improve system stability and smoothness. - [CHECK THE FULL CHANGELOG](https://github.com/getdokan/dokan/blob/develop/CHANGELOG.md). == Upgrade Notice == diff --git a/src/admin/components/Currency.vue b/src/admin/components/Currency.vue index 9ec4fc48fe..5a95954e6b 100644 --- a/src/admin/components/Currency.vue +++ b/src/admin/components/Currency.vue @@ -8,7 +8,7 @@ export default { methods: { formattedPrice(value) { - return accounting.formatMoney( value, {...dokan.currency, precision: dokan.currency.precision+ 2} ); + return accounting.formatMoney( value, {...dokan.currency, precision: dokan.currency.precision} ); } } }; diff --git a/templates/emails/plain/vendor-completed-order.php b/templates/emails/plain/vendor-completed-order.php index 38fec16d0c..5867ab614a 100644 --- a/templates/emails/plain/vendor-completed-order.php +++ b/templates/emails/plain/vendor-completed-order.php @@ -5,7 +5,7 @@ * An email sent to the vendor when a order is completed. * * @class VendorCompletedOrder - * @version DOKAN_LITE_SINCE + * @version 3.2.2 */ if ( ! defined( 'ABSPATH' ) ) { diff --git a/templates/emails/vendor-completed-order.php b/templates/emails/vendor-completed-order.php index b67fd3a40c..3e80b03af3 100644 --- a/templates/emails/vendor-completed-order.php +++ b/templates/emails/vendor-completed-order.php @@ -5,7 +5,7 @@ * An email sent to the vendor when a order is completed. * * @class VendorCompletedOrder - * @version DOKAN_LITE_SINCE + * @version 3.2.2 */ if ( ! defined( 'ABSPATH' ) ) { diff --git a/templates/emails/withdraw-approve.php b/templates/emails/withdraw-approve.php index ea5ba72743..da5a655967 100644 --- a/templates/emails/withdraw-approve.php +++ b/templates/emails/withdraw-approve.php @@ -29,6 +29,11 @@
+
+ diff --git a/templates/emails/withdraw-cancel.php b/templates/emails/withdraw-cancel.php index 546fa1e57e..46442b4382 100644 --- a/templates/emails/withdraw-cancel.php +++ b/templates/emails/withdraw-cancel.php @@ -31,6 +31,11 @@ ?>
+
+ diff --git a/templates/emails/withdraw-new.php b/templates/emails/withdraw-new.php index 62025480d4..a64ec1bc49 100644 --- a/templates/emails/withdraw-new.php +++ b/templates/emails/withdraw-new.php @@ -35,6 +35,12 @@ +
  • + + + + +
  • diff --git a/templates/orders/commission-meta-box-html.php b/templates/orders/commission-meta-box-html.php index b495a2cba8..c859493849 100644 --- a/templates/orders/commission-meta-box-html.php +++ b/templates/orders/commission-meta-box-html.php @@ -172,7 +172,7 @@ echo wc_price( $original_commission, array( 'currency' => $order->get_currency(), - 'decimals' => wc_get_price_decimals() + 2, + 'decimals' => wc_get_price_decimals(), ) ); ?> @@ -186,7 +186,7 @@ echo wc_price( $commission_refunded, array( 'currency' => $order->get_currency(), - 'decimals' => wc_get_price_decimals() + 2, + 'decimals' => wc_get_price_decimals(), ) ); ?> @@ -212,7 +212,7 @@ echo wc_price( $order_total, array( 'currency' => $order->get_currency(), - 'decimals' => wc_get_price_decimals() + 2, + 'decimals' => wc_get_price_decimals(), ) ); ?> @@ -226,7 +226,7 @@ echo wc_price( $net_amount, array( 'currency' => $order->get_currency(), - 'decimals' => wc_get_price_decimals() + 2, + 'decimals' => wc_get_price_decimals(), ) ); ?> @@ -241,7 +241,7 @@ echo wc_price( $shipping_fee, array( 'currency' => $order->get_currency(), - 'decimals' => wc_get_price_decimals() + 2, + 'decimals' => wc_get_price_decimals(), ) ); ?> @@ -253,7 +253,7 @@ echo wc_price( $shipping_fee_refunded, array( 'currency' => $order->get_currency(), - 'decimals' => wc_get_price_decimals() + 2, + 'decimals' => wc_get_price_decimals(), ) ); ?> @@ -273,7 +273,7 @@ echo wc_price( $product_tax_fee, array( 'currency' => $order->get_currency(), - 'decimals' => wc_get_price_decimals() + 2, + 'decimals' => wc_get_price_decimals(), ) ); ?> @@ -285,7 +285,7 @@ echo wc_price( $product_tax_fee_refunded, array( 'currency' => $order->get_currency(), - 'decimals' => wc_get_price_decimals() + 2, + 'decimals' => wc_get_price_decimals(), ) ); ?> @@ -305,7 +305,7 @@ echo wc_price( $shipping_tax_fee, array( 'currency' => $order->get_currency(), - 'decimals' => wc_get_price_decimals() + 2, + 'decimals' => wc_get_price_decimals(), ) ); ?> @@ -317,7 +317,7 @@ echo wc_price( $shipping_tax_fee_refunded, array( 'currency' => $order->get_currency(), - 'decimals' => wc_get_price_decimals() + 2, + 'decimals' => wc_get_price_decimals(), ) ); ?> @@ -344,7 +344,7 @@ echo wc_price( $total_commission, array( 'currency' => $order->get_currency(), - 'decimals' => wc_get_price_decimals() + 2, + 'decimals' => wc_get_price_decimals(), ) ); ?> diff --git a/templates/orders/listing.php b/templates/orders/listing.php index a22c206a6d..41a4387d5f 100755 --- a/templates/orders/listing.php +++ b/templates/orders/listing.php @@ -84,7 +84,7 @@ dokan()->commission->get_earning_by_order( $order ), [ 'currency' => $order->get_currency(), - 'decimals' => wc_get_price_decimals() + 2, + 'decimals' => wc_get_price_decimals(), ] ) ); diff --git a/templates/orders/order-download-permission-html.php b/templates/orders/order-download-permission-html.php index 6d563b4a90..6c67ce6238 100755 --- a/templates/orders/order-download-permission-html.php +++ b/templates/orders/order-download-permission-html.php @@ -31,7 +31,7 @@ class="title" rel="product_id ) ) . ',' . esc_attr( $download->download_id ); ?>" class="revoke_access btn btn-danger btn-sm pull-right" data-order-id="order_id ); ?>" - data-permission-id="permission_id ); ?>" + data-permission-id="get_id() ); ?>" data-nonce="" > diff --git a/templates/products/edit-product-single.php b/templates/products/edit-product-single.php index c807bd50f9..e197d4ff2d 100755 --- a/templates/products/edit-product-single.php +++ b/templates/products/edit-product-single.php @@ -165,7 +165,7 @@ /** * Render the contents before product edit status label. * - * @since DOKAN_PRO_SINCE + * @since 3.13.1 * * @param \WC_Product $product */ @@ -180,7 +180,7 @@ /** * Render the contents after product edit status label. * - * @since DOKAN_PRO_SINCE + * @since 3.13.1 * * @param \WC_Product $product */ @@ -312,7 +312,7 @@ class="vendor-earning simple-product" wc_price( dokan()->commission->get_earning_by_product( $post_id ), [ - 'decimals' => wc_get_price_decimals() + 2, + 'decimals' => wc_get_price_decimals(), ] ) ); @@ -329,7 +329,7 @@ class="vendor-earning simple-product" '_regular_price', [ 'class' => 'dokan-product-regular-price', - 'placeholder' => __( '0.00', 'dokan-lite' ), + 'placeholder' => sprintf( '%.0' . get_option( 'woocommerce_price_num_decimals' ) . 'f', 0 ), ], 'price' ); @@ -352,7 +352,7 @@ class="vendor-earning simple-product" '_sale_price', [ 'class' => 'dokan-product-sales-price', - 'placeholder' => __( '0.00', 'dokan-lite' ), + 'placeholder' => sprintf( '%.0' . get_option( 'woocommerce_price_num_decimals' ) . 'f', 0 ), ], 'price' ); diff --git a/templates/products/products-listing-row.php b/templates/products/products-listing-row.php index 7295a33897..cf311c0a01 100644 --- a/templates/products/products-listing-row.php +++ b/templates/products/products-listing-row.php @@ -256,7 +256,7 @@ /** * Render product listing product type symbol. * - * @since DOKAN_PRO_SINCE + * @since 3.13.1 * * @param string $product_type * @param WC_Product $product diff --git a/templates/settings/payment-manage.php b/templates/settings/payment-manage.php index 36d9c4490b..56d8e93460 100644 --- a/templates/settings/payment-manage.php +++ b/templates/settings/payment-manage.php @@ -37,7 +37,7 @@ 'Version 3.14.10', + 'released' => '2025-02-28', + 'changes' => [ + 'Fix' => [ + [ + 'title' => 'Prevented wrong store URL generation for staff managers on admin dashboard.', + 'description' => '', + ], + [ + 'title' => 'Restoring parent order with restore related child orders.', + 'description' => '', + ], + [ + 'title' => 'Store settings API data storing inconsistencies.', + 'description' => '', + ], + ], + ], + ], [ 'version' => 'Version 3.14.9', 'released' => '2025-02-12', diff --git a/tests/php/src/Orders/OrderRestoreFromTrashTest.php b/tests/php/src/Orders/OrderRestoreFromTrashTest.php new file mode 100644 index 0000000000..3e6d61dc26 --- /dev/null +++ b/tests/php/src/Orders/OrderRestoreFromTrashTest.php @@ -0,0 +1,46 @@ +create_multi_vendor_order(); + + $child_orders = dokan()->order->get_child_orders( $parent_order_id ); + $this->assertCount( 2, $child_orders ); + + // Move to trash + wp_trash_post( $parent_order_id ); + $this->assertEquals( 'trash', get_post_status( $parent_order_id ) ); + + foreach ( $child_orders as $child_order ) { + wp_trash_post( $child_order->get_id() ); + $this->assertEquals( 'trash', get_post_status( $child_order->get_id() ) ); + } + + $child_orders = dokan()->order->get_child_orders( $parent_order_id ); + $this->assertCount( 0, $child_orders ); + + // Restore order + wp_untrash_post( $parent_order_id ); + // Assert order status is not trash anymore + $this->assertNotEquals( 'trash', get_post_status( $parent_order_id ) ); + + // get from trash + $child_orders = dokan()->order->get_child_orders( + $parent_order_id, [ + 'status' => [ 'trash' ], + ] + ); + $this->assertCount( 2, $child_orders ); + + foreach ( $child_orders as $child_order ) { + wp_untrash_post( $child_order->get_id() ); + $this->assertNotEquals( 'trash', get_post_status( $child_order->get_id() ) ); + } + } +} diff --git a/tests/pw/e2e.config.ts b/tests/pw/e2e.config.ts index b3987e4f6b..e20d4f4790 100644 --- a/tests/pw/e2e.config.ts +++ b/tests/pw/e2e.config.ts @@ -29,7 +29,7 @@ export default defineConfig({ toHaveScreenshot: { maxDiffPixelRatio: 0.2, maxDiffPixels: 500, - threshold: 0.5, + threshold: 0.2, }, }, /* Whether to preserve test output in the testConfig.outputDir. Defaults to 'always'. */ @@ -63,6 +63,7 @@ export default defineConfig({ ], use: { + ...devices['Desktop Chrome'], /* Whether to automatically download all the attachments. */ acceptDownloads: true, @@ -105,7 +106,9 @@ export default defineConfig({ launchOptions: { slowMo: (SLOWMO ?? 0) * 1000, // devtools: true, + }, + // viewport: { width: 1280, height: 1922 }, }, projects: [ diff --git a/tests/pw/feature-map/feature-map.yml b/tests/pw/feature-map/feature-map.yml index 7b307b1c65..7832adf06d 100644 --- a/tests/pw/feature-map/feature-map.yml +++ b/tests/pw/feature-map/feature-map.yml @@ -940,7 +940,9 @@ vendor can view inbox menu page: true vendor can reply to customer message: true customer: + customer can view inbox menu page: false customer can send message to vendor: true + customer can reply to customer message: false - page: 'Live Search' features: diff --git a/tests/pw/package.json b/tests/pw/package.json index b12e608e1f..80536e6111 100644 --- a/tests/pw/package.json +++ b/tests/pw/package.json @@ -24,10 +24,12 @@ "test:e2e:coverage": "npx playwright test --project=coverage_report --config=e2e.config.ts --reporter=null", "test:e2e:headed": "npx playwright test --project=e2e_tests --config=e2e.config.ts --headed", "test:e2e:ui": "npx playwright test --project=e2e_tests --config=e2e.config.ts --ui", - "test:e2e:debug": "npx playwright test --project=e2e_tests --config=e2e.config.ts --debug", + "test:e2e:debug": "npx playwright test --project=visual_tests --config=visual.config.ts --debug", + "test:visual": "DOKAN_PRO=true npx playwright test --project=visual_tests --config=visual.config.ts", "test:codegen": "playwright codegen", "test:report": "npx playwright show-report", "test:trace": "npx playwright show-trace trace.zip", + "update:screenshot": "npx playwright test --project=e2e_tests --config=e2e.config.ts --update-snapshots", "merge:report": "npx playwright merge-reports --reporter html", "allure:generate": "allure generate playwright-report/allure-report -o allure-report --clean", "allure:open": "allure open allure-report", diff --git a/tests/pw/pages/selectors.ts b/tests/pw/pages/selectors.ts index a9b0d8318a..288d8c3b12 100644 --- a/tests/pw/pages/selectors.ts +++ b/tests/pw/pages/selectors.ts @@ -7194,8 +7194,7 @@ export const selector = { satellite: '//button[normalize-space()="Satellite"]', fullScreenToggle: '//button[@title="Toggle fullscreen view"]', pegman: '//button[@title="Drag Pegman onto the map to open Street View"]', - zoomIn: '//button[@title="Zoom in"]', - zoomOut: '//button[@title="Zoom out"]', + mapCameraControls: '//button[@title="Map camera controls"]', productOnMap: { productPin: '//div[@id="dokan-geolocation-locations-map"]//img[contains(@src, "maps.gstatic.com/mapfiles/transparent.png")]/../..//div[@role="button"]', productCluster: '//div[@id="dokan-geolocation-locations-map"]//div[contains(@style, "dokan-pro/modules/geolocation/assets/images")]', diff --git a/tests/pw/pages/vendorAuctionsPage.ts b/tests/pw/pages/vendorAuctionsPage.ts index e2c56be1b6..b9091ab1eb 100644 --- a/tests/pw/pages/vendorAuctionsPage.ts +++ b/tests/pw/pages/vendorAuctionsPage.ts @@ -91,8 +91,8 @@ export class AuctionsPage extends VendorPage { async vendorAuctionRenderProperly() { await this.goIfNotThere(data.subUrls.frontend.vDashboard.auction); - // auctions menu elements are visible - await this.multipleElementVisible(auctionProductsVendor.menus); + // auctions all menu is visible + await this.toBeVisible(auctionProductsVendor.menus.all); // add new auction product button is visible await this.toBeVisible(auctionProductsVendor.addNewActionProduct); diff --git a/tests/pw/pages/visualPage.ts b/tests/pw/pages/visualPage.ts index e8a5496bd4..f052b64ef7 100644 --- a/tests/pw/pages/visualPage.ts +++ b/tests/pw/pages/visualPage.ts @@ -95,4 +95,11 @@ export class VisualPage extends AdminPage { await this.wait(1.5); await this.toHaveScreenshot(this.page, [notice]); } + + // dokan vendor dashboard menu + async vendorDashboardMenu(locator: string) { + await this.goIfNotThere(locator, 'networkidle'); + // await this.wait(1); + await this.toHaveScreenshot(this.page); + } } diff --git a/tests/pw/tests/api/_auth.setup.ts b/tests/pw/tests/api/_auth.setup.ts index 9794777436..e20a2c19d8 100644 --- a/tests/pw/tests/api/_auth.setup.ts +++ b/tests/pw/tests/api/_auth.setup.ts @@ -43,7 +43,7 @@ setup.describe('add users', () => { await apiUtils.createStoreReview(sellerId, { ...payloads.createStoreReview, rating: 5 }, payloads.adminAuth); } // add map location - await dbUtils.addStoreBiographyAndMapLocation(sellerId); + await dbUtils.addStoreMapLocation(sellerId); helpers.createEnvVar('VENDOR_ID', sellerId); }); @@ -62,7 +62,7 @@ setup.describe('add users', () => { await apiUtils.createStoreReview(sellerId, { ...payloads.createStoreReview, rating: 5 }, payloads.adminAuth); } // add map location - await dbUtils.addStoreBiographyAndMapLocation(sellerId); + await dbUtils.addStoreMapLocation(sellerId); helpers.createEnvVar('VENDOR2_ID', sellerId); }); diff --git a/tests/pw/tests/e2e/_auth.setup.ts b/tests/pw/tests/e2e/_auth.setup.ts index 4ade63d556..7acab59fbf 100644 --- a/tests/pw/tests/e2e/_auth.setup.ts +++ b/tests/pw/tests/e2e/_auth.setup.ts @@ -45,7 +45,7 @@ setup.describe('add & authenticate users', () => { await apiUtils.createStoreReview(sellerId, { ...payloads.createStoreReview, rating: 5 }, payloads.adminAuth); } // add map location - await dbUtils.addStoreBiographyAndMapLocation(sellerId); + await dbUtils.addStoreMapLocation(sellerId); helpers.createEnvVar('VENDOR_ID', sellerId); }); @@ -64,7 +64,7 @@ setup.describe('add & authenticate users', () => { await apiUtils.createStoreReview(sellerId, { ...payloads.createStoreReview, rating: 5 }, payloads.adminAuth); } // add map location - await dbUtils.addStoreBiographyAndMapLocation(sellerId); + await dbUtils.addStoreMapLocation(sellerId); helpers.createEnvVar('VENDOR2_ID', sellerId); }); diff --git a/tests/pw/tests/e2e/visual.spec.ts b/tests/pw/tests/e2e/visual.spec.ts deleted file mode 100644 index 5290527b81..0000000000 --- a/tests/pw/tests/e2e/visual.spec.ts +++ /dev/null @@ -1,248 +0,0 @@ -import { test, Page } from '@playwright/test'; -import { VisualPage } from '@pages/visualPage'; -import { data } from '@utils/testData'; -import { selector } from '@pages/selectors'; - -test.describe('dokan visual test', () => { - test.skip(true, 'skip visual tests'); - let admin: VisualPage; - let aPage: Page; - - test.beforeAll(async ({ browser }) => { - const adminContext = await browser.newContext(data.auth.adminAuth); - aPage = await adminContext.newPage(); - admin = new VisualPage(aPage); - }); - - test.afterAll(async () => { - await aPage.close(); - }); - - test('dokan admin dashboard @visual', async () => { - await admin.dokanMenu(data.subUrls.backend.dokan.dokan); - }); - - test('admin withdraw menu @visual', async () => { - await admin.dokanMenu(data.subUrls.backend.dokan.withdraw); - }); - - test('admin reverse withdraw menu @visual', async () => { - await admin.dokanMenu(data.subUrls.backend.dokan.reverseWithdraws); - }); - - test('admin add reverse withdrawal @visual', async () => { - await admin.addReverseWithdrawal(); - }); - - test('admin vendors menu @visual', async () => { - await admin.dokanMenu(data.subUrls.backend.dokan.vendors); - }); - - test('admin can add vendor @visual', async () => { - await admin.addVendor(); - }); - - test('admin store category @visual', async () => { - await admin.adminStoreCategoryRenderProperly(); - }); - - test('dokan store reviews menu @visual', async () => { - await admin.dokanMenu(data.subUrls.backend.dokan.storeReviews); - }); - - test('dokan store support menu @visual', async () => { - await admin.dokanMenu(data.subUrls.backend.dokan.storeSupport); - }); - - test('dokan seller badge menu @visual', async () => { - await admin.dokanMenu(data.subUrls.backend.dokan.sellerBadge); - }); - - test('admin can create seller badge @visual', async () => { - await admin.createSellerBadge(); - }); - - test('admin quotes menu @visual', async () => { - await admin.dokanMenu(data.subUrls.backend.dokan.requestForQuote); - }); - - test('admin can add quote @visual', async () => { - await admin.addQuote(); - }); - - test('admin quote rules menu @visual', async () => { - await admin.dokanMenu(data.subUrls.backend.dokan.requestForQuoteRules); - }); - - test('admin can add quote rule @visual', async () => { - await admin.addQuoteRule(); - }); - - test('dokan abuse report menu @visual', async () => { - await admin.dokanMenu(data.subUrls.backend.dokan.abuseReports); - }); - - test('dokan announcements menu @visual', async () => { - await admin.dokanMenu(data.subUrls.backend.dokan.announcements); - }); - - test('admin can add announcement @visual', async () => { - await admin.addAnnouncement(); - }); - - test('admin refunds menu @visual', async () => { - await admin.dokanMenu(data.subUrls.backend.dokan.refunds); - }); - - test('admin reports menu @visual', async () => { - await admin.dokanMenu(data.subUrls.backend.dokan.reports); - }); - - test('admin All Logs menu @visual', async () => { - await admin.dokanMenu(data.subUrls.backend.dokan.allLogs); - }); - - test('dokan modules menu @visual', async () => { - await admin.dokanMenu(data.subUrls.backend.dokan.modules); - }); - - test('dokan modules plan @visual', async () => { - await admin.adminModulesPlanRenderProperly(); - }); - - test('dokan tools menu @visual', async () => { - await admin.dokanMenu(data.subUrls.backend.dokan.tools); - }); - - test('admin verifications menu @visual', async () => { - await admin.dokanMenu(data.subUrls.backend.dokan.verifications); - }); - - test('dokan product advertising menu @visual', async () => { - await admin.dokanMenu(data.subUrls.backend.dokan.productAdvertising); - }); - - test('admin can add product advertisement @visual', async () => { - await admin.addNewProductAdvertisement(); - }); - - test('dokan wholesale customers menu @visual', async () => { - await admin.dokanMenu(data.subUrls.backend.dokan.wholeSaleCustomer); - }); - - test('dokan help menu @visual', async () => { - await admin.dokanMenu(data.subUrls.backend.dokan.help); - }); - - test('dokan settings general menu @visual', async () => { - await admin.dokanSettingsMenu(selector.admin.dokan.settings.menus.general); - }); - - test('dokan settings selling menu @visual', async () => { - await admin.dokanSettingsMenu(selector.admin.dokan.settings.menus.sellingOptions); - }); - - test('dokan settings withdraw menu @visual', async () => { - await admin.dokanSettingsMenu(selector.admin.dokan.settings.menus.withdrawOptions); - }); - - test('dokan settings reverseWithdraw menu @visual', async () => { - await admin.dokanSettingsMenu(selector.admin.dokan.settings.menus.reverseWithdrawal); - }); - - test('dokan settings page menu @visual', async () => { - await admin.dokanSettingsMenu(selector.admin.dokan.settings.menus.pageSettings); - }); - - test('dokan settings appearance menu @visual', async () => { - await admin.dokanSettingsMenu(selector.admin.dokan.settings.menus.appearance); - }); - - test('dokan settings privacyPolicy menu @visual', async () => { - await admin.dokanSettingsMenu(selector.admin.dokan.settings.menus.privacyPolicy); - }); - - test('dokan settings colors menu @visual', async () => { - await admin.dokanSettingsMenu(selector.admin.dokan.settings.menus.colors); - }); - - test('dokan settings liveSearch menu @visual', async () => { - await admin.dokanSettingsMenu(selector.admin.dokan.settings.menus.liveSearch); - }); - - test('dokan settings storeSupport menu @visual', async () => { - await admin.dokanSettingsMenu(selector.admin.dokan.settings.menus.storeSupport); - }); - - test('dokan settings sellerVerification menu @visual', async () => { - await admin.dokanSettingsMenu(selector.admin.dokan.settings.menus.vendorVerification); - }); - - test('dokan settings verificationSmsGateways menu @visual', async () => { - await admin.dokanSettingsMenu(selector.admin.dokan.settings.menus.verificationSmsGateways); - }); - - test('dokan settings emailVerification menu @visual', async () => { - await admin.dokanSettingsMenu(selector.admin.dokan.settings.menus.emailVerification); - }); - - test('dokan settings socialApi menu @visual', async () => { - await admin.dokanSettingsMenu(selector.admin.dokan.settings.menus.socialApi); - }); - - test('dokan settings shippingStatus menu @visual', async () => { - await admin.dokanSettingsMenu(selector.admin.dokan.settings.menus.shippingStatus); - }); - - test('dokan settings quote menu @visual', async () => { - await admin.dokanSettingsMenu(selector.admin.dokan.settings.menus.quote); - }); - - test('dokan settings liveChat menu @visual', async () => { - await admin.dokanSettingsMenu(selector.admin.dokan.settings.menus.liveChat); - }); - - test('dokan settings rma menu @visual', async () => { - await admin.dokanSettingsMenu(selector.admin.dokan.settings.menus.rma); - }); - - test('dokan settings wholesale menu @visual', async () => { - await admin.dokanSettingsMenu(selector.admin.dokan.settings.menus.wholesale); - }); - - test('dokan settings euComplianceFields menu @visual', async () => { - await admin.dokanSettingsMenu(selector.admin.dokan.settings.menus.euComplianceFields); - }); - - test('dokan settings deliveryTime menu @visual', async () => { - await admin.dokanSettingsMenu(selector.admin.dokan.settings.menus.deliveryTime); - }); - - test('dokan settings productAdvertising menu @visual', async () => { - await admin.dokanSettingsMenu(selector.admin.dokan.settings.menus.productAdvertising); - }); - - test('dokan settings geolocation menu @visual', async () => { - await admin.dokanSettingsMenu(selector.admin.dokan.settings.menus.geolocation); - }); - - test('dokan settings productReportAbuse menu @visual', async () => { - await admin.dokanSettingsMenu(selector.admin.dokan.settings.menus.productReportAbuse); - }); - - test('dokan settings singleProductMultiVendor menu @visual', async () => { - await admin.dokanSettingsMenu(selector.admin.dokan.settings.menus.singleProductMultiVendor); - }); - - test('dokan settings vendorSubscription menu @visual', async () => { - await admin.dokanSettingsMenu(selector.admin.dokan.settings.menus.vendorSubscription); - }); - - test('dokan settings vendorAnalytics menu @visual', async () => { - await admin.dokanSettingsMenu(selector.admin.dokan.settings.menus.vendorAnalytics); - }); - - test('dokan license menu @visual', async () => { - await admin.dokanMenu(data.subUrls.backend.dokan.license); - }); -}); diff --git a/tests/pw/tests/visual/visual.spec.ts b/tests/pw/tests/visual/visual.spec.ts new file mode 100644 index 0000000000..1b7eeaa76e --- /dev/null +++ b/tests/pw/tests/visual/visual.spec.ts @@ -0,0 +1,396 @@ +import { test, Page } from '@playwright/test'; +import { VisualPage } from '@pages/visualPage'; +import { data } from '@utils/testData'; +import { selector } from '@pages/selectors'; + +test.describe('dokan visual test', () => { + test.skip(true, 'skip visual tests'); + let admin: VisualPage; + let aPage: Page; + + test.beforeAll(async ({ browser }) => { + const adminContext = await browser.newContext(data.auth.adminAuth); + aPage = await adminContext.newPage(); + admin = new VisualPage(aPage); + }); + + test.afterAll(async () => { + await aPage.close(); + }); + + test('dokan admin dashboard', { tag: ['@lite', '@visual'] }, async () => { + await admin.dokanMenu(data.subUrls.backend.dokan.dokan); + }); + + test('admin withdraw menu', { tag: ['@lite', '@visual'] }, async () => { + await admin.dokanMenu(data.subUrls.backend.dokan.withdraw); + }); + + test('admin reverse withdraw menu', { tag: ['@lite', '@visual'] }, async () => { + await admin.dokanMenu(data.subUrls.backend.dokan.reverseWithdraws); + }); + + test('admin add reverse withdrawal', { tag: ['@lite', '@visual'] }, async () => { + await admin.addReverseWithdrawal(); + }); + + test('admin vendors menu', { tag: ['@lite', '@visual'] }, async () => { + await admin.dokanMenu(data.subUrls.backend.dokan.vendors); + }); + + test('admin can add vendor', { tag: ['@lite', '@visual'] }, async () => { + await admin.addVendor(); + }); + + test('admin store category', { tag: ['@pro', '@visual'] }, async () => { + await admin.adminStoreCategoryRenderProperly(); + }); + + test('dokan store reviews menu', { tag: ['@pro', '@visual'] }, async () => { + await admin.dokanMenu(data.subUrls.backend.dokan.storeReviews); + }); + + test('dokan store support menu', { tag: ['@pro', '@visual'] }, async () => { + await admin.dokanMenu(data.subUrls.backend.dokan.storeSupport); + }); + + test('dokan seller badge menu', { tag: ['@pro', '@visual'] }, async () => { + await admin.dokanMenu(data.subUrls.backend.dokan.sellerBadge); + }); + + test('admin can create seller badge', { tag: ['@pro', '@visual'] }, async () => { + await admin.createSellerBadge(); + }); + + test('admin quotes menu', { tag: ['@pro', '@visual'] }, async () => { + await admin.dokanMenu(data.subUrls.backend.dokan.requestForQuote); + }); + + test('admin can add quote', { tag: ['@pro', '@visual'] }, async () => { + await admin.addQuote(); + }); + + test('admin quote rules menu', { tag: ['@pro', '@visual'] }, async () => { + await admin.dokanMenu(data.subUrls.backend.dokan.requestForQuoteRules); + }); + + test('admin can add quote rule', { tag: ['@pro', '@visual'] }, async () => { + await admin.addQuoteRule(); + }); + + test('dokan abuse report menu', { tag: ['@pro', '@visual'] }, async () => { + await admin.dokanMenu(data.subUrls.backend.dokan.abuseReports); + }); + + test('dokan announcements menu', { tag: ['@pro', '@visual'] }, async () => { + await admin.dokanMenu(data.subUrls.backend.dokan.announcements); + }); + + test('admin can add announcement', { tag: ['@pro', '@visual'] }, async () => { + await admin.addAnnouncement(); + }); + + test('admin refunds menu', { tag: ['@pro', '@visual'] }, async () => { + await admin.dokanMenu(data.subUrls.backend.dokan.refunds); + }); + + test('admin reports menu', { tag: ['@pro', '@visual'] }, async () => { + await admin.dokanMenu(data.subUrls.backend.dokan.reports); + }); + + test('admin All Logs menu', { tag: ['@pro', '@visual'] }, async () => { + await admin.dokanMenu(data.subUrls.backend.dokan.allLogs); + }); + + test('dokan modules menu', { tag: ['@pro', '@visual'] }, async () => { + await admin.dokanMenu(data.subUrls.backend.dokan.modules); + }); + + test('dokan modules plan', { tag: ['@lite', '@visual'] }, async () => { + await admin.adminModulesPlanRenderProperly(); + }); + + test('dokan tools menu', { tag: ['@pro', '@visual'] }, async () => { + await admin.dokanMenu(data.subUrls.backend.dokan.tools); + }); + + test('admin verifications menu', { tag: ['@pro', '@visual'] }, async () => { + await admin.dokanMenu(data.subUrls.backend.dokan.verifications); + }); + + test('dokan product advertising menu', { tag: ['@pro', '@visual'] }, async () => { + await admin.dokanMenu(data.subUrls.backend.dokan.productAdvertising); + }); + + test('admin can add product advertisement', { tag: ['@pro', '@visual'] }, async () => { + await admin.addNewProductAdvertisement(); + }); + + test('dokan wholesale customers menu', { tag: ['@pro', '@visual'] }, async () => { + await admin.dokanMenu(data.subUrls.backend.dokan.wholeSaleCustomer); + }); + + test('dokan help menu', { tag: ['@lite', '@visual'] }, async () => { + await admin.dokanMenu(data.subUrls.backend.dokan.help); + }); + + test('dokan settings general menu', { tag: ['@lite', '@visual'] }, async () => { + await admin.dokanSettingsMenu(selector.admin.dokan.settings.menus.general); + }); + + test('dokan settings selling menu', { tag: ['@lite', '@visual'] }, async () => { + await admin.dokanSettingsMenu(selector.admin.dokan.settings.menus.sellingOptions); + }); + + test('dokan settings withdraw menu', { tag: ['@lite', '@visual'] }, async () => { + await admin.dokanSettingsMenu(selector.admin.dokan.settings.menus.withdrawOptions); + }); + + test('dokan settings reverseWithdraw menu', { tag: ['@lite', '@visual'] }, async () => { + await admin.dokanSettingsMenu(selector.admin.dokan.settings.menus.reverseWithdrawal); + }); + + test('dokan settings page menu', { tag: ['@lite', '@visual'] }, async () => { + await admin.dokanSettingsMenu(selector.admin.dokan.settings.menus.pageSettings); + }); + + test('dokan settings appearance menu', { tag: ['@lite', '@visual'] }, async () => { + await admin.dokanSettingsMenu(selector.admin.dokan.settings.menus.appearance); + }); + + test('dokan settings privacyPolicy menu', { tag: ['@lite', '@visual'] }, async () => { + await admin.dokanSettingsMenu(selector.admin.dokan.settings.menus.privacyPolicy); + }); + + test('dokan settings colors menu', { tag: ['@pro', '@visual'] }, async () => { + await admin.dokanSettingsMenu(selector.admin.dokan.settings.menus.colors); + }); + + test('dokan settings liveSearch menu', { tag: ['@pro', '@visual'] }, async () => { + await admin.dokanSettingsMenu(selector.admin.dokan.settings.menus.liveSearch); + }); + + test('dokan settings storeSupport menu', { tag: ['@pro', '@visual'] }, async () => { + await admin.dokanSettingsMenu(selector.admin.dokan.settings.menus.storeSupport); + }); + + test('dokan settings sellerVerification menu', { tag: ['@pro', '@visual'] }, async () => { + await admin.dokanSettingsMenu(selector.admin.dokan.settings.menus.vendorVerification); + }); + + test('dokan settings verificationSmsGateways menu', { tag: ['@pro', '@visual'] }, async () => { + await admin.dokanSettingsMenu(selector.admin.dokan.settings.menus.verificationSmsGateways); + }); + + test('dokan settings emailVerification menu', { tag: ['@pro', '@visual'] }, async () => { + await admin.dokanSettingsMenu(selector.admin.dokan.settings.menus.emailVerification); + }); + + test('dokan settings socialApi menu', { tag: ['@pro', '@visual'] }, async () => { + await admin.dokanSettingsMenu(selector.admin.dokan.settings.menus.socialApi); + }); + + test('dokan settings shippingStatus menu', { tag: ['@pro', '@visual'] }, async () => { + await admin.dokanSettingsMenu(selector.admin.dokan.settings.menus.shippingStatus); + }); + + test('dokan settings quote menu', { tag: ['@pro', '@visual'] }, async () => { + await admin.dokanSettingsMenu(selector.admin.dokan.settings.menus.quote); + }); + + test('dokan settings liveChat menu', { tag: ['@pro', '@visual'] }, async () => { + await admin.dokanSettingsMenu(selector.admin.dokan.settings.menus.liveChat); + }); + + test('dokan settings rma menu', { tag: ['@pro', '@visual'] }, async () => { + await admin.dokanSettingsMenu(selector.admin.dokan.settings.menus.rma); + }); + + test('dokan settings wholesale menu', { tag: ['@pro', '@visual'] }, async () => { + await admin.dokanSettingsMenu(selector.admin.dokan.settings.menus.wholesale); + }); + + test('dokan settings euComplianceFields menu', { tag: ['@pro', '@visual'] }, async () => { + await admin.dokanSettingsMenu(selector.admin.dokan.settings.menus.euComplianceFields); + }); + + test('dokan settings deliveryTime menu', { tag: ['@pro', '@visual'] }, async () => { + await admin.dokanSettingsMenu(selector.admin.dokan.settings.menus.deliveryTime); + }); + + test('dokan settings productAdvertising menu', { tag: ['@pro', '@visual'] }, async () => { + await admin.dokanSettingsMenu(selector.admin.dokan.settings.menus.productAdvertising); + }); + + test('dokan settings geolocation menu', { tag: ['@pro', '@visual'] }, async () => { + await admin.dokanSettingsMenu(selector.admin.dokan.settings.menus.geolocation); + }); + + test('dokan settings productReportAbuse menu', { tag: ['@pro', '@visual'] }, async () => { + await admin.dokanSettingsMenu(selector.admin.dokan.settings.menus.productReportAbuse); + }); + + test('dokan settings singleProductMultiVendor menu', { tag: ['@pro', '@visual'] }, async () => { + await admin.dokanSettingsMenu(selector.admin.dokan.settings.menus.singleProductMultiVendor); + }); + + test('dokan settings vendorSubscription menu', { tag: ['@pro', '@visual'] }, async () => { + await admin.dokanSettingsMenu(selector.admin.dokan.settings.menus.vendorSubscription); + }); + + test('dokan settings vendorAnalytics menu', { tag: ['@pro', '@visual'] }, async () => { + await admin.dokanSettingsMenu(selector.admin.dokan.settings.menus.vendorAnalytics); + }); + + test('dokan license menu', { tag: ['@pro', '@visual'] }, async () => { + await admin.dokanMenu(data.subUrls.backend.dokan.license); + }); +}); + +test.describe('dokan vendor dashboard visual test', () => { + test.skip(true, 'skip visual tests'); + let vendor: VisualPage; + let vPage: Page; + + test.beforeAll(async ({ browser }) => { + const vendorContext = await browser.newContext(data.auth.vendorAuth); + vPage = await vendorContext.newPage(); + vendor = new VisualPage(vPage); + }); + + test.afterAll(async () => { + await vPage.close(); + }); + + test('dokan vendor dashboard dashboard menu', { tag: ['@lite', '@visual'] }, async () => { + await vendor.vendorDashboardMenu(data.subUrls.frontend.vDashboard.dashboard); + }); + + test('dokan vendor dashboard products menu', { tag: ['@lite', '@visual'] }, async () => { + await vendor.vendorDashboardMenu(data.subUrls.frontend.vDashboard.products); + }); + + test('dokan vendor dashboard orders menu', { tag: ['@lite', '@visual'] }, async () => { + await vendor.vendorDashboardMenu(data.subUrls.frontend.vDashboard.orders); + }); + + test('dokan vendor dashboard userSubscriptions menu', { tag: ['@pro', '@visual'] }, async () => { + await vendor.vendorDashboardMenu(data.subUrls.frontend.vDashboard.userSubscriptions); + }); + + test('dokan vendor dashboard requestQuotes menu', { tag: ['@pro', '@visual'] }, async () => { + await vendor.vendorDashboardMenu(data.subUrls.frontend.vDashboard.requestQuotes); + }); + + test('dokan vendor dashboard coupons menu', { tag: ['@pro', '@visual'] }, async () => { + await vendor.vendorDashboardMenu(data.subUrls.frontend.vDashboard.coupons); + }); + + test('dokan vendor dashboard reports menu', { tag: ['@pro', '@visual'] }, async () => { + await vendor.vendorDashboardMenu(data.subUrls.frontend.vDashboard.reports); + }); + + test('dokan vendor dashboard deliveryTime menu', { tag: ['@pro', '@visual'] }, async () => { + await vendor.vendorDashboardMenu(data.subUrls.frontend.vDashboard.deliveryTime); + }); + + test('dokan vendor dashboard reviews menu', { tag: ['@pro', '@visual'] }, async () => { + await vendor.vendorDashboardMenu(data.subUrls.frontend.vDashboard.reviews); + }); + + test('dokan vendor dashboard withdraw menu', { tag: ['@lite', '@visual'] }, async () => { + await vendor.vendorDashboardMenu(data.subUrls.frontend.vDashboard.withdraw); + }); + + test('dokan vendor dashboard reverseWithdrawal menu', { tag: ['@lite', '@visual'] }, async () => { + await vendor.vendorDashboardMenu(data.subUrls.frontend.vDashboard.reverseWithdrawal); + }); + + test('dokan vendor dashboard badges menu', { tag: ['@pro', '@visual'] }, async () => { + await vendor.vendorDashboardMenu(data.subUrls.frontend.vDashboard.badges); + }); + + test('dokan vendor dashboard productQa menu', { tag: ['@pro', '@visual'] }, async () => { + await vendor.vendorDashboardMenu(data.subUrls.frontend.vDashboard.productQa); + }); + + test('dokan vendor dashboard returnRequest menu', { tag: ['@pro', '@visual'] }, async () => { + await vendor.vendorDashboardMenu(data.subUrls.frontend.vDashboard.returnRequest); + }); + + test('dokan vendor dashboard staff menu', { tag: ['@pro', '@visual'] }, async () => { + await vendor.vendorDashboardMenu(data.subUrls.frontend.vDashboard.staff); + }); + + test('dokan vendor dashboard followers menu', { tag: ['@pro', '@visual'] }, async () => { + await vendor.vendorDashboardMenu(data.subUrls.frontend.vDashboard.followers); + }); + + test('dokan vendor dashboard booking menu', { tag: ['@pro', '@visual'] }, async () => { + await vendor.vendorDashboardMenu(data.subUrls.frontend.vDashboard.booking); + }); + + test('dokan vendor dashboard announcements menu', { tag: ['@pro', '@visual'] }, async () => { + await vendor.vendorDashboardMenu(data.subUrls.frontend.vDashboard.announcements); + }); + + test('dokan vendor dashboard analytics menu', { tag: ['@pro', '@visual'] }, async () => { + await vendor.vendorDashboardMenu(data.subUrls.frontend.vDashboard.analytics); + }); + + test('dokan vendor dashboard tools menu', { tag: ['@pro', '@visual'] }, async () => { + await vendor.vendorDashboardMenu(data.subUrls.frontend.vDashboard.tools); + }); + + test('dokan vendor dashboard inbox menu', { tag: ['@pro', '@visual'] }, async () => { + await vendor.vendorDashboardMenu(data.subUrls.frontend.vDashboard.inbox); + }); + + test('dokan vendor dashboard storeSupport menu', { tag: ['@pro', '@visual'] }, async () => { + await vendor.vendorDashboardMenu(data.subUrls.frontend.vDashboard.storeSupport); + }); + + test('dokan vendor dashboard store settings menu', { tag: ['@lite', '@visual'] }, async () => { + await vendor.vendorDashboardMenu(data.subUrls.frontend.vDashboard.settingsStore); + }); + + test('dokan vendor dashboard addon settings menu', { tag: ['@pro', '@visual'] }, async () => { + await vendor.vendorDashboardMenu(data.subUrls.frontend.vDashboard.settingsAddon); + }); + + test('dokan vendor dashboard payment settings menu', { tag: ['@lite', '@visual'] }, async () => { + await vendor.vendorDashboardMenu(data.subUrls.frontend.vDashboard.settingsPayment); + }); + + test('dokan vendor dashboard verification settings menu', { tag: ['@pro', '@visual'] }, async () => { + await vendor.vendorDashboardMenu(data.subUrls.frontend.vDashboard.settingsVerification); + }); + + test('dokan vendor dashboard delivery time settings menu', { tag: ['@pro', '@visual'] }, async () => { + await vendor.vendorDashboardMenu(data.subUrls.frontend.vDashboard.settingsDeliveryTime); + }); + + test('dokan vendor dashboard shipping settings menu', { tag: ['@pro', '@visual'] }, async () => { + await vendor.vendorDashboardMenu(data.subUrls.frontend.vDashboard.settingsShipping); + }); + + test('dokan vendor dashboard shipstation settings menu', { tag: ['@pro', '@visual'] }, async () => { + await vendor.vendorDashboardMenu(data.subUrls.frontend.vDashboard.settingsShipStation); + }); + + test('dokan vendor dashboard social profile settings menu', { tag: ['@pro', '@visual'] }, async () => { + await vendor.vendorDashboardMenu(data.subUrls.frontend.vDashboard.settingsSocialProfile); + }); + + test('dokan vendor dashboard rma settings menu', { tag: ['@pro', '@visual'] }, async () => { + await vendor.vendorDashboardMenu(data.subUrls.frontend.vDashboard.settingsRma); + }); + + test('dokan vendor dashboard printful settings menu', { tag: ['@pro', '@visual'] }, async () => { + await vendor.vendorDashboardMenu(data.subUrls.frontend.vDashboard.settingsPrintful); + }); + + test('dokan vendor dashboard seo settings menu', { tag: ['@pro', '@visual'] }, async () => { + await vendor.vendorDashboardMenu(data.subUrls.frontend.vDashboard.settingsSeo); + }); +}); diff --git a/tests/pw/utils/dbUtils.ts b/tests/pw/utils/dbUtils.ts index 3da28f683f..35c2aabb6b 100644 --- a/tests/pw/utils/dbUtils.ts +++ b/tests/pw/utils/dbUtils.ts @@ -225,8 +225,7 @@ export const dbUtils = { return res; }, - async addStoreBiographyAndMapLocation(sellerId: string) { - await dbUtils.updateUserMeta(sellerId, 'dokan_profile_settings', { vendor_biography: 'test biography' }); + async addStoreMapLocation(sellerId: string) { await dbUtils.updateUserMeta(sellerId, 'dokan_profile_settings', { find_address: 'New York, NY, USA' }); await dbUtils.setUserMeta(sellerId, 'dokan_geo_latitude', '40.7127753', false); await dbUtils.setUserMeta(sellerId, 'dokan_geo_longitude', '-74.0059728', false); diff --git a/tests/pw/utils/payloads.ts b/tests/pw/utils/payloads.ts index 0444f17804..19c1de3555 100644 --- a/tests/pw/utils/payloads.ts +++ b/tests/pw/utils/payloads.ts @@ -2113,7 +2113,7 @@ export const payloads = { gravatar: '', show_more_ptab: 'yes', store_ppp: 12, - enable_tnc: 'off', + enable_tnc: false, store_tnc: '', show_min_order_discount: '', store_seo: [], @@ -3738,7 +3738,7 @@ export const payloads = { social: [], payment: [], phone: '0123456789', - show_email: 'no', + show_email: 'yes', address: [], location: '', banner: '', @@ -3746,7 +3746,7 @@ export const payloads = { gravatar: '', show_more_tpab: 'yes', show_ppp: 12, - enable_tnc: 'off', + enable_tnc: 'on', store_seo: [], dokan_store_time: [], enabled: 'yes', @@ -3788,11 +3788,11 @@ export const payloads = { location: '40.7127753,-74.0059728', banner_id: 0, gravatar_id: 0, - enable_tnc: 'yes', + enable_tnc: true, store_tnc: 'test Vendor terms and conditions', - featured: 'yes', - enabled: 'yes', - trusted: 'yes', // publish product directly + featured: true, + enabled: true, + trusted: true, // publish product directly payment: { paypal: { email: 'paypal@g.c', @@ -3906,10 +3906,6 @@ export const payloads = { }), updateStore: () => ({ - // email: faker.internet.email(), - // store_name: faker.person.firstName(), - // first_name: faker.person.firstName(), - // last_name: faker.person.lastName(), social: { fb: 'https://www.facebook.com/', twitter: 'https://www.twitter.com/', @@ -3921,7 +3917,7 @@ export const payloads = { threads: 'https://www.threads.net/', }, phone: '0123456789', - show_email: 'yes', + show_email: true, address: { street_1: 'abc street', street_2: 'xyz street', @@ -3933,11 +3929,11 @@ export const payloads = { location: '40.7127753,-74.0059728', banner_id: 0, gravatar_id: 0, - enable_tnc: 'yes', + enable_tnc: true, store_tnc: 'test Vendor terms and conditions', - featured: 'yes', - enabled: 'yes', - trusted: 'yes', // publish product directly + featured: true, + enabled: true, + trusted: true, // publish product directly payment: { paypal: { email: 'paypal@g.c', @@ -4063,7 +4059,7 @@ export const payloads = { threads: 'https://www.threads.net/', }, phone: '0123456789', - show_email: 'yes', + show_email: true, address: { street_1: 'abc street', street_2: 'xyz street', @@ -4078,10 +4074,10 @@ export const payloads = { gravatar: 0, gravatar_id: 0, - enable_tnc: 'on', + enable_tnc: true, store_tnc: 'test Vendor terms and conditions', featured: 'yes', - enabled: 'yes', + enabled: true, payment: { paypal: { email: 'paypal@g.c', @@ -4140,12 +4136,12 @@ export const payloads = { }, storeResetFields: { - featured: 'yes', - enabled: 'yes', - trusted: 'yes', - enable_tnc: 'yes', - show_email: 'yes', - sale_only_here: 'yes', + featured: true, + enabled: true, + trusted: true, + enable_tnc: true, + show_email: true, + sale_only_here: true, store_open_close: { enabled: 'yes', }, @@ -4202,7 +4198,7 @@ export const payloads = { }, createStore1: { - user_login: VENDOR, + user_login: VENDOR , user_pass: USER_PASSWORD, user_nicename: `${VENDOR}store`, // store url email: `${VENDOR}@email.com`, @@ -4222,7 +4218,7 @@ export const payloads = { threads: 'https://www.threads.net/', }, phone: '0123456789', - show_email: 'yes', + show_email: true, address: { street_1: 'abc street', street_2: 'xyz street', @@ -4234,11 +4230,11 @@ export const payloads = { location: '40.7127753,-74.0059728', banner_id: 0, gravatar_id: 0, - enable_tnc: 'yes', + enable_tnc: true, store_tnc: 'test Vendor terms and conditions', - featured: 'yes', - enabled: 'yes', - trusted: 'yes', // publish product directly + featured: true, + enabled: true, + trusted: true, // publish product directly payment: { paypal: { email: 'paypal@g.c', @@ -4314,7 +4310,7 @@ export const payloads = { vat_number: faker.string.alphanumeric(10), bank_name: faker.string.alphanumeric(7), bank_iban: faker.finance.iban(), - vendor_biography: 'test vendor biography', // todo: api does not support this field create enhancement + vendor_biography: 'test vendor biography', categories: [ { // id: 74, @@ -4373,7 +4369,7 @@ export const payloads = { threads: 'https://www.threads.net/', }, phone: '0123456789', - show_email: 'yes', + show_email: true, address: { street_1: 'abc street', street_2: 'xyz street', @@ -4385,11 +4381,11 @@ export const payloads = { location: '40.7127753,-74.0059728', banner_id: 0, gravatar_id: 0, - enable_tnc: 'yes', + enable_tnc: true, store_tnc: 'test Vendor terms and conditions', - featured: 'yes', - enabled: 'yes', - trusted: 'yes', // publish product directly + featured: true, + enabled: true, + trusted: true, // publish product directly payment: { paypal: { email: 'paypal@g.c', diff --git a/tests/pw/visual.config.ts b/tests/pw/visual.config.ts new file mode 100644 index 0000000000..2d9d0af618 --- /dev/null +++ b/tests/pw/visual.config.ts @@ -0,0 +1,171 @@ +import { defineConfig, devices, expect } from '@playwright/test'; +import { customExpect } from '@utils/pwMatchers'; +import 'dotenv/config'; +const { CI, NON_HEADLESS, BASE_URL, SLOWMO, NO_SETUP, DOKAN_PRO } = process.env; + +export default defineConfig({ + /* test directory */ + testDir: 'tests/visual', + /* Include tests based on the pattern */ + grep: [/@lite/, /@liteOnly/, /@pro/], + /* Exclude tests based on the pattern */ + grepInvert: DOKAN_PRO ? [/@liteOnly/, /@serial/] : [/@pro/, /@serial/], + /* Folder for test artifacts such as screenshots, videos, traces, etc. */ + outputDir: 'playwright/visual/test-artifacts/', + /* Path to the global setup file. This file will be required and run before all the tests. */ + // globalSetup: './global-setup', + /* Path to the global teardown file. This file will be required and run after all the tests. */ + // globalTeardown: './global-teardown' , + /* Maximum time in milliseconds the whole test suite can run */ + globalTimeout: CI ? 40 * (60 * 1000) : 40 * (60 * 1000), + /* The maximum number of test failures for the whole test suite run. After reaching this number, testing will stop and exit with an error. */ + maxFailures: CI ? 50 : 50, + /* Maximum time one test can run for. */ + timeout: CI ? 35 * 1000 : 45 * 1000, + /* Configuration for the expect assertion library */ + expect: { + /* Maximum time expect() should wait for the condition to be met. For example in `await expect(locator).toHaveText();`*/ + timeout: 15 * 1000, + toHaveScreenshot: { + maxDiffPixelRatio: 0.2, + maxDiffPixels: 500, + threshold: 0.2, + }, + }, + /* Whether to preserve test output in the testConfig.outputDir. Defaults to 'always'. */ + preserveOutput: 'always', + /* Run tests in files in parallel */ + // fullyParallel : true, + /* Fail the build on CI if you accidentally left test-only in the source code. */ + // forbidOnly : !!CI, + /* The number of times to repeat each test, useful for debugging flaky tests. */ + repeatEach: CI ? 0 : 0, + /* The maximum number of retry attempts given to failed tests. */ + retries: CI ? 1 : 0, + /* Opt out of parallel tests on CI. */ + workers: CI ? 4 : 4, + /* Whether to report slow test files. Pass null to disable this feature. */ + reportSlowTests: { max: 2, threshold: 25 }, + /* Configure reporters */ + reporter: CI + ? [ + // ['github'], + // ['html', { open: 'never', outputFolder: 'playwright-report/e2e/html-report' }], + ['blob', { open: 'outputDir', outputDir: 'playwright-report/e2e/blob-report' }], + ['list', { printSteps: true }], + ['./utils/summaryReporter.ts', { outputFile: 'playwright-report/e2e/summary-report/results.json' }], + ] + : [ + // ['blob', { open: 'outputDir', outputDir: 'playwright-report/e2e/blob-report' }], + ['html', { open: 'never', outputFolder: 'playwright-report/e2e/html-report' }], + ['list', { printSteps: true }], + ['./utils/summaryReporter.ts', { outputFile: 'playwright-report/e2e/summary-report/results.json' }], + ], + + use: { + + ...devices['Desktop Chrome'], + /* Whether to automatically download all the attachments. */ + acceptDownloads: true, + /* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */ + actionTimeout: 15 * 1000, + /* Maximum time each navigation such as 'goto()' can take. */ + navigationTimeout: 20 * 1000, + /* Base URL */ + baseURL: BASE_URL ?? 'http://localhost:9999', + /* Name of the browser that runs tests. */ + // browserName: 'chromium', + /* Toggles bypassing page's Content-Security-Policy. */ + bypassCSP: true, + /* Browser distribution channel. */ + // channel: 'chrome', + /* Emulates 'prefers-colors-scheme' media feature, supported values are 'light', 'dark', 'no-preference' */ + // colorScheme: 'dark' , + /* Whether to run tests on headless or non-headless mode */ + headless: !NON_HEADLESS, + /* Whether to ignore HTTPS errors during navigation. */ + ignoreHTTPSErrors: true, + /* Record trace only when retrying a test for the first time. */ + trace: { + mode: 'on-first-retry', + snapshots: true, + screenshots: true, + sources: true, + attachments: true, + }, + /* Capture screenshot after each test failure. */ + screenshot: { + mode: 'only-on-failure', + fullPage: true, + }, + /* Record video only when retrying a test for the first time. */ + video: DOKAN_PRO ? 'off' : 'on-first-retry', // to reduce artifacts size in CI for dokan-pro + /* Size of viewport */ + // viewport: { width: 1420, height: 900 }, // default 1280x720 + /* whether to slow down test execution by provided seconds */ + launchOptions: { + slowMo: (SLOWMO ?? 0) * 1000, + // devtools: true, + + }, + viewport: { width: 1280, height: 1922 }, + }, + + projects: [ + // E2E project + + // local_site_setup + { + name: 'local_site_setup', + testMatch: ['_localSite.setup.ts'], + }, + + // site_setup + { + name: 'site_setup', + testMatch: ['_site.setup.ts'], + }, + + // auth_setup + { + name: 'auth_setup', + testMatch: ['_auth.setup.ts'], + dependencies: NO_SETUP ? [] : ['site_setup'], + // fullyParallel: true, + retries: 1, + }, + + // e2e_setup + { + name: 'e2e_setup', + testMatch: ['_env.setup.ts'], + dependencies: NO_SETUP ? [] : ['auth_setup'], + fullyParallel: true, + retries: 1, + }, + + // visual_tests + { + name: 'visual_tests', + testMatch: /.*\.spec\.ts/, + /* whether not to run setup tests before running actual tests */ + dependencies: NO_SETUP ? [] : ['e2e_setup'], + /* whether not to run teardown tests after running actual tests */ + // teardown: NO_SETUP ? undefined : 'coverage_report', + }, + + // coverage_report + { + name: 'coverage_report', + testMatch: ['_coverage.teardown.ts'], + }, + + // global_teardown + { + name: 'global_teardown', + testMatch: ['global-teardown.ts'], + }, + ], +}); + +expect.extend(customExpect);