Skip to content

Commit cb8af81

Browse files
committed
Issue #2833249 followup: AddToCartForm::buildEntity() doesn't respect overriden prices.
1 parent 5252922 commit cb8af81

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

modules/cart/src/Form/AddToCartForm.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,11 +224,13 @@ public function buildEntity(array $form, FormStateInterface $form_state) {
224224
$entity = parent::buildEntity($form, $form_state);
225225
// Now that the purchased entity is set, populate the title and price.
226226
$purchased_entity = $entity->getPurchasedEntity();
227-
$store = $this->selectStore($purchased_entity);
228-
$context = new Context($this->currentUser, $store);
229-
$resolved_price = $this->chainPriceResolver->resolve($purchased_entity, $entity->getQuantity(), $context);
230227
$entity->setTitle($purchased_entity->getOrderItemTitle());
231-
$entity->setUnitPrice($resolved_price);
228+
if (!$entity->isUnitPriceOverridden()) {
229+
$store = $this->selectStore($purchased_entity);
230+
$context = new Context($this->currentUser, $store);
231+
$resolved_price = $this->chainPriceResolver->resolve($purchased_entity, $entity->getQuantity(), $context);
232+
$entity->setUnitPrice($resolved_price);
233+
}
232234

233235
return $entity;
234236
}

0 commit comments

Comments
 (0)