Skip to content

Commit

Permalink
Merge branch 'release/3.14.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
Aunshon committed Dec 27, 2024
2 parents e49d823 + 49068d3 commit 56488ae
Show file tree
Hide file tree
Showing 111 changed files with 4,106 additions and 1,463 deletions.
1 change: 1 addition & 0 deletions .github/workflows/e2e_api_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ env:
CUSTOMER2: customer2
USER_PASSWORD: 01dokan01
GMAP: ${{secrets.GMAP}}
MAPBOX: ${{secrets.MAPBOX}}
BASE_URL: http://localhost:9999
CI: true
FORCE_COLOR: 1
Expand Down
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
### v3.14.0 ( Dec 02, 2024 ) ###

- **new:** Commission amount now displayed in the product list within the admin dashboard.
- **new:** Vendor earning amount displayed in the product list within the vendor dashboard.
- **new:** Vendor earning suggestions on the product add and edit pages in the vendor dashboard for simple and variable products.
- **new:** Commission details metabox on the order details page in the admin dashboard is now visible for child orders or orders without a parent.
- **new:** Related order metabox on the order details page in the admin dashboard, displaying sibling orders for child orders and child orders for parent orders.
- **new:** Backward compatibility for flat, percentage, and combine commission types for older orders.
- **update:** Updated commission types from flat, percentage, and combine to fixed and category-based commissions.
- **update:** Overhauled the commission UI across Dokan global settings, vendor settings, product settings, Dokan subscription product settings, and the admin setup wizard.
- **update:** Updated the commission settings in the admin setup wizard.
- **update:** Enhanced responsiveness of the UI for Dokan admin dashboard settings menus.
- **update:** Product is rebranded with new branding.
- **update:** As per new branding of Dokan Multivendor Plugin, full product is rebranded with new theme color.
- **fix:** Moved the vendor edit page from Dokan Pro to Dokan Lite and eliminated the commission setting from the WordPress default user profile page.
- **fix:** Removed the commission from every category, introducing category-based commission in global settings, vendor settings, Dokan subscription products, and the admin setup wizard.
-
### v3.13.1 ( Nov 11, 2024 ) ###

- **update:** Compatibility with the Printful Integration Module added.
Expand Down
24 changes: 5 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
**Requires at least:** 6.5
**Tested up to:** 6.7.1
**WC requires at least:** 8.0.0
**WC tested up to:** 9.4.3
**WC tested up to:** 9.5.1
**Requires PHP:** 7.4
**Stable tag:** 3.14.3
**Stable tag:** 3.14.4
**License:** GPLv2 or later
**License URI:** http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -346,6 +346,9 @@ A. Just install and activate the PRO version without deleting the free plugin. A


## Changelog ##
### v3.14.4 ( Dec 27, 2024 ) ###
- **fix:** Added tweaks to improve system stability and smoothness

### v3.14.3 ( Dec 11, 2024 ) ###
- **update:** Updated Dokan admin header to display current pro plan and version with upgrading option.

Expand All @@ -357,23 +360,6 @@ A. Just install and activate the PRO version without deleting the free plugin. A

- **fix:** Fixed a issue in the commission upgrader to deal with empty values for product and vendor.

### v3.14.0 ( Dec 02, 2024 ) ###

- **new:** Commission amount now displayed in the product list within the admin dashboard.
- **new:** Vendor earning amount displayed in the product list within the vendor dashboard.
- **new:** Vendor earning suggestions on the product add and edit pages in the vendor dashboard for simple and variable products.
- **new:** Commission details metabox on the order details page in the admin dashboard is now visible for child orders or orders without a parent.
- **new:** Related order metabox on the order details page in the admin dashboard, displaying sibling orders for child orders and child orders for parent orders.
- **new:** Backward compatibility for flat, percentage, and combine commission types for older orders.
- **update:** Updated commission types from flat, percentage, and combine to fixed and category-based commissions.
- **update:** Overhauled the commission UI across Dokan global settings, vendor settings, product settings, Dokan subscription product settings, and the admin setup wizard.
- **update:** Updated the commission settings in the admin setup wizard.
- **update:** Enhanced responsiveness of the UI for Dokan admin dashboard settings menus.
- **update:** Product is rebranded with new branding.
- **update:** As per new branding of Dokan Multivendor Plugin, full product is rebranded with new theme color.
- **fix:** Moved the vendor edit page from Dokan Pro to Dokan Lite and eliminated the commission setting from the WordPress default user profile page.
- **fix:** Removed the commission from every category, introducing category-based commission in global settings, vendor settings, Dokan subscription products, and the admin setup wizard.

