| Author |
Message |
Susan H
Guest
|
Posted:
Fri Oct 07, 2005 12:50 am Post subject:
How to Save then Retrieve a basket |
|
|
I am using Commerce Server 2002 FP1, CMS 2002, and MSIB 2.5
I am trying to simply save a user's shopping cart in such a way that it is
not an order, and I can retrieve this cart later given the user's email
address.
Currently, I am trying
GetOrderTemplate(new Guid(UserObject.CurrentUser.UserID), new
Guid(UserObject.CurrentUser.UserID));
but this does not seem to be working. I was wondering if there's a common
way to do this. |
|
| Back to top |
|
 |
Marcelo
Guest
|
Posted:
Fri Oct 07, 2005 8:51 am Post subject:
RE: How to Save then Retrieve a basket |
|
|
Hi Susan,
In Commerce Help documentatio you have a example of you can do that, see
"Code to Manipulate a Basket on an ASP.NET Web Form"
void UpdateBasket() {
OrderContext orders = CommerceContext.Current.OrderSystem;
// This requires that the CommerceContext.UserID property already
// be set. It can either be set dynamically if using Commerce Server
// authentication, or manually.
Basket shoppingCart =
orders.GetBasket(new System.Guid(CommerceContext.Current.UserID));
// If the shopping cart has just been created, no order forms
// will exist and thus, it is unusable. So a new, default
// order form must be added.
if (shoppingCart.OrderForms.Count == 0) {
shoppingCart.OrderForms.Add(new OrderForm("default"));
}
// Execute the product pipeline to ensure we have the latest product
// information in the basket.
shoppingCart.RunPipeline(new PipelineInfo("basket"));
// Bind the default order form to the Repeater control used for
// displaying its contents.
BasketListing.DataSource =
shoppingCart.OrderForms["default"].LineItems;
BasketListing.DataBind();
// Update information about the order.
SubTotal.Text = String.Format("{0:C}", shoppingCart.SubTotal);
// This data will not be available after running the basket pipeline
// alone.
Tax.Text = String.Format("{0:C}", shoppingCart.TaxTotal);
Total.Text = String.Format("{0:C}", shoppingCart.Total);
shoppingCart.Save();
}
Regards
Marcelo SWánchez Lujambio
"Susan H" wrote:
| Quote: | I am using Commerce Server 2002 FP1, CMS 2002, and MSIB 2.5
I am trying to simply save a user's shopping cart in such a way that it is
not an order, and I can retrieve this cart later given the user's email
address.
Currently, I am trying
GetOrderTemplate(new Guid(UserObject.CurrentUser.UserID), new
Guid(UserObject.CurrentUser.UserID));
but this does not seem to be working. I was wondering if there's a common
way to do this. |
|
|
| Back to top |
|
 |
Susan H
Guest
|
Posted:
Fri Oct 07, 2005 4:51 pm Post subject:
RE: How to Save then Retrieve a basket |
|
|
Thank you for your reply. Unfortunately, this is not what I meant.
I have been able to succesfully construct and save a basket, and if I call
cart.SaveAsOrder() I properly get a new order (PurchaseOrder) that I expect.
What I'm trying to do is save the basket in a "saved" state, where the order
form object is in a status of "2", in such a way that I can later, in a
different session, re-retrieve that same basket using the person's email
address. Basically, what we have is a customer service section, where the
CSR's place orders for customers; if the customer's credit card doesn't work,
they need to check on it and call back, so instead of re-placing the whole
order, the intention is to "save" the order for later retrieval.
I was using GetOrderTemplate(new Guid(UserObject.CurrentUser.UserID), new
Guid(UserObject.CurrentUser.UserID)) but that does not seem to work.
Thanks again for your reply. |
|
| Back to top |
|
 |
