Skip to content

Conversation

@opr
Copy link
Contributor

@opr opr commented Dec 15, 2025

Changes proposed in this Pull Request:

In the admin order view when the total calculation is shown, discounts are named Coupon(s) which is not consistent with the email sent to customers where it is named Discount.

Also, negative fees are not shown in this calculation resulting in discrepencies when they are applied, meaning the Total (which is correct) does not actually match the sum of all the displayed components. Below is an example of an order with a £1 negative fee added.

image

The total sum of the components here adds up to £2.55 but the total is actually £1.55 because of the negative fee.

Closes WOOPLUG-5995
Closes #62386
Closes WOOPLUG-5989

Screenshots or screen recordings:

Before After
image image

How to test the changes in this Pull Request:

Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:

  1. Place an order using a coupon, then go to edit it in the admin
  2. You could use this one-liner to update the order: wp eval '$o = wc_get_order(123); $f = new WC_Order_Item_Fee(); $f->set_name("Test Discount"); $f->set_total(-1); $o->add_item($f); $o->calculate_totals(); $o->save();' (update the order ID)
  3. If the above doesn't work, put it in an mu-plugin and run it once.
  4. Ensure the entry for "Fees" is shown and that it contains the correct negative amount.
  5. Note, the fee name does not need to show in the subtotals section, as it is listed in the line items.
  6. Re-send both the "New order notification" email and "Send order details to customer" from the order actions panel on the sidebar:
image

View these emails and ensure the discounts for coupons show correctly, and that the negative fee, named "Test fee" is shown correctly.

Testing that has already taken place:

Milestone

Note: Check the box above to have the milestone automatically assigned when merged.
Alternatively (e.g. for point releases), manually assign the appropriate milestone.

Changelog entry

  • Automatically create a changelog entry from the details below.
  • This Pull Request does not require a changelog entry. (Comment required below)
Changelog Entry Details

Significance

  • Patch
  • Minor
  • Major

Type

  • Fix - Fixes an existing bug
  • Add - Adds functionality
  • Update - Update existing functionality
  • Dev - Development related task
  • Tweak - A minor adjustment to the codebase
  • Performance - Address performance issues
  • Enhancement - Improvement to existing functionality

Message

Changelog Entry Comment

Comment

@github-actions github-actions bot added the plugin: woocommerce Issues related to the WooCommerce Core plugin. label Dec 15, 2025
@opr opr force-pushed the wooplug-5995-2-display-issues-to-make-the-order-detail-page-synchronized branch from 7a5d309 to 9418513 Compare December 15, 2025 19:21
@opr opr added this to the 10.5.0 milestone Dec 15, 2025
@opr opr marked this pull request as ready for review December 15, 2025 21:00
@woocommercebot woocommercebot requested review from a team and straku and removed request for a team December 15, 2025 21:01
@github-actions
Copy link
Contributor

github-actions bot commented Dec 15, 2025

Testing Guidelines

Hi @straku ,

Apart from reviewing the code changes, please make sure to review the testing instructions (Guide) and verify that relevant tests (E2E, Unit, Integration, etc.) have been added or updated as needed.

Reminder: PR reviewers are required to document testing performed. This includes:

  • 🖼️ Screenshots or screen recordings.
  • 📝 List of functionality tested / steps followed.
  • 🌐 Site details (environment attributes such as hosting type, plugins, theme, store size, store age, and relevant settings).
  • 🔍 Any analysis performed, such as assessing potential impacts on environment attributes and other plugins, conducting performance profiling, or using LLM/AI-based analysis.

⚠️ Within the testing details you provide, please ensure that no sensitive information (such as API keys, passwords, user data, etc.) is included in this public issue.

@github-actions github-actions bot added the focus: e2e tests Issues related to e2e tests label Dec 15, 2025
Copy link

@claude claude bot left a comment

Choose a reason for hiding this comment

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

🤖 Backwards Compatibility Review - Found 2 potential issues

Generated by Claude via this workflow run

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 15, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

📝 Walkthrough

Walkthrough

This PR fixes the handling of discount fees in WooCommerce orders. The admin order view label is changed from "Coupon(s):" to "Discount:", the fee display logic is updated to handle negative fees using an absolute value comparison, and new unit tests are added to verify negative fee calculations.

Changes

