5 Commits

Author SHA1 Message Date
wpdev ad3f604321 Merge pull request 'release 0.3.1: 2meet-data-optimizer-woocommerce-addon' (#5) from release/0.3.1 into main
Tests / PHP Lint (push) Successful in 10s
Tests / Unit Tests (push) Successful in 1m4s
Tests / Integration Tests (push) Successful in 2m17s
2026-10-02 20:48:58 +08:00
wpdev 5d13f70f16 chore(2meet-data-optimizer-woocommerce-addon): 0.3.1 repackage (no functional change)
Tests / PHP Lint (pull_request) Successful in 8s
Tests / Unit Tests (pull_request) Successful in 1m0s
Tests / Integration Tests (pull_request) Successful in 1m40s
Version bump for a re-release packaged alongside the WP-MVB v8 hub (dev39)
acceptance; code is identical to the previous release.
2026-10-02 17:23:22 +08:00
wpdev 4d3d1774b6 Merge pull request 'hardening 2.3: 2meet-data-optimizer-woocommerce-addon 0.3.0 (commissions follow refunds)' (#4) from hardening/2.3 into main
Tests / PHP Lint (push) Successful in 7s
Tests / Unit Tests (push) Successful in 1m6s
Tests / Integration Tests (push) Successful in 2m2s
2026-09-27 18:37:29 +08:00
wpdev d9d3556579 docs(2meet-data-optimizer-woocommerce-addon): add PR-112 to the 0.3.0 release notes
Tests / PHP Lint (pull_request) Successful in 16s
Tests / Unit Tests (pull_request) Successful in 1m31s
Tests / Integration Tests (pull_request) Successful in 1m57s
- PR: PR-103 (follow-up)
2026-09-27 17:34:19 +08:00
wpdev c2bd02e9ec fix(2meet-data-optimizer-woocommerce-addon): record no negative commission for a fully refunded taxed order
- the amounts follow Marketplace::get_order_profit() (what the vendor is
  paid), which subtracts the full order tax after refunds; a fully refunded
  taxed order came out at subtotal = commission = -tax. The subtotal is now
  floored at 0 (security review M2); partial refunds keep matching what
  Marketplace pays
- Verify: WCOrdersInterceptorTest (full refund with tax), integration 28, unit 11, phpcs
- PR: PR-112 (2.3 acceptance security review)
2026-09-27 17:23:31 +08:00
4 changed files with 34 additions and 2 deletions
+2 -2
View File
@@ -3,7 +3,7 @@
* Plugin Name: 2meet Data Optimizer — Woocommerce AddOn * Plugin Name: 2meet Data Optimizer — Woocommerce AddOn
* Plugin URI: https://2meet.io/2meet-data-optimizer/woocommerce * Plugin URI: https://2meet.io/2meet-data-optimizer/woocommerce
* Description: WooCommerce 整合:20 表 schema 註冊 + commission tracking (wp_wpdo_wc_commissions) + product/order zone + HPOS notice * Description: WooCommerce 整合:20 表 schema 註冊 + commission tracking (wp_wpdo_wc_commissions) + product/order zone + HPOS notice
* Version: 0.3.0 * Version: 0.3.1
* Requires at least: 6.0 * Requires at least: 6.0
* Tested up to: 6.9.4 * Tested up to: 6.9.4
* Requires PHP: 8.1 * Requires PHP: 8.1
@@ -24,7 +24,7 @@ if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
} }
define( 'TMDO_WOOCOMMERCE_VERSION', '0.3.0' ); define( 'TMDO_WOOCOMMERCE_VERSION', '0.3.1' );
define( 'TMDO_WOOCOMMERCE_PATH', plugin_dir_path( __FILE__ ) ); define( 'TMDO_WOOCOMMERCE_PATH', plugin_dir_path( __FILE__ ) );
define( 'TMDO_WOOCOMMERCE_URL', plugin_dir_url( __FILE__ ) ); define( 'TMDO_WOOCOMMERCE_URL', plugin_dir_url( __FILE__ ) );
define( 'TMDO_WOOCOMMERCE_FILE', __FILE__ ); define( 'TMDO_WOOCOMMERCE_FILE', __FILE__ );
+11
View File
@@ -11,6 +11,13 @@ Versioning follows [Semantic Versioning](https://semver.org/).
--- ---
## [0.3.1] — 2026-10-02 — 重新打包
### Changed
- 重新打包(無功能變更):與 WP-MVB v8 樞紐站(dev39)一同驗收後發版;程式碼與前一版相同。
---
## [0.3.0] — 2026-09-27 ## [0.3.0] — 2026-09-27
Released with 2meet-data-optimizer 1.3.0 (hardening 2.3). Released with 2meet-data-optimizer 1.3.0 (hardening 2.3).
@@ -26,6 +33,10 @@ Released with 2meet-data-optimizer 1.3.0 (hardening 2.3).
status `refunded`; untracked orders get none). Repeated events still leave status `refunded`; untracked orders get none). Repeated events still leave
one row per order and vendor. dev36: partial refund then completion records one row per order and vendor. dev36: partial refund then completion records
the refunded amount. (PR-092) the refunded amount. (PR-092)
- Amounts follow Marketplace::get_order_profit() (what the vendor is paid,
which subtracts the full tax after refunds); the subtotal is floored at 0,
so a fully refunded taxed order no longer records a negative commission.
(PR-112)
### Upgrading ### Upgrading
@@ -149,6 +149,10 @@ class TMDO_WC_Orders_Interceptor extends TMDO_Interceptor_Base {
if ( ! get_option( 'hp_vendor_include_taxes' ) ) { if ( ! get_option( 'hp_vendor_include_taxes' ) ) {
$subtotal -= (float) $order->get_total_tax(); $subtotal -= (float) $order->get_total_tax();
} }
// Marketplace subtracts the full tax even after a refund; a fully
// refunded taxed order would otherwise record a negative amount.
$subtotal = max( 0.0, $subtotal );
$vendor_payout = max( 0.0, $subtotal * $vendor_share - $fee ); $vendor_payout = max( 0.0, $subtotal * $vendor_share - $fee );
$commission = $subtotal - $vendor_payout; $commission = $subtotal - $vendor_payout;
$commission_rate = round( ( 1 - $vendor_share ) * 100, 2 ); // Platform percentage, as set in Marketplace. $commission_rate = round( ( 1 - $vendor_share ) * 100, 2 ); // Platform percentage, as set in Marketplace.
@@ -204,6 +204,23 @@ class WCOrdersInterceptorTest extends TestCase {
$this->assertEqualsWithDelta( 0.0, (float) $row['vendor_payout'], 0.0001 ); $this->assertEqualsWithDelta( 0.0, (float) $row['vendor_payout'], 0.0001 );
} }
/**
* Amounts follow Marketplace::get_order_profit() (what the vendor is paid,
* which subtracts the full tax after refunds), but a fully refunded taxed
* order must not record a negative subtotal or commission.
*/
public function test_a_fully_refunded_taxed_order_records_no_negative_amounts(): void {
$this->place_order( $this->marketplace_meta(), 110.0, 10.0 );
$this->refund( 110.0, 'refunded' );
( new TMDO_WC_Orders_Interceptor() )->action_order_refunded( self::ORDER_ID, 1 );
$row = $this->commission_row();
$this->assertEqualsWithDelta( 0.0, (float) $row['subtotal'], 0.0001 );
$this->assertEqualsWithDelta( 0.0, (float) $row['commission'], 0.0001 );
$this->assertEqualsWithDelta( 0.0, (float) $row['vendor_payout'], 0.0001 );
}
public function test_a_refund_of_an_untracked_order_records_nothing(): void { public function test_a_refund_of_an_untracked_order_records_nothing(): void {
$this->refund( 50.0, 'pending' ); $this->refund( 50.0, 'pending' );