Integration with ShipStation?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
3 years ago
Hi. You may try to change the WriteOrderItemsToXml method to the following one:


protected virtual void WriteOrderItemsToXml(XmlTextWriter writer, ICollection<OrderItem> orderItems)
{
  writer.WriteStartElement("Items");

  var productAttributeParser = EngineContext.Current.Resolve<ProductAttributeParser>();

  foreach (var orderItem in orderItems)
  {
    var product = _productService.GetProductById(orderItem.ProductId);
    var order = _orderService.GetOrderById(orderItem.OrderId);

    //is shippable
    if (!product.IsShipEnabled)
      continue;

    writer.WriteStartElement("Item");

    var sku = product.Sku;
    var attributesXml = orderItem.AttributesXml;

    if (!string.IsNullOrEmpty(attributesXml) && product.ManageInventoryMethod == ManageInventoryMethod.ManageStockByAttributes)
    {
      var combination = productAttributeParser.FindProductAttributeCombination(product, attributesXml);
      if (combination != null)
      {
        sku = combination.Sku;
      }
    }

    writer.WriteElementString("SKU", string.IsNullOrEmpty(sku) ? product.Id.ToString() : sku);
    writer.WriteElementString("Name", product.Name);
    writer.WriteElementString("Quantity", orderItem.Quantity.ToString());
    writer.WriteElementString("UnitPrice", (order.CustomerTaxDisplayType == TaxDisplayType.IncludingTax ? orderItem.UnitPriceInclTax : orderItem.UnitPriceExclTax).ToString(CultureInfo.InvariantCulture));

    writer.WriteEndElement();
    writer.Flush();
  }

  writer.WriteEndElement();
  writer.Flush();
}
3 years ago
Hi

It works, thank you very much for the help.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.