Cohort / File(s) Summary
Changelog entry
plugins/woocommerce/changelog/2025-12-15-17-18-50-141498
New changelog entry documenting patch fix for discount fees in order subtotal calculation
Admin order view
plugins/woocommerce/includes/admin/meta-boxes/views/html-order-items.php
Display label changed from "Coupon(s):" to "Discount:"; fee visibility condition updated from 0 < $order->get_total_fees() to abs( $order->get_total_fees() ) > 0 to handle negative fees
E2E tests
plugins/woocommerce/tests/e2e-pw/tests/order/order-coupon.spec.js
Test selectors updated to query cells with label "Discount:" instead of "Coupon(s):" in two coupon-related assertions
Unit tests
plugins/woocommerce/tests/legacy/unit-tests/order/class-wc-tests-crud-orders.php
Two new test methods added: test_get_total_fees_should_return_negative_fees and test_get_total_fees_should_sum_mixed_positive_and_negative_fees to verify fee calculations with negative values

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Admin view fee condition: Verify the logic change from strict positive check to absolute value comparison correctly handles both positive and negative fee scenarios
  • Label consistency: Ensure "Discount:" label aligns with the updated test selectors across the codebase
  • Unit test coverage: Confirm new tests adequately cover negative and mixed fee scenarios for the get_total_fees() method

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the two main changes: renaming the display label from 'Coupon(s)' to 'Discount' and ensuring negative fees are reflected in order details.
Linked Issues check ✅ Passed The PR addresses all objectives from issue #62386: fixing display of negative fees in the admin totals box and updating the label from 'Coupon(s)' to 'Discount' for consistency with emails.
Out of Scope Changes check ✅ Passed All code changes are directly related to the linked issue objectives: updating the display label, modifying the condition for showing fees to include negative amounts, and adding tests to verify the fee handling.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description check ✅ Passed The PR description clearly describes the problem (negative fees not displayed, inconsistent labeling) and solution (show negative fees, change 'Coupon(s)' to 'Discount'), with testing instructions and before/after screenshots.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch wooplug-5995-2-display-issues-to-make-the-order-detail-page-synchronized

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
plugins/woocommerce/changelog/2025-12-15-17-18-50-141498 (1)

1-4: Clarify the changelog message for accuracy.

The message states fees are "included in the order subtotal calculation," but the actual fix is about display, not calculation. The get_total_fees() method already correctly sums negative fees—the issue was that the admin UI condition 0 < $order->get_total_fees() prevented negative fees from rendering.

Consider revising to:

-Ensure discount fees are included in the order subtotal calculation on the admin order view
+Ensure negative fees are displayed in the order totals on the admin order view
📜 Review details

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 953c595 and 9418513.

📒 Files selected for processing (4)
  • plugins/woocommerce/changelog/2025-12-15-17-18-50-141498 (1 hunks)
  • plugins/woocommerce/includes/admin/meta-boxes/views/html-order-items.php (1 hunks)
  • plugins/woocommerce/tests/e2e-pw/tests/order/order-coupon.spec.js (2 hunks)
  • plugins/woocommerce/tests/legacy/unit-tests/order/class-wc-tests-crud-orders.php (1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{php,js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/avoid-regex.mdc)

**/*.{php,js,jsx,ts,tsx}: Avoid regular expressions in favor of more readable and maintainable alternatives, only using regex when no built-in alternative exists, performance is critical, the pattern is complex and well-documented, or maintaining legacy code
Document regular expressions extensively by explaining what the pattern matches, using named groups to improve readability, and adding comprehensive tests for edge cases and security issues
Validate regex input first and consider security implications such as ReDoS (Regular Expression Denial of Service) attacks and injection vulnerabilities when using regular expressions

Files:

  • plugins/woocommerce/tests/legacy/unit-tests/order/class-wc-tests-crud-orders.php
  • plugins/woocommerce/tests/e2e-pw/tests/order/order-coupon.spec.js
  • plugins/woocommerce/includes/admin/meta-boxes/views/html-order-items.php
**/*.{php,js,jsx,tsx,ts}

📄 CodeRabbit inference engine (.cursor/rules/code-quality.mdc)

**/*.{php,js,jsx,tsx,ts}: Guard all code against unexpected inputs
Sanitize and validate any potentially dangerous inputs
Ensure code is backwards compatible
Ensure code is readable and intuitive
Add unit or E2E tests where applicable

Files:

  • plugins/woocommerce/tests/legacy/unit-tests/order/class-wc-tests-crud-orders.php
  • plugins/woocommerce/tests/e2e-pw/tests/order/order-coupon.spec.js
  • plugins/woocommerce/includes/admin/meta-boxes/views/html-order-items.php
plugins/woocommerce/tests/**/*.php

📄 CodeRabbit inference engine (.cursor/rules/woo-phpunit.mdc)

plugins/woocommerce/tests/**/*.php: All setUp() and tearDown() methods in WooCommerce PHPUnit test classes must be declared as public, not protected
All test methods in WooCommerce PHPUnit tests must be declared as public, not protected
Add declare( strict_types = 1 ); at the top of WooCommerce PHPUnit test files
WooCommerce PHPUnit test classes should extend WC_Unit_Test_Case and include proper class documentation

Files:

  • plugins/woocommerce/tests/legacy/unit-tests/order/class-wc-tests-crud-orders.php
**/*.{php,js,ts,jsx,tsx}

⚙️ CodeRabbit configuration file

**/*.{php,js,ts,jsx,tsx}: Don't trust that extension developers will follow the best practices, make sure the code:

  • Guards against unexpected inputs.
  • Sanitizes and validates any potentially dangerous inputs.
  • Is backwards compatible.
  • Is readable and intuitive.
  • Has unit or E2E tests where applicable.
    When making any changes to code that deletes or modifies orders/products/customer data, make sure that there are
    sufficient checks in place to prevent accidental data loss. As an example, if deleting a draft order, check that
    the order status is indeed draft or checkout-draft. Also think about whether race conditions could occur and
    delete orders that don't belong to the current customer. When in doubt, ask for clarification in the PR comments.

Files:

  • plugins/woocommerce/tests/legacy/unit-tests/order/class-wc-tests-crud-orders.php
  • plugins/woocommerce/tests/e2e-pw/tests/order/order-coupon.spec.js
  • plugins/woocommerce/includes/admin/meta-boxes/views/html-order-items.php
plugins/woocommerce/includes/**/*.php

📄 CodeRabbit inference engine (CLAUDE.md)

Legacy WordPress code in includes/ directory should be modified minimally and only when necessary

Files:

  • plugins/woocommerce/includes/admin/meta-boxes/views/html-order-items.php
🧠 Learnings (23)
📓 Common learnings
Learnt from: peterwilsoncc
Repo: woocommerce/woocommerce PR: 60447
File: plugins/woocommerce/templates/emails/email-order-details.php:96-131
Timestamp: 2025-10-23T01:44:03.397Z
Learning: In WooCommerce email templates (plugins/woocommerce/templates/emails/), when displaying order details, the order items table and order totals should be separate tables rather than combined with <tfoot>. This follows accessibility guidance: the totals are semantically different information from the line items and should not be forced into a single table structure just for visual positioning. The split improves accessibility for assistive technology users.
Learnt from: jamesckemp
Repo: woocommerce/woocommerce PR: 60816
File: plugins/woocommerce/includes/class-wc-post-types.php:485-492
Timestamp: 2025-09-12T13:24:41.207Z
Learning: In WooCommerce PR #60816, the shop_order post type registration correctly uses 'show_in_menu' => true to create a top-level Orders menu, moving away from the previous submenu structure under WooCommerce. This is intentional and aligns with the PR goal of promoting Orders to top-level navigation.
Learnt from: samueljseay
Repo: woocommerce/woocommerce PR: 58716
File: plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/iapi-frontend.ts:83-101
Timestamp: 2025-06-17T07:07:53.443Z
Learning: In WooCommerce blocks, when porting existing code patterns that have known issues (like parseInt truncating decimal money values), maintain consistency with existing implementation rather than making isolated fixes. The preference is for systematic refactoring approaches (like broader Dinero adoption) over piecemeal changes.
Learnt from: nerrad
Repo: woocommerce/woocommerce PR: 60176
File: plugins/woocommerce/client/legacy/css/admin.scss:9088-9105
Timestamp: 2025-08-04T00:21:51.440Z
Learning: WooCommerce is currently in the midst of an admin redesign project, so temporary/short-term CSS solutions for admin pages are preferred over long-term refactoring when addressing immediate needs.
📚 Learning: 2025-10-23T01:44:03.397Z
Learnt from: peterwilsoncc
Repo: woocommerce/woocommerce PR: 60447
File: plugins/woocommerce/templates/emails/email-order-details.php:96-131
Timestamp: 2025-10-23T01:44:03.397Z
Learning: In WooCommerce email templates (plugins/woocommerce/templates/emails/), when displaying order details, the order items table and order totals should be separate tables rather than combined with <tfoot>. This follows accessibility guidance: the totals are semantically different information from the line items and should not be forced into a single table structure just for visual positioning. The split improves accessibility for assistive technology users.

Applied to files:

  • plugins/woocommerce/changelog/2025-12-15-17-18-50-141498
  • plugins/woocommerce/includes/admin/meta-boxes/views/html-order-items.php
📚 Learning: 2025-07-15T15:39:21.856Z
Learnt from: jorgeatorres
Repo: woocommerce/woocommerce PR: 59675
File: .github/workflows/release-bump-as-requirement.yml:48-65
Timestamp: 2025-07-15T15:39:21.856Z
Learning: In WooCommerce core repository, changelog entries for all PRs live in `plugins/woocommerce/changelog/` directory and are processed during releases, not at the repository root level.

Applied to files:

  • plugins/woocommerce/changelog/2025-12-15-17-18-50-141498
📚 Learning: 2025-11-24T16:14:26.363Z
Learnt from: CR
Repo: woocommerce/woocommerce PR: 0
File: plugins/woocommerce/tests/php/src/CLAUDE.md:0-0
Timestamp: 2025-11-24T16:14:26.363Z
Learning: Applies to plugins/woocommerce/tests/php/src/tests/**/*Test.php : Test behavior and interfaces, not implementation details, to ensure tests remain resilient when internal code changes

Applied to files:

  • plugins/woocommerce/tests/legacy/unit-tests/order/class-wc-tests-crud-orders.php
  • plugins/woocommerce/tests/e2e-pw/tests/order/order-coupon.spec.js
📚 Learning: 2025-11-24T16:14:26.363Z
Learnt from: CR
Repo: woocommerce/woocommerce PR: 0
File: plugins/woocommerce/tests/php/src/CLAUDE.md:0-0
Timestamp: 2025-11-24T16:14:26.363Z
Learning: Applies to plugins/woocommerce/tests/php/src/tests/**/*Test.php : Write one purpose per test - multiple assertions are acceptable if testing the same behavior, but avoid testing multiple unrelated behaviors in a single test method

Applied to files:

  • plugins/woocommerce/tests/legacy/unit-tests/order/class-wc-tests-crud-orders.php
📚 Learning: 2025-11-24T16:15:16.065Z
Learnt from: CR
Repo: woocommerce/woocommerce PR: 0
File: .cursor/rules/woo-phpunit.mdc:0-0
Timestamp: 2025-11-24T16:15:16.065Z
Learning: Applies to plugins/woocommerce/tests/**/*.php : All test methods in WooCommerce PHPUnit tests must be declared as `public`, not `protected`

Applied to files:

  • plugins/woocommerce/tests/legacy/unit-tests/order/class-wc-tests-crud-orders.php
📚 Learning: 2025-11-24T16:15:16.065Z
Learnt from: CR
Repo: woocommerce/woocommerce PR: 0
File: .cursor/rules/woo-phpunit.mdc:0-0
Timestamp: 2025-11-24T16:15:16.065Z
Learning: Applies to plugins/woocommerce/tests/**/*.php : WooCommerce PHPUnit test classes should extend `WC_Unit_Test_Case` and include proper class documentation

Applied to files:

  • plugins/woocommerce/tests/legacy/unit-tests/order/class-wc-tests-crud-orders.php
📚 Learning: 2025-11-24T16:14:26.363Z
Learnt from: CR
Repo: woocommerce/woocommerce PR: 0
File: plugins/woocommerce/tests/php/src/CLAUDE.md:0-0
Timestamp: 2025-11-24T16:14:26.363Z
Learning: Applies to plugins/woocommerce/tests/php/src/tests/**/*Test.php : Use setUp() and tearDown() methods to initialize test data and clean up resources, calling parent methods and resetting globals, deleted users, and other state

Applied to files:

  • plugins/woocommerce/tests/legacy/unit-tests/order/class-wc-tests-crud-orders.php
📚 Learning: 2025-11-24T16:15:16.065Z
Learnt from: CR
Repo: woocommerce/woocommerce PR: 0
File: .cursor/rules/woo-phpunit.mdc:0-0
Timestamp: 2025-11-24T16:15:16.065Z
Learning: Applies to plugins/woocommerce/tests/**/*.php : All setUp() and tearDown() methods in WooCommerce PHPUnit test classes must be declared as `public`, not `protected`

Applied to files:

  • plugins/woocommerce/tests/legacy/unit-tests/order/class-wc-tests-crud-orders.php
📚 Learning: 2025-11-24T16:14:26.363Z
Learnt from: CR
Repo: woocommerce/woocommerce PR: 0
File: plugins/woocommerce/tests/php/src/CLAUDE.md:0-0
Timestamp: 2025-11-24T16:14:26.363Z
Learning: Applies to plugins/woocommerce/tests/php/src/tests/**/*Test.php : Structure tests using the Arrange-Act-Assert pattern: set up test data and mocks in Arrange, execute code being tested in Act, and verify expected behavior in Assert

Applied to files:

  • plugins/woocommerce/tests/legacy/unit-tests/order/class-wc-tests-crud-orders.php
📚 Learning: 2025-11-24T16:14:26.363Z
Learnt from: CR
Repo: woocommerce/woocommerce PR: 0
File: plugins/woocommerce/tests/php/src/CLAUDE.md:0-0
Timestamp: 2025-11-24T16:14:26.363Z
Learning: Applies to plugins/woocommerce/tests/php/src/tests/**/*Test.php : Use resilient assertions that won't break when adjacent code changes or new keys are added to data structures

Applied to files:

  • plugins/woocommerce/tests/legacy/unit-tests/order/class-wc-tests-crud-orders.php
  • plugins/woocommerce/tests/e2e-pw/tests/order/order-coupon.spec.js
📚 Learning: 2025-11-24T16:14:26.363Z
Learnt from: CR
Repo: woocommerce/woocommerce PR: 0
File: plugins/woocommerce/tests/php/src/CLAUDE.md:0-0
Timestamp: 2025-11-24T16:14:26.363Z
Learning: Applies to plugins/woocommerce/tests/php/src/tests/**/*Test.php : Name test methods as test_{feature}_{scenario}() or test_{feature}_{scenario}_{outcome}() to clearly describe what is being tested

Applied to files:

  • plugins/woocommerce/tests/legacy/unit-tests/order/class-wc-tests-crud-orders.php
📚 Learning: 2025-11-24T16:14:26.363Z
Learnt from: CR
Repo: woocommerce/woocommerce PR: 0
File: plugins/woocommerce/tests/php/src/CLAUDE.md:0-0
Timestamp: 2025-11-24T16:14:26.363Z
Learning: Applies to plugins/woocommerce/tests/php/src/tests/**/*IntegrationTest.php : For WordPress hook tests, use add_filter() or add_action() within tests to verify that hooks fire correctly by setting flags or tracking calls

Applied to files:

  • plugins/woocommerce/tests/legacy/unit-tests/order/class-wc-tests-crud-orders.php
📚 Learning: 2025-11-24T16:13:56.953Z
Learnt from: CR
Repo: woocommerce/woocommerce PR: 0
File: plugins/woocommerce/client/admin/client/settings-payments/CLAUDE.md:0-0
Timestamp: 2025-11-24T16:13:56.953Z
Learning: Applies to plugins/woocommerce/client/admin/client/settings-payments/client/settings-payments/components/**/test/*.test.tsx : Test names must accurately describe what the test actually verifies, not what you wish they verified (e.g., describe actual verification performed, not presumed prop passing without mock inspection)

Applied to files:

  • plugins/woocommerce/tests/e2e-pw/tests/order/order-coupon.spec.js
📚 Learning: 2025-11-24T16:13:56.953Z
Learnt from: CR
Repo: woocommerce/woocommerce PR: 0
File: plugins/woocommerce/client/admin/client/settings-payments/CLAUDE.md:0-0
Timestamp: 2025-11-24T16:13:56.953Z
Learning: Applies to plugins/woocommerce/client/admin/client/settings-payments/packages/js/data/src/payment-settings/test/helpers/stub.ts : Update test stubs when modifying payment gateway features: `packages/js/data/src/payment-settings/test/helpers/stub.ts`

Applied to files:

  • plugins/woocommerce/tests/e2e-pw/tests/order/order-coupon.spec.js
📚 Learning: 2025-11-11T11:03:44.571Z
Learnt from: opr
Repo: woocommerce/woocommerce PR: 61507
File: plugins/woocommerce/tests/php/includes/rest-api/Controllers/Version4/Customers/class-wc-rest-customers-v4-controller-tests.php:638-638
Timestamp: 2025-11-11T11:03:44.571Z
Learning: In WooCommerce test files (plugins/woocommerce/tests/**/*.php), prefer explicit count assertions over scoping tests with parameters like `include` when testing pagination and default behaviors. Explicit counts test the specifics more reliably and help catch edge cases.

