Basket shipment ApplyShipMethod()
Posted: Thu Jun 25, 2009 2:37 pm
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:
However, when we try to create a new basket instance and use that instead of the token user's basket:
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.
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();
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();
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.