diff --git a/assets/src/js/dokan-daterangepicker.js b/assets/src/js/dokan-daterangepicker.js index fdc8b22e93..4529055058 100644 --- a/assets/src/js/dokan-daterangepicker.js +++ b/assets/src/js/dokan-daterangepicker.js @@ -4,7 +4,7 @@ // Set date range data. let localeData = { format : dokan_get_daterange_picker_format(), - ...dokan_helper.locale + ...dokan_helper.daterange_picker_local }; // Date range picker handler. diff --git a/assets/src/js/helper.js b/assets/src/js/helper.js index 7a128025dd..d0d2c5ea41 100644 --- a/assets/src/js/helper.js +++ b/assets/src/js/helper.js @@ -262,6 +262,7 @@ showCancelButton : true, confirmButtonColor:'#28a745', cancelButtonColor :'#dc3545', + ...dokan_helper.sweetalert_local }; const args = { ...defaults, ...options }; diff --git a/composer.json b/composer.json index bbfb2f81ee..167c269d29 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "minimum-stability": "dev", "require": { "php": ">=7.4", - "appsero/client": "^v1.4.0", + "appsero/client": "^v2.0.1", "jakeasmith/http_build_url": "^1" }, "require-dev": { diff --git a/composer.lock b/composer.lock index acade28223..64fa042447 100644 --- a/composer.lock +++ b/composer.lock @@ -4,20 +4,20 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "c2a9df22d67a08d96f9896580e526200", + "content-hash": "b7c36dca126f9ba3110cb4dc269fedad", "packages": [ { "name": "appsero/client", - "version": "v1.4.0", + "version": "v2.0.1", "source": { "type": "git", "url": "https://github.com/Appsero/client.git", - "reference": "43289d79f1d55de687f667b17a2834b986cc7b6e" + "reference": "b87e7593c6295748e88cdbfc92a638c8a73462ce" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Appsero/client/zipball/43289d79f1d55de687f667b17a2834b986cc7b6e", - "reference": "43289d79f1d55de687f667b17a2834b986cc7b6e", + "url": "https://api.github.com/repos/Appsero/client/zipball/b87e7593c6295748e88cdbfc92a638c8a73462ce", + "reference": "b87e7593c6295748e88cdbfc92a638c8a73462ce", "shasum": "" }, "require": { @@ -56,9 +56,9 @@ ], "support": { "issues": "https://github.com/Appsero/client/issues", - "source": "https://github.com/Appsero/client/tree/v1.4.0" + "source": "https://github.com/Appsero/client/tree/v2.0.1" }, - "time": "2024-01-08T11:38:14+00:00" + "time": "2024-01-16T11:20:48+00:00" }, { "name": "jakeasmith/http_build_url", @@ -311,12 +311,12 @@ "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "ff095c3c65c144f32a811685a81195c4df53fb99" + "reference": "ce019e9ad711e31ee87c2c4c72e538b5240970c3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/ff095c3c65c144f32a811685a81195c4df53fb99", - "reference": "ff095c3c65c144f32a811685a81195c4df53fb99", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/ce019e9ad711e31ee87c2c4c72e538b5240970c3", + "reference": "ce019e9ad711e31ee87c2c4c72e538b5240970c3", "shasum": "" }, "require": { @@ -362,7 +362,7 @@ "issues": "https://github.com/nikic/PHP-Parser/issues", "source": "https://github.com/nikic/PHP-Parser/tree/master" }, - "time": "2024-01-10T19:34:09+00:00" + "time": "2024-01-14T09:02:54+00:00" }, { "name": "phar-io/manifest", @@ -744,12 +744,12 @@ "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHPCSUtils.git", - "reference": "da4c4da18b430eacdc6a6016009475951f9b1434" + "reference": "26dcb893d86fbe90ab2a8abd7b08a3fda3602237" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHPCSUtils/zipball/da4c4da18b430eacdc6a6016009475951f9b1434", - "reference": "da4c4da18b430eacdc6a6016009475951f9b1434", + "url": "https://api.github.com/repos/PHPCSStandards/PHPCSUtils/zipball/26dcb893d86fbe90ab2a8abd7b08a3fda3602237", + "reference": "26dcb893d86fbe90ab2a8abd7b08a3fda3602237", "shasum": "" }, "require": { @@ -825,7 +825,7 @@ "type": "open_collective" } ], - "time": "2024-01-02T16:59:15+00:00" + "time": "2024-01-15T05:03:54+00:00" }, { "name": "phpunit/php-code-coverage", @@ -1152,12 +1152,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "241c4aa189ef1f3b7608de2da5510a59f1d22a01" + "reference": "4c1997c21fb0e29198b7b83be49d460df2571d79" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/241c4aa189ef1f3b7608de2da5510a59f1d22a01", - "reference": "241c4aa189ef1f3b7608de2da5510a59f1d22a01", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/4c1997c21fb0e29198b7b83be49d460df2571d79", + "reference": "4c1997c21fb0e29198b7b83be49d460df2571d79", "shasum": "" }, "require": { @@ -1247,7 +1247,7 @@ "type": "tidelift" } ], - "time": "2024-01-07T09:57:50+00:00" + "time": "2024-01-21T09:34:47+00:00" }, { "name": "sebastian/cli-parser", @@ -2219,12 +2219,12 @@ "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", - "reference": "364cc7269d54dc4c862d1a41318764c86e43710d" + "reference": "e0e03f05662f5035923abebc90f85abaf5efdb3f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/364cc7269d54dc4c862d1a41318764c86e43710d", - "reference": "364cc7269d54dc4c862d1a41318764c86e43710d", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/e0e03f05662f5035923abebc90f85abaf5efdb3f", + "reference": "e0e03f05662f5035923abebc90f85abaf5efdb3f", "shasum": "" }, "require": { @@ -2292,7 +2292,7 @@ "type": "open_collective" } ], - "time": "2024-01-10T13:52:25+00:00" + "time": "2024-01-22T23:39:52+00:00" }, { "name": "tareq1988/wp-php-cs-fixer", diff --git a/dokan.php b/dokan.php index 2107651a56..c5b84e57db 100755 --- a/dokan.php +++ b/dokan.php @@ -291,7 +291,7 @@ private function define( $name, $value ) { public function declare_woocommerce_feature_compatibility() { if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) { \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true ); - \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'cart_checkout_blocks', __FILE__, false ); + \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'cart_checkout_blocks', __FILE__, true ); } } diff --git a/includes/Assets.php b/includes/Assets.php index f6842b1690..e91c9793b6 100644 --- a/includes/Assets.php +++ b/includes/Assets.php @@ -757,6 +757,13 @@ public function load_dokan_global_scripts() { __( 'December', 'dokan-lite' ), ], ], + 'sweetalert_local' => [ + 'cancelButtonText' => __( 'Cancel', 'dokan-lite' ), + 'closeButtonText' => __( 'Close', 'dokan-lite' ), + 'confirmButtonText' => __( 'OK', 'dokan-lite' ), + 'denyButtonText' => __( 'No', 'dokan-lite' ), + 'closeButtonAriaLabel' => __( 'Close this dialog', 'dokan-lite' ), + ], ] ); diff --git a/includes/CatalogMode/Dashboard/Products.php b/includes/CatalogMode/Dashboard/Products.php index d5f4afaffe..bf84cf9d0e 100644 --- a/includes/CatalogMode/Dashboard/Products.php +++ b/includes/CatalogMode/Dashboard/Products.php @@ -30,6 +30,7 @@ public function __construct() { add_action( 'dokan_product_edit_after_options', [ $this, 'render_product_section' ], 99, 1 ); // save catalog mode section data add_action( 'dokan_product_updated', [ $this, 'save_catalog_mode_data' ], 13 ); + add_action( 'dokan_new_product_added', [ $this, 'save_catalog_mode_data' ], 13 ); } /** diff --git a/includes/Dashboard/Templates/Dashboard.php b/includes/Dashboard/Templates/Dashboard.php index 4e303b30a8..11861d956a 100644 --- a/includes/Dashboard/Templates/Dashboard.php +++ b/includes/Dashboard/Templates/Dashboard.php @@ -122,11 +122,62 @@ public function get_orders_widgets() { ], ]; + $nonce = wp_create_nonce( 'seller-order-filter-nonce' ); + $order_url = dokan_get_navigation_url( 'orders' ); + $completed_url = add_query_arg( + [ + 'order_status' => 'wc-completed', + 'seller_order_filter_nonce' => $nonce, + ], + $order_url + ); + $pending_url = add_query_arg( + [ + 'order_status' => 'wc-pending', + 'seller_order_filter_nonce' => $nonce, + ], + $order_url + ); + $processing_url = add_query_arg( + [ + 'order_status' => 'wc-processing', + 'seller_order_filter_nonce' => $nonce, + ], + $order_url + ); + $cancelled_url = add_query_arg( + [ + 'order_status' => 'wc-cancelled', + 'seller_order_filter_nonce' => $nonce, + ], + $order_url + ); + $refunded_url = add_query_arg( + [ + 'order_status' => 'wc-refunded', + 'seller_order_filter_nonce' => $nonce, + ], + $order_url + ); + $on_hold_url = add_query_arg( + [ + 'order_status' => 'wc-on-hold', + 'seller_order_filter_nonce' => $nonce, + ], + $order_url + ); + dokan_get_template_part( 'dashboard/orders-widget', '', [ - 'order_data' => $order_data, - 'orders_count' => $this->orders_count, - 'orders_url' => dokan_get_navigation_url( 'orders' ), + 'order_data' => $order_data, + 'orders_count' => $this->orders_count, + 'orders_url' => $order_url, + 'completed_url' => $completed_url, + 'pending_url' => $pending_url, + 'processing_url' => $processing_url, + 'cancelled_url' => $cancelled_url, + 'refunded_url' => $refunded_url, + 'on_hold_url' => $on_hold_url, ] ); } @@ -142,11 +193,33 @@ public function get_products_widgets() { if ( ! current_user_can( 'dokan_view_product_status_report' ) ) { return; } - + $nonce = wp_create_nonce( 'product_listing_filter' ); + $product_url = dokan_get_navigation_url( 'products' ); + $online_url = add_query_arg( + [ + 'post_status' => 'publish', + '_product_listing_filter_nonce' => $nonce, + ], $product_url + ); + $draft_url = add_query_arg( + [ + 'post_status' => 'draft', + '_product_listing_filter_nonce' => $nonce, + ], $product_url + ); + $pending_url = add_query_arg( + [ + 'post_status' => 'pending', + '_product_listing_filter_nonce' => $nonce, + ], $product_url + ); dokan_get_template_part( 'dashboard/products-widget', '', [ 'post_counts' => $this->get_post_counts(), - 'products_url' => dokan_get_navigation_url( 'products' ), + 'products_url' => $product_url, + 'online_url' => $online_url, + 'draft_url' => $draft_url, + 'pending_url' => $pending_url, ] ); } diff --git a/includes/Frontend/MyAccount/BecomeAVendor.php b/includes/Frontend/MyAccount/BecomeAVendor.php index f29e6bccf0..60506c5a15 100644 --- a/includes/Frontend/MyAccount/BecomeAVendor.php +++ b/includes/Frontend/MyAccount/BecomeAVendor.php @@ -176,6 +176,8 @@ public function load_customer_to_vendor_update_template() { return; } + wp_enqueue_script( 'dokan-vendor-registration' ); + $data = [ 'user_id' => $user_id, 'first_name' => get_user_meta( $user_id, 'first_name', true ), diff --git a/includes/Order/Hooks.php b/includes/Order/Hooks.php index b5a25e66dd..22597eb98a 100644 --- a/includes/Order/Hooks.php +++ b/includes/Order/Hooks.php @@ -36,9 +36,11 @@ public function __construct() { // create sub-orders add_action( 'woocommerce_checkout_update_order_meta', [ $this, 'split_vendor_orders' ] ); + add_action( 'woocommerce_store_api_checkout_update_order_meta', [ $this, 'split_vendor_orders' ] ); // order table synced for WooCommerce update order meta add_action( 'woocommerce_checkout_update_order_meta', 'dokan_sync_insert_order', 20 ); + add_action( 'woocommerce_store_api_checkout_update_order_meta', 'dokan_sync_insert_order', 20 ); // order table synced for dokan update order meta add_action( 'dokan_checkout_update_order_meta', 'dokan_sync_insert_order' ); diff --git a/includes/Order/Manager.php b/includes/Order/Manager.php index 4616ef60fb..f9997245f4 100644 --- a/includes/Order/Manager.php +++ b/includes/Order/Manager.php @@ -881,7 +881,13 @@ function ( $item ) { * @return void */ public function maybe_split_orders( $parent_order_id, $force_create = false ) { - $parent_order = $this->get( $parent_order_id ); + if ( is_a( $parent_order_id, 'WC_Order' ) ) { + $parent_order = $parent_order_id; + $parent_order_id = $parent_order->get_id(); + } else { + $parent_order = $this->get( $parent_order_id ); + } + if ( ! $parent_order ) { //dokan_log( sprintf( 'Invalid Order ID #%d found. Skipping from here.', $parent_order_id ) ); return; diff --git a/includes/Order/functions.php b/includes/Order/functions.php index f3dbbed329..6ddde73040 100644 --- a/includes/Order/functions.php +++ b/includes/Order/functions.php @@ -215,7 +215,13 @@ function dokan_delete_sync_duplicate_order( $order_id, $seller_id ) { function dokan_sync_insert_order( $order_id ) { global $wpdb; - $order = wc_get_order( $order_id ); + if ( is_a( $order_id, 'WC_Order' ) ) { + $order = $order_id; + $order_id = $order->get_id(); + } else { + $order = wc_get_order( $order_id ); + } + if ( ! $order || $order instanceof WC_Subscription ) { return; } diff --git a/includes/Shipping/Hooks.php b/includes/Shipping/Hooks.php index 923fbe2ba5..22b29436e7 100644 --- a/includes/Shipping/Hooks.php +++ b/includes/Shipping/Hooks.php @@ -43,6 +43,9 @@ public function split_shipping_packages( $packages ) { $packages = []; foreach ( $cart_content as $key => $item ) { + if ( $item['data']->is_virtual() ) { + continue; + } $post_author = get_post_field( 'post_author', $item['data']->get_id() ); $seller_pack[ $post_author ][ $key ] = $item; diff --git a/includes/Vendor/SetupWizard.php b/includes/Vendor/SetupWizard.php index ef168e82ce..c3dbe32703 100644 --- a/includes/Vendor/SetupWizard.php +++ b/includes/Vendor/SetupWizard.php @@ -402,7 +402,7 @@ public function dokan_setup_store_save() { } update_user_meta( $this->store_id, 'dokan_profile_settings', $dokan_settings ); - + do_action( 'dokan_store_profile_saved', $this->store_id, $dokan_settings ); do_action( 'dokan_seller_wizard_store_field_save', $this ); wp_safe_redirect( esc_url_raw( $this->get_next_step_link() ) ); diff --git a/includes/functions-rest-api.php b/includes/functions-rest-api.php index ea846b4c45..8e8a93e159 100644 --- a/includes/functions-rest-api.php +++ b/includes/functions-rest-api.php @@ -1,7 +1,7 @@ 400 ] ); } } + +if ( ! function_exists( 'dokan_rest_validate_order_id' ) ) { + /** + * This method will verify an order id, will be used only with rest api validate callback + * + * @since DOKAN_SINCE + * + * @param $value + * @param $request WP_REST_Request + * @param $key + * + * @return bool|WP_Error + */ + function dokan_rest_validate_order_id( $value, $request, $key ) { + $attributes = $request->get_attributes(); + + if ( isset( $attributes['args'][ $key ] ) ) { + $argument = $attributes['args'][ $key ]; + // Check to make sure our argument is an int. + if ( 'integer' === $argument['type'] && ! is_numeric( $value ) ) { + // translators: 1) argument name, 2) argument value + return new WP_Error( 'rest_invalid_param', sprintf( esc_html__( '%1$s is not of type %2$s', 'dokan-lite' ), $key, 'integer' ), [ 'status' => 400 ] ); + } + } else { + // this code won't execute because we have specified this argument as required. + // if we reused this validation callback and did not have required args then this would fire. + // translators: 1) argument name + return new WP_Error( 'rest_invalid_param', sprintf( esc_html__( '%s was not registered as a request argument.', 'dokan-lite' ), $key ), [ 'status' => 400 ] ); + } + + $order = wc_get_order( (int) $value ); + if ( $order ) { + return true; + } + + // translators: 1) rest api endpoint key name + return new WP_Error( 'rest_invalid_param', sprintf( esc_html__( 'No store found with given store id', 'dokan-lite' ), $key ), [ 'status' => 400 ] ); + } +} diff --git a/includes/functions.php b/includes/functions.php index ca3e9e66e3..39df1c285f 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -4351,4 +4351,22 @@ function dokan_user_update_to_seller( $user, $data ) { do_action( 'dokan_new_seller_created', $user_id, $vendor->get_shop_info() ); } -} \ No newline at end of file +} + +/** + * Get new product creation URL. + * + * @since DOKAN_SINCE + * + * @return false|string + */ +function dokan_get_new_product_url() { + $one_step_product_create = 'on' === dokan_get_option( 'one_step_product_create', 'dokan_selling', 'on' ); + + return $one_step_product_create ? dokan_edit_product_url( 0, true ) : add_query_arg( + [ + '_dokan_add_product_nonce' => wp_create_nonce( 'dokan_add_product_nonce' ), + ], + dokan_get_navigation_url( 'new-product' ) + ); +} diff --git a/includes/template-tags.php b/includes/template-tags.php index ad81fec13a..4b8b595032 100755 --- a/includes/template-tags.php +++ b/includes/template-tags.php @@ -580,7 +580,7 @@ function dokan_dashboard_nav( $active_menu = '' ) { * * @param string $menu_key */ - $filtered_key = apply_filters( 'dokan_dashboard_nav_menu_key', $key ); + $filtered_key = rawurlencode_deep( apply_filters( 'dokan_dashboard_nav_menu_key', $key ) ); $class = $active_menu === $filtered_key || 0 === stripos( $active_menu, $filtered_key ) ? 'active ' . $key : $key; // checking starts with the key $title = isset( $item['title'] ) ? $item['title'] : __( 'No title', 'dokan-lite' ); @@ -602,7 +602,7 @@ function dokan_dashboard_nav( $active_menu = '' ) { * @param string $submenu_key * @param string $menu_key */ - $filtered_subkey = apply_filters( 'dokan_dashboard_nav_submenu_key', $sub_key, $key ); + $filtered_subkey = rawurlencode_deep( apply_filters( 'dokan_dashboard_nav_submenu_key', $sub_key, $key ) ); $submenu_class = $active_submenu === $filtered_subkey || 0 === stripos( $active_submenu, $filtered_subkey ) ? "current $sub_key" : $sub_key; diff --git a/package.json b/package.json index 29f95a4b30..212d3a4494 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,8 @@ "format": "wp-scripts format", "lint:css": "wp-scripts lint-style", "lint:js": "wp-scripts lint-js", - "release": "npm run readme && npm run build && npm run clean-files && npm run makepot && npm run version && npm run zip" + "release": "npm install && npm run readme && npm run build && npm run clean-files && npm run makepot && npm run version && npm run zip", + "release:dev": "npm install && npm run build && npm run clean-files && npm run makepot && npm run zip" }, "devDependencies": { "@wordpress/scripts": "^26.18.0", diff --git a/templates/dashboard/orders-widget.php b/templates/dashboard/orders-widget.php index f1f38a8ca5..6d70768506 100644 --- a/templates/dashboard/orders-widget.php +++ b/templates/dashboard/orders-widget.php @@ -6,6 +6,14 @@ * * @since 2.4 * + * @var string $orders_url Order Url. + * @var string $completed_url Completed Order Url. + * @var string $pending_url Pending Order Url. + * @var string $processing_url Processing Order Url. + * @var string $cancelled_url Cancelled Order Url. + * @var string $refunded_url Refunded Order Url. + * @var string $on_hold_url On Hold Order Url. + * * @package dokan */ ?> @@ -21,32 +29,32 @@
  • - + {'wc-completed'}, 0 ) ); ?>
  • - + {'wc-pending'}, 0 ) ); ?>
  • - + {'wc-processing'}, 0 ) ); ?>
  • - + {'wc-cancelled'}, 0 ) ); ?>
  • - + {'wc-refunded'}, 0 ) ); ?>
  • - + {'wc-on-hold'}, 0 ) ); ?>
  • diff --git a/templates/dashboard/products-widget.php b/templates/dashboard/products-widget.php index fd67ca19f4..7321bd1cb2 100644 --- a/templates/dashboard/products-widget.php +++ b/templates/dashboard/products-widget.php @@ -7,6 +7,12 @@ * * @since 2.4 * + * @var object $post_counts All product status count. + * @var string $products_url All product listing url. + * @var string $online_url Online product listing url. + * @var string $draft_url Draft product listing url. + * @var string $pending_url Pending product listing url. + * * @package dokan */ ?> @@ -16,7 +22,7 @@ - + @@ -27,17 +33,17 @@
  • - + publish ); ?>
  • - + draft ); ?>
  • - + pending ); ?>
  • diff --git a/templates/products/edit-product-single.php b/templates/products/edit-product-single.php index 049cd14de0..c5e0a6d065 100755 --- a/templates/products/edit-product-single.php +++ b/templates/products/edit-product-single.php @@ -50,7 +50,14 @@ $product->set_name( $post_title ); $product->set_status( $post_status ); - $post_id = $product->save(); + $post_id = $product->save(); + wp_update_post( + [ + 'ID' => $post_id, + 'post_author' => dokan_get_current_user_id(), + ] + ); + $post = get_post( $post_id ); $from_shortcode = true; $new_product = true;