0

I am adding a product with custom options to my cart. One of the options costs extra. But the Magento Cart page does not show the price correctly.

Here you can see the cart page. The Summary shows the correct prices. But the items list does not.

enter image description here

This is the "add option" implementation I am using:

private function addToCart($product) {
    $this->cart->addProduct($product, ['product_id' => $product->getId(), 'qty' => 1]);
}

// <snip>

private function addColorToProduct($product, ?string $color)
{
    // <snip>

    $product->addCustomOption('option_ids', $option->getData('option_id'));
    $product->addCustomOption('option_'.$option->getData('option_id'), $value->getData('option_type_id'))->save();
}

I've tried doing things like this

$quote = $this->cart->getQuote()->setTotalsCollectedFlag(false)->collectTotals();
$this->cart->setQuote($quote);
$this->cart->save();

But that did not fix it either.

What am I missing?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.