[CHECK THE FULL CHANGELOG](https://github.com/getdokan/dokan/blob/develop/CHANGELOG.md).

## Upgrade Notice ##
Expand Down
271 changes: 271 additions & 0 deletions docs/api/api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,271 @@
# Dokan REST Controllers Documentation

- [Introduction](#introduction)
- [Base REST Controller](#base-rest-controller)
- [1. Role-Specific Controllers.](#1-role-specifix-controllers)
- [Admin REST Controller.](#admin-rest-controller)
- [Vendor REST Controller.](#vendor-rest-controller)
- [Customer REST Controller.](#customer-rest-controller)

## Introduction
The Dokan REST Controllers provide a structured approach to handle REST API endpoints with role-based permissions. The hierarchy consists of a base controller (`DokanRESTBaseController`) and role-specific controllers (`DokanRESTAdminController`, `DokanRESTVendorController`, `DokanRESTCustomerController`).

## Base REST Controller
The `DokanRESTBaseController` extends WordPress's `WP_REST_Controller` and provides common functionality for all Dokan REST endpoints.

### Base Controller Implementation
```php
abstract class DokanRESTBaseController extends WP_REST_Controller {
protected $namespace = 'dokan/v1';

public function format_collection_response( $response, $request, $total_items ) {
// Handles pagination and response formatting
}
}
```

## Role-Specific Controllers

### Admin REST Controller Implementation

```php
abstract class DokanRESTAdminController extends DokanRESTBaseController {
protected $namespace = 'dokan/v1/admin';

public function check_permission() {
return current_user_can( 'manage_woocommerce' );
}
}
```

### How to extend the Admin REST Controller

```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 get_items( $request ) {
$items = []; // Your implementation
$total = count( $items );

$response = rest_ensure_response( $items );
return $this->format_collection_response( $response, $request, $total );
}
}
```

### 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' );
}

public function get_items( $request ) {
$items = []; // Your implementation
$total = count( $items );

$response = rest_ensure_response( $items );
return $this->format_collection_response( $response, $request, $total );
}
}
```

### Vendor REST Controller Implementation

```php
abstract class DokanRESTVendorController extends DokanRESTBaseController {
protected $rest_base = 'vendor';

public function check_permission() {
return current_user_can( 'dokandar' );
}
}
```

### How to extend the Vendor REST Controller

```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(),
]
]
);
}

public function get_items( $request ) {
$items = []; // Your implementation
$total = count( $items );

$response = rest_ensure_response( $items );
return $this->format_collection_response( $response, $request, $total );
}
}
```

### 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';

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 );
}
}
```

### Customer REST Controller Implementation

```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

```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 get_items( $request ) {
$items = []; // Your implementation
$total = count( $items );

$response = rest_ensure_response( $items );
return $this->format_collection_response( $response, $request, $total );
}
}
```

### Override Customer REST Controller permission

```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() );;
}

public function get_items( $request ) {
$items = []; // Your implementation
$total = count( $items );

$response = rest_ensure_response( $items );
return $this->format_collection_response( $response, $request, $total );
}
}
```
3 changes: 2 additions & 1 deletion dokan-class.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* @class WeDevs_Dokan The class that holds the entire WeDevs_Dokan plugin
*
* @property WeDevs\Dokan\Commission $commission Instance of Commission class
* @property WeDevs\Dokan\Fees $fees Instance of Fees class
* @property WeDevs\Dokan\Order\Manager $order Instance of Order Manager class
* @property WeDevs\Dokan\Product\Manager $product Instance of Order Manager class
* @property WeDevs\Dokan\Vendor\Manager $vendor Instance of Vendor Manager Class
Expand All @@ -23,7 +24,7 @@ final class WeDevs_Dokan {
*
* @var string
*/
public $version = '3.14.3';
public $version = '3.14.4';

/**
* Instance of self
Expand Down
4 changes: 2 additions & 2 deletions dokan.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.3
* Version: 3.14.4
* Author: weDevs
* Author URI: https://dokan.co/
* Text Domain: dokan-lite
* Requires Plugins: woocommerce
* WC requires at least: 8.0.0
* WC tested up to: 9.4.2
* WC tested up to: 9.5.1
* Domain Path: /languages/
* License: GPL2
*/
Expand Down
Loading

0 comments on commit 56488ae

Please sign in to comment.