Cannot get ShippingMethod name, ID only.
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Web Servers reviews > Microsoft Commerce Server > Commerce Server General > Cannot get ShippingMethod name, ID only.




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Cannot get ShippingMethod name, ID only.  
Ripos


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-13-05 11:01 PM

We use CS2002+SP3+FP1.
We build out site on top of the Starter Site.

This is a method of saving a Shippment:
Cart cart =3D TransactionContext.Current.Cart;
foreach(LineItem item in cart.LineItems) {
cart.SetShippingMethod(item.Index, optShip.Value);
}
cart.ShippingMethodID =3D optShip.Value;
cart.Save();

This is a method of getting a current Shippment:
Cart cart =3D TransactionContext.Current.Cart;
lblShipping.Text =3D TransactionContext.Current.GetShippingMethodName (=

((Shipment) Cart.Shipments[0]). ShippingMethodName);
Also I've tried:
Cart cart =3D TransactionContext.Current.Cart;
lblShipping.Text =3D ((Shipment)cart.Shipments[0]).ShippingMethodName;
and	=

Cart cart =3D TransactionContext.Current.Cart;
lblShipping.Text =3D Cart.ShippingMethodName;

All of them say that MethodName is null, and for some of them even  =

MethodID is null too.

May be I do smthing wrong?





[ Post a follow-up to this message ]



    RE: Cannot get ShippingMethod name, ID only.  
Joe Wasson [MSFT]


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-15-05 10:59 PM

I think you've ended up dancing around the right answer.  If you're trying
to have only one shipping method then you only need "cart.ShippingMethodID
= optShip.Value;", setting each line item shouldn't be necessary (I'm not
entirely certain, but I've been told by another developer this is the case).

The first code you display has a bug where you are trying to get the
ShippingMethodName by using the ShippingMethod Name.  Also, the Shipments
array is not built until you run the pipeline, so that explains why the
first and second code blocks don't really work.

One would think that the third code block would work, but due to the way
ShippingMethodName is implemented you could be running into two problems:
1) if there is more than one shipping method or shipping address assigned
to the basket and/or lineitems then this property will return null, as
there is no single shipping method.  2) There appears to be a bug in the
implementation where the Shipping Method ID is used for the
ShippingMethodName.

My recommendation is to use "cart.ShippingMethodID = optShip.Value;" to set
the shipping method and use
"TransactionContext.Current.GetShippingMethodName(CommerceContext.OrderSyste
m.GetBasket(currUserGuid)["shipping_method_id"])" to get the shipping
method name.

I hope this helps.  Let me know if you have any questions or my answer
didn't help.

-joe

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
Date: Tue, 13 Sep 2005 17:24:49 +0400
Subject: Cannot get ShippingMethod name, ID only.
From: Ripos <ripos@ripsoft.net>

We use CS2002+SP3+FP1.
We build out site on top of the Starter Site.
This is a method of saving a Shippment:
Cart cart = TransactionContext.Current.Cart;
foreach(LineItem item in cart.LineItems) {
cart.SetShippingMethod(item.Index, optShip.Value);
}
cart.ShippingMethodID = optShip.Value;
cart.Save();
This is a method of getting a current Shippment:
Cart cart = TransactionContext.Current.Cart;
lblShipping.Text = TransactionContext.Current.GetShippingMethodName (
((Shipment) Cart.Shipments[0]). ShippingMethodName);
Also I've tried:
Cart cart = TransactionContext.Current.Cart;
lblShipping.Text = ((Shipment)cart.Shipments[0]).ShippingMethodName;
and		Cart cart = TransactionContext.Current.Cart;
lblShipping.Text = Cart.ShippingMethodName;
All of them say that MethodName is null, and for some of them even
MethodID is null too.
May be I do smthing wrong?






[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 06:31 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register