Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Enhancement: Make analytics reports compatible with Dokan #2318

Open
wants to merge 78 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 75 commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
b65555e
refactor: separate test directory for PHP and add factories
mrabbani Jun 27, 2024
4ee1255
Add docs for factories
mrabbani Jun 27, 2024
f0b44e1
Update docs for test running instruction
mrabbani Jun 27, 2024
bab8fbf
Fix formating
mrabbani Jun 27, 2024
0d9fb9d
refactor: folder structure for PSR4.
mrabbani Jun 28, 2024
2e22dd9
Fix composer autoload for test cases
mrabbani Jun 28, 2024
93a59aa
Fix test auto loading
mrabbani Jun 28, 2024
e271396
refactor: Simplify the shipping item attributes settings
mrabbani Jun 29, 2024
f9508ed
Add docblock to DBAssertionTrait
mrabbani Jun 29, 2024
2094ee5
Implement league container to swap Dokan curent container
mrabbani Jul 6, 2024
3cd5383
Implement queue handling
mrabbani Jul 9, 2024
36e71ca
Seperate file for WeDevs_Dokan class
mrabbani Jul 9, 2024
1856d99
Update Docblocks
mrabbani Jul 9, 2024
5691487
Fix get & post request methods
mrabbani Jul 10, 2024
b41df65
Merge branch 'chore/tdd' into enhancement/analytics-reports
mrabbani Jul 10, 2024
6a8ea9e
Apply conditions on Query
mrabbani Jul 10, 2024
6f110e9
Add FilterQuery class
mrabbani Jul 10, 2024
b00222e
Add brain monkey for mocking
mrabbani Jul 10, 2024
d173d2a
Merge branch 'chore/tdd-integrate-brain-monkey' into enhancement/anal…
mrabbani Jul 10, 2024
840d5dd
Add test cases for ScheduleListener and FilteQuery of dokan_order_stats
mrabbani Jul 11, 2024
e876902
Add PHPUnit data provider method for dokan_multi_vendor_order
mrabbani Jul 11, 2024
1c23196
Merge branch 'chore/tdd' into enhancement/analytics-reports
mrabbani Jul 11, 2024
e554aa7
Add test cases for order stats
mrabbani Jul 11, 2024
ce2a6e2
Add create_multi_vendor_order method to DokanUnitTestCase
mrabbani Jul 11, 2024
07a7362
Merge branch 'chore/tdd' into enhancement/analytics-reports
mrabbani Jul 11, 2024
9feebd1
Update test cases
mrabbani Jul 11, 2024
81af1ca
Check isset seller_id index
mrabbani Jul 11, 2024
cd6a0f6
Merge branch 'chore/tdd' into enhancement/analytics-reports
mrabbani Jul 11, 2024
6698ac0
Remove dokan data retantion
mrabbani Jul 11, 2024
9e80742
Merge branch 'chore/tdd' into enhancement/analytics-reports
mrabbani Jul 11, 2024
b8fa691
Use default data only when given data is empty for multi vendor order
mrabbani Jul 13, 2024
563f378
Add docs for TDD
mrabbani Jul 14, 2024
680faff
Update docs style
mrabbani Jul 14, 2024
41f24ff
Fix the ref in Docs
mrabbani Jul 14, 2024
1374d98
Add unit test only props
mrabbani Jul 14, 2024
05695f0
Update docs
mrabbani Jul 17, 2024
e0f2557
Fix prop name
mrabbani Jul 17, 2024
7a0428c
Merge with chore/tdd
mrabbani Jul 17, 2024
f3ee898
Fix base test class
mrabbani Jul 21, 2024
67898c5
Rename col is_sub_order to order_type
mrabbani Jul 21, 2024
b42cfc9
Add method to get order type
mrabbani Jul 22, 2024
6b91a8d
Apply Dokan stats conditions for Orders analytics
mrabbani Jul 25, 2024
5a889db
Inroduce Single vendor order refund type
mrabbani Jul 27, 2024
9c2a5d4
Add where clause for refund
mrabbani Jul 27, 2024
7e18fd4
Add base query filter
mrabbani Jul 27, 2024
f53868a
Add query for condition for products analutics
mrabbani Jul 27, 2024
a9ccb38
Merge with devleop
mrabbani Aug 9, 2024
29d6e12
Add test cases for Product analytics
mrabbani Aug 9, 2024
b08b12a
Implement categories, variations and product segmenters reports
mrabbani Aug 12, 2024
a70e159
Implement tax report
mrabbani Aug 13, 2024
bf5b2ef
Add docblocks
mrabbani Aug 13, 2024
4c82265
Refactor and add docblocks
mrabbani Aug 13, 2024
d7b5c23
Add group for analytics test cases
mrabbani Aug 13, 2024
2e2c716
Merge branch 'develop' into enhancement/analytics-reports
mrabbani Aug 13, 2024
32ac352
Alter WC order stats data store
mrabbani Aug 13, 2024
992fcf3
Remove error log for debug
mrabbani Aug 13, 2024
16de598
Merge with develop
mrabbani Aug 15, 2024
707259d
Implement coupons report only based on WC Order only
mrabbani Aug 15, 2024
18cd21a
Fix plugin activation hooks
mrabbani Aug 16, 2024
524c5f5
Add vendor hooks
mrabbani Aug 16, 2024
97c3b32
Apply condition on SELECT clause to show coupon data against Dokan Su…
mrabbani Aug 19, 2024
f4e3118
Implement customer analynics report
mrabbani Aug 19, 2024
afaa5bd
Update docs
mrabbani Aug 20, 2024
0176baf
Merge branch 'refactor/introduce-container' into enhancement/analytic…
mrabbani Aug 20, 2024
d3fa0f1
Add seller filter
mrabbani Aug 25, 2024
7366a46
Update query param name for seller filter
mrabbani Aug 29, 2024
9a2878c
Implement stock report product filter for seller
mrabbani Aug 30, 2024
2c05bf0
Change accessibility to get seller id
mrabbani Aug 30, 2024
30bc3c4
Implement stock stats report to filter by seller
mrabbani Aug 30, 2024
6f13a6e
Fix typo
mrabbani Aug 30, 2024
c30f6aa
Prevent the removal of child order insertion in WC order stats table
mrabbani Oct 2, 2024
0bb18ad
Pass valid filter param
mrabbani Oct 2, 2024
c7e04b0
Insert dokan stats data from the Order
mrabbani Oct 2, 2024
768e909
Add col for shipping fee in dokan stats
mrabbani Oct 2, 2024
0d84346
Create dokan order stats table if not exists
mrabbani Oct 3, 2024
67443f3
Add Analytics Migrations
mrabbani Oct 3, 2024
5a818a6
Update comment for ordery_type table column
mrabbani Oct 3, 2024
4b2e85f
Remove auto table creation
mrabbani Oct 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
},
"autoload": {
"psr-4": {
"WeDevs\\Dokan\\": "includes/"
"WeDevs\\Dokan\\": "includes/",
"WeDevs\\Dokan\\ThirdParty\\Packages\\": "lib/packages/"
},
"files": [
"includes/functions-rest-api.php",
Expand Down
19 changes: 19 additions & 0 deletions docs/analytics/reports.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
- [Introduction](#introduction)
- [Custom Products Stats Datastore](#custom-products-stats-datastore)
Copy link
Contributor

Choose a reason for hiding this comment

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

Fix the link fragment in the table of contents.

The link fragment for "Custom Products Stats Datastore" should match the section heading.

- [Custom Products Stats Datastore](#custom-products-stats-datastore)
+ [Custom Stats Datastore](#custom-stats-datastore)
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- [Custom Products Stats Datastore](#custom-products-stats-datastore)
[Custom Stats Datastore](#custom-stats-datastore)
Tools
Markdownlint

2-2: null
Link fragments should be valid

(MD051, link-fragments)


## Introduction
To handle **Dokan Orders**, we followed the [WooCommerce Admin Reports Extension Guidelines](https://github.com/woocommerce/woocommerce/blob/trunk/docs/reporting/extending-woocommerce-admin-reports.md#handle-currency-parameters-on-the-server).

## Custom Stats Datastore

We need to customize the default *WooCommerce Analytics Datastore* for some reports. For example, we replaced the [WC Products Stats DataStore](https://github.com/woocommerce/woocommerce/blob/9297409c5a705d1cd0ae65ec9b058271bd90851e/plugins/woocommerce/src/Admin/API/Reports/Products/Stats/DataStore.php#L170) with the [Dokan Product Stats Store](./../../includes/Analytics/Reports/Products/Stats/WcDataStore.php). This modification involves overriding the `$total_query` and `$interval_query` properties by substituting the `Automattic\WooCommerce\Admin\API\Reports\SqlQuery` class with `WeDevs\Dokan\Analytics\Reports\WcSqlQuery`.

The primary change was to update the `get_sql_clause( $type, $handling = 'unfiltered' )` method to `get_sql_clause( $type, $handling = '' )`, allowing us to apply necessary filters for adding JOIN and WHERE clauses to the `dokan_order_stats` table.

### Implementation Steps

- **Step 1:** Create the [WcSqlQuery](./../../includes/Analytics/Reports/DataStoreModifier.php) class to override the `get_sql_clause( $type, $handling = 'unfiltered' )` method from the [WC SqlQuery](https://github.com/woocommerce/woocommerce/blob/9297409c5a705d1cd0ae65ec9b058271bd90851e/plugins/woocommerce/src/Admin/API/Reports/SqlQuery.php#L87) class. The new method should use `get_sql_clause( $type, $handling = '' )`.

- **Step 2:** Implement the [WcDataStore](https://github.com/woocommerce/woocommerce/blob/9297409c5a705d1cd0ae65ec9b058271bd90851e/plugins/woocommerce/src/Admin/API/Reports/Products/Stats/DataStore.php#L170) class to set the `$total_query` and `$interval_query` properties with instance of **WcSqlQuery**.

- **Step 3:** Use the `woocommerce_data_stores` filter within the [DataStoreModifier](./../../includes/Analytics/Reports/DataStoreModifier.php) class to replace the default WooCommerce Products Stats datastore with the custom Dokan Product Stats Store.
2 changes: 1 addition & 1 deletion docs/tdd/get-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -301,4 +301,4 @@ $array = [
// Use the custom assertion method
$this->assertNestedContains( [ 'subkey1' => 'value1' ], $array );
$this->assertNestedContains( [ 'key2' => 'value3' ], $array );
```
```
Loading