Applied to files:

  • plugins/woocommerce/tests/e2e-pw/tests/order/order-coupon.spec.js
📚 Learning: 2025-11-24T16:13:56.953Z
Learnt from: CR
Repo: woocommerce/woocommerce PR: 0
File: plugins/woocommerce/client/admin/client/settings-payments/CLAUDE.md:0-0
Timestamp: 2025-11-24T16:13:56.953Z
Learning: Applies to plugins/woocommerce/client/admin/client/settings-payments/client/settings-payments/components/**/test/*.test.tsx : Include edge case tests for defensive coding: test missing optional fields (undefined icon), undefined nested objects (supports array), invalid state combinations, and conflicting boolean flags

Applied to files:

  • plugins/woocommerce/tests/e2e-pw/tests/order/order-coupon.spec.js
📚 Learning: 2025-11-24T16:13:34.861Z
Learnt from: CR
Repo: woocommerce/woocommerce PR: 0
File: plugins/woocommerce/client/admin/CLAUDE.md:0-0
Timestamp: 2025-11-24T16:13:34.861Z
Learning: Applies to plugins/woocommerce/client/admin/**/*.test.{ts,tsx} : Generate coverage reports using `pnpm run test:js -- --coverage` to identify untested code paths

Applied to files:

  • plugins/woocommerce/tests/e2e-pw/tests/order/order-coupon.spec.js
