I am trying to use this code for making an order in Woocommerce, using this add-on :
https://github.com/XiaoFaye/WooCommerce.NET. My code is this:
var order = new Order() { status = "pending" };
order.currency = "EUR";
order.line_items.Add(new OrderLineItem()
{
id=44,
product_id = 44,
quantity=2
}
);
order.customer_id = 1;
Task ord = wc.Order.Add(order);
ord.Wait();
But everytime it gives me this exception:
System.NullReferenceExcept
ion: 'Object reference not set to an instance of an object.'
I have tried everything but no success...
Both of these lines look like they're adding an object to list, so it's possible that the list itself hasn't been initialised:
Open in new window