You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When creating a manual order, I have a module that runs the validation function on the EVENT_BEFORE_SAVE event. When validation is run, it removes the tax adjustment from the line item.
Steps to reproduce
Event::on(
Order::class,
Order::EVENT_BEFORE_SAVE,
function (ModelEvent$event) {
if (Craft::$app->request->isCpRequest) {
$this->updateLineItemQuantity($event);
}
}
);
privatefunctionupdateLineItemQuantity($event): void
{
$order = $event->sender;
// this line removes tax adjuster from line item for some reason// stop here if the order has errors for the admin to fixif (!$order->validate()) return;
}
Create some required "order fields"
Load module code as above
Create new manual order
Add/input customer and add one line item that has a price excluding tax to the order (notice the tax adjustment figure/percentage below the line item is shown when added to the order)
Click "Update order", and notice how the tax line vanishes
Expected behaviour
Tax on line items to be persistent when validating an order for "errors"
Actual behavior
Tax line is not persistent when validating an order for "errors". Tax adjustment is not even in the line item snapshot.
Craft CMS version
4.5.13
Craft Commerce version
4.3.3
PHP version
No response
Operating system and version
No response
Database type and version
No response
Image driver and version
No response
Installed plugins and versions
The text was updated successfully, but these errors were encountered:
jonleverrier
changed the title
[4.x]: Validating an order removes tax from line item
[4.x]: validate() function removes tax from line item
Dec 19, 2023
jonleverrier
changed the title
[4.x]: validate() function removes tax from line item
[4.x]: validate() function removes tax adjustment from line item
Dec 21, 2023
What happened?
Description
When creating a manual order, I have a module that runs the
validation function
on theEVENT_BEFORE_SAVE
event. When validation is run, it removes the tax adjustment from the line item.Steps to reproduce
Expected behaviour
Tax on line items to be persistent when validating an order for "errors"
Actual behavior
Tax line is not persistent when validating an order for "errors". Tax adjustment is not even in the line item snapshot.
Craft CMS version
4.5.13
Craft Commerce version
4.3.3
PHP version
No response
Operating system and version
No response
Database type and version
No response
Image driver and version
No response
Installed plugins and versions
The text was updated successfully, but these errors were encountered: