Page 1 of 1

Basket shipment ApplyShipMethod()

Posted: Thu Jun 25, 2009 2:37 pm
by adamh
There is a section of our store where we'd like a separate fully functional shopping basket. The basket will need to be able to display the shipping costs associated with an order. If we use Token.Instance.User.Basket, the following code works like a charm:

Code: Select all

Token.Instance.User.Basket.Save();
Token.Instance.User.Basket.Package();
Token.Instance.User.Basket.Recalculate();

foreach (BasketShipment shipment in Token.Instance.User.Basket.Shipments)
{
	shipment.ApplyShipMethod("ShippingMethod1");
}
Token.Instance.User.Basket.Shipments.Save();
However, when we try to create a new basket instance and use that instead of the token user's basket:

Code: Select all

protected Basket _cart
{
	get
	{
		return (Basket)Session["cart"];
	}
	set
	{
		Session["cart"] = value;
	}
}
...
_cart.Save();
_cart.Package();
_cart.Recalculate();

foreach (BasketShipment shipment in _cart.Shipments)
{
	shipment.ApplyShipMethod("ShippingMethod1");
}
_cart.Shipments.Save();
No shipping method is applied. When we check each shipment in the basket, there no items listed. If we place the order, the shipment(s) is correct, but there will not be any shipping method applied.

Is there any reason why items are not being created in each shipment on the Package() or Recalculate() methods? and why ApplyShipMethod() does not work when using a basket in this manner?

Thanks in advance.

Re: Basket shipment ApplyShipMethod()

Posted: Mon Aug 03, 2009 8:34 pm
by AbleMods
Adam, you ever figure this out? I'm seeing the exact same thing with some testing I'm doing. It's like there's something in the Token basket that isn't created/assigned when do a new Basket(); setup.