cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Share Cart Info on Mail with "Add to Cart" Link

rahulverma94
Active Participant
0 Likes
1,044

Hi Experts,

We have a requirement of sharing the Cart info with any user over an email. The email should contain a "Add to Cart" link which upon clicking should take us to the Cart Page with the Cart Entries added in our session. Could someone please suggest an approach, especially handling the "Add to Cart" button in vm file for email.

Regards Rahul

Accepted Solutions (0)

Answers (5)

Answers (5)

0 Likes

bro , use whishlist feature for you functionality , while sharing create wishlist in your hybris , and encode indentifier and share the link with another user. Once user hit the link then decode the encoded identifier and add products from wishlist . Once product added successfully delete wishilist.

Former Member
0 Likes

Hi DurgaRao

'Add All to Cart' will have the following url
www.xyz.com/cart/<cart-guid>;

In the CartPageController, have an endpoint like I mentioned in my previous comment. Write a service that fetches the cart with GUID. Now there are 2 scenarios

Either the user clicking 'Add All to Cart' is logged in in a different browser tab or not logged in at all.

If the user who is clicking 'Add all to cart' is logged in, his session is active. In this case, get the current session and add the cart to this session and do change the user of the cart to this user.

If the user who is clicking 'Add all to cart' is NOT logged in, there is no session. Create a new session, add the cart to sesssion and change the user of the cart to anonymous.

Let me know how you go. If you have any direct questions, please send an email to saurabh24grover@gmail.com

rahulverma94
Active Participant
0 Likes

Hi ,

Could you please look into and help DurgaRao with his requirement?

Regards Rahul

0 Likes

Hi Saurabh,

Thanks for your reply. Below is the requirement.

1) User A shared a cart with User B via email. 2) In the received email for User B, we are displaying all cart entries one by one with a "ADD TO CART" button for each entry. 3) After all the entries are displayed, at the end we are displaying one more "ADD ALL TO CART" button. 4) If User B clicks on "ADD TO CART" button (step2),he should navigate to cart page in our site with the selected entry added to the cart. 5) If User B clicks on "ADD ALL TO CART" button(step3), he should navigate to cart page in our site with all the entries add to the cart.

Please let me know if you need any other information.

Regards, DurgaRao

Former Member
0 Likes

Hey DurgaRao

Let me know how you go. Alternatively you can send me an email at my email ID mentioned below.

Former Member
0 Likes

Hi Rahul

sorry, I am little confused, if you are sharing cart info, that means products are present in the clready and you are displaying a list of products in an email that gets sent to the user.

The email can have a 'View Cart' link which upon clicking, takes the user to your site and fetches the cart. If this is your requirement you can send a url /<cartGUID> as a hyperlink in your email

In you CartPageController, create another method with with RequestParameter as below

 @RequestMethod(value="/{guid}", method = RequestMethod.GET)
 public String fetchCart(@PathVariable final String guid) {
    CartModel cartModel = service.getCartForGuid(guid);
     // populate cartData from cart
     model.addAttribute("cartData", cartData);
     return "cartPage"
 }

If you have a list of products and there is an add to cart button against every product in the email, and you want that clicking on 'Add to Cart' again any product adds that product in you cart

then you have to create a form in your VM file and submit that form to the /cart/add endpoint POST product code to the /cart/add endpoint. Also pass the GUID as a get or post parameter and fetch the cart via this GUID and add the cart to the session in CartRestorationFilter.

Let me know how you go. Sorry if I have not understood your problem fully.