Jeff Lynch
Guest
|
Posted:
Mon Oct 10, 2005 12:50 am Post subject:
Re: How to Save then Retrieve a basket |
|
|
Try something like this code:
/// <summary> /// The <b>SaveAsTemplate</b> method allows the
user to save the current Basket as a /// Template for later use.
/// </summary> /// <param name="TemplateName">The name of the
template.</param> public void SaveAsTemplate(string TemplateName)
{ // Create a new OrderTemplate from the Basket
OrderTemplate template =
CommerceContext.Current.OrderSystem.CreateOrderTemplate(_Basket.BasketID);
// Add the OrderForms to the Template template.OrderForms.Add(new
OrderForm("default")); foreach (LineItem item in
_Basket.OrderForms["default"].LineItems) {
template.OrderForms["default"].LineItems.Add(item); }
// Run the pipeline
template.RunPipeline(GetBasketPipelineInfo()); // Save the
template template.Save(TemplateName); // Empty the
Basket EmptyBasket(); }
private PipelineInfo GetBasketPipelineInfo() {
PipelineInfo info = new PipelineInfo("basket");
info["catalog_language"] = Utility.EnglishLanguage;
info.Profiles.Add("User", CommerceContext.Current.UserProfile);
info.Language = Utility.EnglishLanguage; return info; }
--
Jeff Lynch
"A BizTalk Enthusiast"
http://codebetter.com/blogs/jeff.lynch
"Susan H" <susanjane@newsgroups.nospam> wrote in message
news:EEB42BD7-FC47-414B-A0EA-679995683133@microsoft.com...
| Quote: | Thank you for your reply. Unfortunately, this is not what I meant.
I have been able to succesfully construct and save a basket, and if I call
cart.SaveAsOrder() I properly get a new order (PurchaseOrder) that I
expect.
What I'm trying to do is save the basket in a "saved" state, where the
order
form object is in a status of "2", in such a way that I can later, in a
different session, re-retrieve that same basket using the person's email
address. Basically, what we have is a customer service section, where the
CSR's place orders for customers; if the customer's credit card doesn't
work,
they need to check on it and call back, so instead of re-placing the whole
order, the intention is to "save" the order for later retrieval.
I was using GetOrderTemplate(new Guid(UserObject.CurrentUser.UserID), new
Guid(UserObject.CurrentUser.UserID)) but that does not seem to work.
Thanks again for your reply. |
|
|
| Back to top |
|
 |
Jeff Lynch
Guest
|
Posted:
Mon Oct 10, 2005 12:50 pm Post subject:
Re: How to Save then Retrieve a basket |
|
|
Sorry about the formatting on my last message. Ping me via my blog and I'll
email you the source code.
--
Jeff Lynch
"A BizTalk Enthusiast"
http://codebetter.com/blogs/jeff.lynch
"Jeff Lynch" <jeff.lynch@newsgroup.nospam> wrote in message
news:OiYvg3SzFHA.736@tk2msftngp13.phx.gbl...
| Quote: | Try something like this code:
/// <summary> /// The <b>SaveAsTemplate</b> method allows
the user to save the current Basket as a /// Template for later
use. /// </summary> /// <param name="TemplateName">The name of the
template.</param> public void SaveAsTemplate(string TemplateName)
{ // Create a new OrderTemplate from the Basket OrderTemplate
template =
CommerceContext.Current.OrderSystem.CreateOrderTemplate(_Basket.BasketID);
// Add the OrderForms to the Template
template.OrderForms.Add(new OrderForm("default")); foreach
(LineItem item in _Basket.OrderForms["default"].LineItems) {
template.OrderForms["default"].LineItems.Add(item); } // Run
the pipeline template.RunPipeline(GetBasketPipelineInfo()); //
Save the template template.Save(TemplateName); //
Empty the Basket EmptyBasket(); }
private PipelineInfo GetBasketPipelineInfo() { PipelineInfo info =
new PipelineInfo("basket"); info["catalog_language"] =
Utility.EnglishLanguage; info.Profiles.Add("User",
CommerceContext.Current.UserProfile); info.Language =
Utility.EnglishLanguage; return info; }
--
Jeff Lynch
"A BizTalk Enthusiast"
http://codebetter.com/blogs/jeff.lynch
"Susan H" <susanjane@newsgroups.nospam> wrote in message
news:EEB42BD7-FC47-414B-A0EA-679995683133@microsoft.com...
Thank you for your reply. Unfortunately, this is not what I meant.
I have been able to succesfully construct and save a basket, and if I
call
cart.SaveAsOrder() I properly get a new order (PurchaseOrder) that I
expect.
What I'm trying to do is save the basket in a "saved" state, where the
order
form object is in a status of "2", in such a way that I can later, in a
different session, re-retrieve that same basket using the person's email
address. Basically, what we have is a customer service section, where
the
CSR's place orders for customers; if the customer's credit card doesn't
work,
they need to check on it and call back, so instead of re-placing the
whole
order, the intention is to "save" the order for later retrieval.
I was using GetOrderTemplate(new Guid(UserObject.CurrentUser.UserID), new
Guid(UserObject.CurrentUser.UserID)) but that does not seem to work.
Thanks again for your reply.
|
|
|
| Back to top |
|
 |
Susan H
Guest
|
Posted:
Mon Oct 10, 2005 4:51 pm Post subject:
Re: How to Save then Retrieve a basket |
|
|
Jeff:
Thank you for your reply. This looks like what I'm looking for. I'm going
to try this and then I'll get back to you. Don't worry about the formatting,
I've got it :-)
Thanks
Sue
"Jeff Lynch" wrote:
| Quote: | Try something like this code:
/// <summary> /// The <b>SaveAsTemplate</b> method allows the |
|
|
| Back to top |
|
 |
|
|
|
|