Reading added items from shopping cart

Posted by Community Admin on 04-Aug-2018 22:31

Reading added items from shopping cart

All Replies

Posted by Community Admin on 23-Jul-2014 00:00

Hello,

I am using sitefinity shopping cart widget, i want to read the products added to shopping cart. I am not using check out. how can i read the added items to shopping cart. i want to read the added items to cart and store it in db.

Please let me know, how can i do this. 

Thank you for your help!

Kiran

Posted by Community Admin on 24-Jul-2014 00:00

Hello Kiran,

Thank you for contacting Telerik Support.

You can get the products added to shopping cart by using the following code :

OrderManager manager = OrderManager.GetManager();
//get shopping cart for the current user, or by cookie.
var shoppingCart = manager.TryGetCartOrder(this.GetShoppingCartId());
var cartDetails = shoppingCart .Details();

Code for GetShoppingCartId() :

/// <summary>
/// This method gets the id of the shopping cart for the current user.
 /// </summary>
/// <remarks>
/// This method uses cookies as persistence for the shopping cart.
/// </remarks>
/// <param name="ordersControl">
/// The instance of <see cref="IOrdersControl"/> which this method extends.
/// </param>
/// <returns>
/// The id of the shopping cart; empty GUID if user has no shopping cart.
/// </returns>
public static Guid GetShoppingCartId()
      HttpCookie shoppingCartCookie = SystemManager.CurrentHttpContext.Request.Cookies[EcommerceConstants.OrdersConstants.ShoppingCartIdCookieName];
      if (shoppingCartCookie == null || string.IsNullOrWhiteSpace(shoppingCartCookie.Value))
                return Guid.Empty;
 
      if (!shoppingCartCookie.Value.IsGuid())
                throw new InvalidOperationException("cartOrderId string cannot be parsed as a GUID; please provide a valid cartOrderId value.");
 
       return new Guid(shoppingCartCookie.Value);
 
public static Guid GetShoppingCartId(HttpCookie shoppingCartCookie)
       if (shoppingCartCookie == null || string.IsNullOrWhiteSpace(shoppingCartCookie.Value))
                return Guid.Empty;
 
       if (!shoppingCartCookie.Value.IsGuid())
                throw new InvalidOperationException("cartOrderId string cannot be parsed as a GUID; please provide a valid cartOrderId value.");
 
       return new Guid(shoppingCartCookie.Value);

For more information regarding your ticket, you can check the following documentation.

Feel free to contact us again if you have any other question. 

Regards,
Bobby
Telerik
 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

Posted by Community Admin on 24-Jul-2014 00:00

Thanks Bobby for the reply.

I am new sitefinity, i am learning and developing. i created page templates for each page and added shopping cart to one the page templates. can you please tell me where can i add this custom code? do i need to create new controller or file under mvc folder? where do i put this code. Please help.

Thanks,

Kiran

Posted by Community Admin on 24-Jul-2014 00:00

Hello again Kiran,

Could you please bring more light of what you are trying to achieve? Would it be possible for you to provide key steps you are taking or any other information that may help us understand your task?

Regards,
Bobby
Telerik

 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

Posted by Community Admin on 24-Jul-2014 00:00

Hi Bobby, 

Here is the task:

I need to save the products added to the cart, get the customer contact information and save it to the sitefinity with products added to cart and  contact information. Its like a quick shopping cart without using checkout module. is it possible ?

Thanks,

Kiran

Posted by Community Admin on 29-Jul-2014 00:00

Hi again Kiran,

You can check the following project, there you can find single page checkout and custom logic that may help you with your task, as almost every task you mentioned is done there.

Regards,
Bobby
Telerik

 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

This thread is closed