0

I'm using Magento 2.3 as a headless solution, having an Angular app as a storefront and using REST API to manage eCommerce functionalities.

The fact is, in certain conditions, a bundled product with fixed price, have a 0 price after being added to the cart.

I'm working with guest carts and the flow is like the detailed below:

  • POST /rest/V1/guest-carts
  • POST /rest/V1/guest-carts/{{quoteId}}/items

    {"cartItem": {
        "sku": "bundled-product", 
        "qty": 1,
        "quoteId":"quoteId", 
        "productOptions": {
            "extensionAttributes": [
                "bundleOptions": {...}
            ]
        }
    }}
    
  • In this moment, the cart shows up the inserted product with its correct price

  • DELETE /rest/V1/guest-carts/{{quoteId}}/items/{{itemId}}
  • POST /rest/V1/guest-carts/{{quoteId}}/items (with the same previous product)
  • In this moment, the cart shows up the inserted product but with price 0

Have anyone faced this problem/issue? Have anyone resolved or fixed? Am I making something wrong?

Thanks in advance!

0

After doing some intensive research and test a lot of sugestions, there's a workaround to fix that:

Editing vendor/magento/module-quote/Model/Quote/Item/Repository.php to add these lines in the save funciton (before $this->quoteRepository->save($quote); ), everything goes ok:

$quote->getBillingAddress()->setCollectShippingRates(true);
$quote->getShippingAddress()->setCollectShippingRates(true);

Source: https://github.com/magento/magento2/issues/2991

  • never ever edit vendor files – Philipp Sander Dec 18 '18 at 9:11
  • You are righ @PhilippSander. In a happy scenario it shouldn't be necessary. But if you have read the linked issue, you would realize that there is a PR waiting for merging for several months and none of the Magento CE mantainers have merged yet. I'm sure that there will be another more elegant solution for this, but as I said, it's a workaround not a solution, that's the reason for the answer has not been marked as a solution. – Carles Dec 19 '18 at 9:52
  • don't even try to justify... editing vendor files is bad. why not use a plugin? – Philipp Sander Dec 19 '18 at 9:59
  • As I said, you are right, a vendor file has not be editted under any circumstance, I agree with that. I use Magento as a base, my goal is not to develop over Magento, just use it as a backend for our headless solution. I think using a plugin to fix a bug (that has been detected on 2.1 version and it has not been fixed yet) is not a proper solution for a project as big as Magento CE is, but it's my opinion. At the end of the day, I've posted the root of the problem in order to others could adapt a solution (plugin, fork, whatever they think it's the best solution) to fix it. – Carles Dec 19 '18 at 11:49

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.