Closed mralaminahamed closed 2 months ago
The changes enhance the on_order_status_change
method in the Hooks
class by implementing conditional checks for sub-order status updates. The new logic verifies if status transitions are allowed before updating sub-orders, preventing unwanted changes. Two new private methods are introduced for prefixing status strings and logging skipped updates, improving code clarity and maintainability.
File | Change Summary |
---|---|
includes/Order/Hooks.php |
Modified on_order_status_change method logic; added is_status_change_allowed , maybe_add_wc_prefix , and log_skipped_status_update methods. |
Objective | Addressed | Explanation |
---|---|---|
Ensure that suborders marked as canceled remain in that state (Issue #2341) | ✅ | |
Prevent incorrect status updates for suborders when the main order is completed (Issue #2341) | ✅ |
🐇 In the land of orders, hopping with glee,
Suborders now stay where they ought to be.
Canceled won't change when the main order's complete,
Logic's been added, making it neat!
So dance little rabbits, let status abide,
In the world of WooCommerce, we take pride! 🌼
[!TIP]
Early access features: enabled
We are currently testing the following features in early access: - **Anthropic Claude for code reviews**: The new model is designed to enhance code understanding and generation capabilities. We're excited to hear your feedback as we evaluate its performance. Note: - You can enable or disable early access features from the CodeRabbit UI or by updating the CodeRabbit configuration file. - Please join our [Discord Community](https://discord.com/invite/GsXnASn26c) to provide feedback and report issues. - OSS projects are currently opted into early access features by default.
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
All Submissions:
Changes proposed in this Pull Request:
This PR addresses an issue where sub-order statuses were being incorrectly updated when the main order status changed. Specifically, it prevents cancelled sub-orders from being marked as completed when the main order is completed.
Key changes:
is_status_change_allowed
method to validate status transitions.dokan_sub_order_status_update_whitelist
filter for customizable status transition rules.on_order_status_change
method to respect sub-order status constraints.Related Pull Request(s)
Closes
How to test the changes in this Pull Request:
Changelog entry
Fix: Prevent incorrect sub-order status updates
Previously, when a main order was marked as completed, all sub-orders would be automatically marked as completed, regardless of their current status. This could lead to cancelled sub-orders being incorrectly marked as completed. This PR implements a flexible system to validate status transitions, ensuring that sub-order statuses are updated correctly based on their current status and a configurable set of rules.
Before Changes
When a main order was marked as completed, all sub-orders, including cancelled ones, would be marked as completed.
After Changes
When a main order is marked as completed, sub-orders are only updated if the transition is allowed according to the defined rules. Cancelled sub-orders remain cancelled.
Feature Video (optional)
N/A
PR Self Review Checklist:
FOR PR REVIEWER ONLY:
Summary by CodeRabbit
New Features
Improvements