📚 Learning: 2025-11-24T16:13:56.953Z
Learnt from: CR
Repo: woocommerce/woocommerce PR: 0
File: plugins/woocommerce/client/admin/client/settings-payments/CLAUDE.md:0-0
Timestamp: 2025-11-24T16:13:56.953Z
Learning: Applies to plugins/woocommerce/client/admin/client/settings-payments/client/settings-payments/components/**/test/*.test.tsx : Group component tests by concern using describe blocks: Basic Rendering, Status Badge Rendering, Button Rendering, Props Handling

Applied to files:

  • plugins/woocommerce/tests/e2e-pw/tests/order/order-coupon.spec.js
📚 Learning: 2025-11-24T16:13:56.953Z
Learnt from: CR
Repo: woocommerce/woocommerce PR: 0
File: plugins/woocommerce/client/admin/client/settings-payments/CLAUDE.md:0-0
Timestamp: 2025-11-24T16:13:56.953Z
Learning: Applies to plugins/woocommerce/client/admin/client/settings-payments/client/settings-payments/components/**/test/*.test.tsx : Component test files must follow the pattern: `components/[component-name]/test/[component-name].test.tsx`

Applied to files:

  • plugins/woocommerce/tests/e2e-pw/tests/order/order-coupon.spec.js
📚 Learning: 2025-11-24T16:14:26.363Z
Learnt from: CR
Repo: woocommerce/woocommerce PR: 0
File: plugins/woocommerce/tests/php/src/CLAUDE.md:0-0
Timestamp: 2025-11-24T16:14:26.363Z
Learning: Applies to plugins/woocommerce/tests/php/src/tests/**/*Test.php : Use targeted assertions instead of full equality checks - break down array comparisons into individual assertions using assertArrayHasKey() and specific value assertions

Applied to files:

  • plugins/woocommerce/tests/e2e-pw/tests/order/order-coupon.spec.js
📚 Learning: 2025-11-24T16:13:34.861Z
Learnt from: CR
Repo: woocommerce/woocommerce PR: 0
File: plugins/woocommerce/client/admin/CLAUDE.md:0-0
Timestamp: 2025-11-24T16:13:34.861Z
Learning: Applies to plugins/woocommerce/client/admin/**/*.test.{ts,tsx} : Query DOM elements in React Testing Library tests using accessibility-first approach: prefer `getByRole`, then `getByLabelText`, then `getByText`, then `getByTitle` (in that priority order)

Applied to files:

  • plugins/woocommerce/tests/e2e-pw/tests/order/order-coupon.spec.js
📚 Learning: 2025-12-12T11:54:25.185Z
Learnt from: mikejolley
Repo: woocommerce/woocommerce PR: 62393
File: plugins/woocommerce/includes/class-wc-cart.php:1626-1635
Timestamp: 2025-12-12T11:54:25.185Z
Learning: In the WooCommerce plugin file plugins/woocommerce/includes/class-wc-cart.php (and related shipping code), keep package_id as a union type that accepts both int and string values to preserve backward compatibility with the REST API schema. Document that strict_types environments may raise TypeError if only strings are accepted, and consider testing REST payloads with mixed types. Do not convert to a strict string type; if downstream code relies on string methods, normalize at the boundary (e.g., coerce when reading from API) but do not change the API schema behavior.

