DEV Community

Dynamics 365 (E-)Commerce development Proof of Concept (2)

Rob vanBrandenburg on May 14, 2021

This is a follow up on this post. Intro In the first part we saw how we can extend the CRT to include additional fields in the extensio...
Collapse
 
senerkan profile image
Erkan Sen • Edited

Hi Rob,
I tried the same thing and as your screenshot I have also two buttons (Add to bag & empty). Why is this happening? And after closing the alert message system raises error message "Unhandled Rejection (Error): [getActiveCartWithProdcuts]Unable to hydrate cart with product information". I think add to cart couldn't work properly.

Collapse
 
robvanb profile image
Rob vanBrandenburg

Hi Erkan, I'm not sure what you mean when you say you have 2 buttons? Can you post a screenshot?
As to your error, are you modifying the cart contents at all in your code?

Collapse
 
senerkan profile image
Erkan Sen • Edited

Hi Rob,
I attached the screenshot. In your screenshot I can also see the other button in orange color. I just override AddToCart and even though I didn't modify it I have two buttons. When I click the button with caption it adds the item into basket and after that raises error message. When I click the second button without caption system tries to login and do nothing.
dev-to-uploads.s3.amazonaws.com/up...
dev-to-uploads.s3.amazonaws.com/up...

Thread Thread
 
robvanb profile image
Rob vanBrandenburg • Edited

Erkan - sorry for the delay. I finally had a chance to look into this. I had not even noticed this myself :)
I wonder if this is a bug in the Theme extension / Component extension framework. If I look at the generated page, I see that there actually are 2 buttons (see attached screenshot). However, the extended component only has one. I might post this in the Yammer group to see if I can get some insight from others and possibly Microsoft. Good find!

dev-to-uploads.s3.amazonaws.com/up...

Collapse
 
hassanamjad91 profile image
Muhammad Hassan Amjad

Hey Rob, Great article!

I am trying tp put a limit on the cart itself such that users can only add 1 item.
Can you suggest the best approach to achieve this?

Thanks.

Collapse
 
robvanb profile image
Rob vanBrandenburg

HI Muhammad, just from the top of my head, I would say, find out which action is called to add items to a cart. Then trace that to the actual CRT method that is being called.
Once you know that, you can extend that method by adding the logic to check for the number of items in the cart, and send the appropriate message back to the front end.
Hope this helps.