Skip to content

Commit 0d57ee3

Browse files
committed
Remove the "preserve order item cost" change added in 61307
This actually prevents the recalculation of order costs on order save. To be rethought and maybe readded later if necessary.
1 parent 65e0d2c commit 0d57ee3

File tree

1 file changed

+0
-12
lines changed

1 file changed

+0
-12
lines changed

plugins/woocommerce/includes/class-wc-order-item-product.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -562,18 +562,6 @@ public function has_cogs(): bool {
562562
* @return float|null The calculated value, null if the product associated to the line item no longer exists.
563563
*/
564564
public function calculate_cogs_value_core(): ?float {
565-
// Refund items should always recalculate based on their (negative) quantity.
566-
// Preserving would give incorrect values since they're cloned from original items.
567-
$is_refund_item = $this->get_quantity() < 0;
568-
569-
// If this is a regular item (not refund) that has been loaded from the database and has a saved COGS value, preserve it.
570-
// COGS values should be "snapshotted" at order creation time, not recalculated later.
571-
// This prevents historical orders from having their costs changed when product prices are updated.
572-
// Note: cogs_value will be null if the item was loaded but had no _cogs_value metadata.
573-
if ( ! $is_refund_item && $this->get_id() > 0 && $this->get_object_read() && isset( $this->data['cogs_value'] ) && ! is_null( $this->data['cogs_value'] ) ) {
574-
return $this->get_cogs_value( 'edit' );
575-
}
576-
577565
// For new items, refund items, or items without saved COGS, calculate from the product.
578566
$product = $this->get_product();
579567
if ( ! $product ) {

0 commit comments

Comments
 (0)