Applied to files:

  • plugins/woocommerce/includes/admin/meta-boxes/views/html-order-items.php
🧬 Code graph analysis (2)
plugins/woocommerce/tests/legacy/unit-tests/order/class-wc-tests-crud-orders.php (1)
plugins/woocommerce/includes/abstracts/abstract-wc-order.php (1)
  • get_total_fees (1864-1872)
plugins/woocommerce/includes/admin/meta-boxes/views/html-order-items.php (1)
plugins/woocommerce/includes/abstracts/abstract-wc-order.php (3)
  • get_total_discount (510-517)
  • get_currency (341-343)
  • get_total_fees (1864-1872)
🔇 Additional comments (4)
plugins/woocommerce/tests/e2e-pw/tests/order/order-coupon.spec.js (1)

111-111: LGTM!

The label updates from "Coupon(s)" to "Discount:" correctly reflect the UI change in the admin order totals and maintain exact matching for reliable assertions.

Also applies to: 135-135

plugins/woocommerce/includes/admin/meta-boxes/views/html-order-items.php (2)

179-179: LGTM!

The label change from "Coupon(s):" to "Discount:" aligns with the PR objective to match the terminology used in customer emails and provides clearer, more consistent language across the order views.


186-186: Correct fix for displaying negative fees.

The condition change from 0 < $order->get_total_fees() to abs( $order->get_total_fees() ) > 0 properly enables display of both positive and negative fees while still hiding the row when the total is zero. The wc_price() function on line 191 correctly handles negative values.

plugins/woocommerce/tests/legacy/unit-tests/order/class-wc-tests-crud-orders.php (1)

2104-2143: LGTM!

The two new test methods provide good coverage for negative fee handling:

  • test_get_total_fees_should_return_negative_fees verifies single negative fee
  • test_get_total_fees_should_sum_mixed_positive_and_negative_fees verifies mixed positive/negative fee summation (25 - 10 + 5.50 = 20.50)

Both follow established patterns, use clear naming, and properly test the behavior that enables the admin UI fix.

@github-actions
Copy link
Contributor

Test using WordPress Playground

The changes in this pull request can be previewed and tested using a WordPress Playground instance.
WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Test this pull request with WordPress Playground.

Note that this URL is valid for 30 days from when this comment was last updated. You can update it by closing/reopening the PR or pushing a new commit.

Copy link
Contributor

@straku straku left a comment

Choose a reason for hiding this comment

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

Tests well, implementation is clear 👍

Claude is taking an extreme stance towards backward compatibility here 😅

@opr opr merged commit 73ebf60 into trunk Dec 17, 2025
148 of 152 checks passed
@opr opr deleted the wooplug-5995-2-display-issues-to-make-the-order-detail-page-synchronized branch December 17, 2025 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

focus: e2e tests Issues related to e2e tests plugin: woocommerce Issues related to the WooCommerce Core plugin.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants