I created an order by using IPurchaseorder API and created the LineItem using LineItem API. I added the LineItem to the order using PurchaseOrder.AddLineItem(LineItem).
On the CMS it displays the order total , order status. After editing Shipping method order total automatically change to $0.0 and Line Item disappered.
And another issue was after saving my purchase order if I load that order it returns null.
I need to check if it happens is correct or not and also I need some blogs to refer.
Thanks in advance.
//Create purchase order
var purchaseOrder = orderRepository.Create(contactId, "computer");
//Create Line Item
LineItem lineitem = new LineItem()
DisplayName = "PenLine",
Quantity = 10,
PlacedPrice = 500,
Code = "1477707",
ListPrice = 500,
ShippingMethodName = "In Store Pick up",
ParentCatalogEntryId = "cart_1",
ShippingAddressId = "0077777",
WarehouseCode = "SAMPLE",
IsInventoryAllocated = true,
Shipment shipment = new Shipment()
WarehouseCode = "SAMPLE",
ShipmentTrackingNumber = "0077777",
purchaseOrder = orderRepository.Load(contactId);//It returns null
You can follow the examples here. In short we don't work with the concrete Shipment and LineItem class, but use cart.CreateLineItem and cart.CreateShipment extension methods to create the instances of ILineItem and IShipment we need.
Thanks for reply.
I tried to create line item and shipment using cart.CreateLineItem and cart.CreateShipment.But still same issue occured.
The most common reason for an lineitem to be removed during a validation is that it does not have a valid price, or it does not have a valid inventory. Make sure your "1477707" lineitem has both those information.
Thanks for the reply.Order Total is not null.I found that Shipping method's base price is reflected in order total.I just get shipping methods using ShippingMethodDto and assign Base price value and save the changes.But it does not reflect in Commerce Manager.My code is like
//Get the list of all shipping methods to be filtered
ShippingMethodDto methods = ShippingManager.GetShippingMethods(SiteContext.Current.LanguageName);
//Assigning Base price value
for(int i = 0; i < 4; i++)
methods.ShippingMethod[i].BasePrice = 500;
methods = ShippingManager.GetShippingMethods(SiteContext.Current.LanguageName); //-->its returns old Base price value
Help me to override the base price value.
For future ref! Updates or add a shippingmethod (COM 13):
var method = ShippingManager.GetShippingMethod(model.ShippingMethodId);
if (method?.ShippingMethod?.Count > 0)//update
method.ShippingMethod.DisplayName = model.DisplayName;
method.ShippingMethod.Currency = model.Currency;
method.ShippingMethod.IsActive = model.IsActive;
method.ShippingMethod.IsDefault = model.IsDefault;
method.ShippingMethod.Name = model.Name;
method.ShippingMethod.Description = model.Description;
method.ShippingMethod.Ordering = model.Ordering;
method.ShippingMethod.LanguageId = model.LanguageId;
method.ShippingMethod.BasePrice = model.BasePrice;
var methods = ShippingManager.GetShippingMethods("");
var row = methods.ShippingMethod.NewShippingMethodRow();
row.ShippingMethodId = model.ShippingMethodId;
row.ShippingOptionId = model.ShippingOptionId;
row.Created = row.Modified = DateTime.UtcNow;
row.DisplayName = model.DisplayName;
row.Currency = model.Currency;
row.IsActive = model.IsActive;
row.IsDefault = model.IsDefault;
row.Name = model.Name;
row.Description = model.Description;
row.Ordering = model.Ordering;
row.LanguageId = model.LanguageId;
row.BasePrice = model.BasePrice;