MInimal code to create user, add items to shopping cart and confirm order?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
12 years ago
Hi,

I'm trying to achieve the following programmatically:

1. create user
2. login user
3. add shipping and billing address to user
4. add products to shoppingbasket
5. convert shopping basket to order and confirm order

everything seems to work fine, except step 5.
I use the method below to convert cart to order:

string result = this.OrderService.PlaceOrder(PaymentInfo, Customer, out orderID);


I keep getting excpetion that shipping total cannot be calculated.

What would be the minimal code to achieve my goal?

Thanks!
12 years ago
The step list is OK. I'm not sure but presume that you forgot to apply 'Shipping method with rate' to your customer (like you do on 'Select shipping method page' during checkout). I mean 'LastShippingOption' property of 'Customer' entity. Have a look at the following file and do the same in your code - \NopCommerceStore\Modules\CheckoutShippingMethod.ascx.cs
12 years ago
thanks! (turned out I had to set some more properties on Customer and PaymentInfo)
12 years ago
Why not share your code to learn?
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.