Create Order Web Service NopCommerce

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
Hace 10 años
Hi All,

I am working for nopcommerce integration.

I want to create order in nopcommerce using web service.

What my requirement is I need to pass customer credentials, billing and shipping address ids, items code and quantity of items as parameter in web service.

I want rest of all things like tax, shipping rates, total is done in custom login in our web service.

I also tried creating one web service in nopcommece. check out following post. But didn't get any response from forum.

https://www.nopcommerce.com/boards/t/27482/create-order-web-service.aspx


If anyone can help me for creating this.
Hace 10 años
ajaysaksena wrote:
Hi All,

I am working for nopcommerce integration.

I want to create order in nopcommerce using web service.

What my requirement is I need to pass customer credentials, billing and shipping address ids, items code and quantity of items as parameter in web service.

I want rest of all things like tax, shipping rates, total is done in custom login in our web service.

I also tried creating one web service in nopcommece. check out following post. But didn't get any response from forum.

https://www.nopcommerce.com/boards/t/27482/create-order-web-service.aspx


If anyone can help me for creating this.


Create a REST service that'll then call OrderProcessingService.PlaceOrder() will do. :D
Hace 10 años
Hi wooncherk,

Thanks for quick reply.

Here I just check that function it seems that we have to pass object of ProcessPaymentRequest class in calling that function.

I checked the code and found that we need to pass total also and there is no thing like item no and quantity.

I need to just pass customer credentials for checking, address ids for billing and shipping and item ids and item quantities for that order.

I want nopcommerce to calculate rest of thing like total, shipping rates, tax and generate grand total and return order it.

Means we want to create one function which takes all above as argument and return order it which is created by that function.

Thanks Again.
Hace 10 años
ajaysaksena wrote:
Hi wooncherk,

Thanks for quick reply.

Here I just check that function it seems that we have to pass object of ProcessPaymentRequest class in calling that function.

I checked the code and found that we need to pass total also and there is no thing like item no and quantity.

I need to just pass customer credentials for checking, address ids for billing and shipping and item ids and item quantities for that order.

I want nopcommerce to calculate rest of thing like total, shipping rates, tax and generate grand total and return order it.

Means we want to create one function which takes all above as argument and return order it which is created by that function.

Thanks Again.


> I checked the code and found that we need to pass total also and there is no thing like item no and quantity.

Because the PlaceOrder function automatically takes the products from Cart.

So you need to create a REST method that add products to cart, create ProcessPaymentRequest, and call PlaceOrder(). :D
Hace 10 años
Hi Woon Cherk,

Thanks for Reply.

Steps you've provided are perfect !!

We got it done.

But we are getting one error.
Shipping total couldn't be calculated

We debugged nopcommerce code and found that error is coming from

..\Libraries\Nop.Services\Orders\OrderProcessingService.cs
It's on line number 732 to 734 in nopcommerce 3.10 source code.

Here is code where we get error.


Discount shippingTotalDiscount = null;
                    orderShippingTotalInclTax = _orderTotalCalculationService.GetShoppingCartShippingTotal(cart, true, out taxRate, out shippingTotalDiscount);
                   //We are getting error in next line with message - Shipping Total Couldn't be calculated.
                    orderShippingTotalExclTax = _orderTotalCalculationService.GetShoppingCartShippingTotal(cart, false);
                    if (!orderShippingTotalInclTax.HasValue || !orderShippingTotalExclTax.HasValue)
                        throw new NopException("Shipping total couldn't be calculated");

                    if (shippingTotalDiscount != null && !appliedDiscounts.ContainsDiscount(shippingTotalDiscount))


We tried to find out reason for this and got result that it is not calculating shipping rates from plugin.

Actually for we are using third party plug-in for calculation shipping rates. This plugin is specially created as per our bussiness logic. It is working fine for normal checkout from nopcommerce site but when we are creating order from newly created function for web service we are receiving error.

I changed it to default fix rate shipping from nopcommerce admin and our code worked perfect to create order from web service.

So what could be the issue here?

If you can help us with you suggestion/view on this.

Thanks In Advance.
Hace 10 años
ajaysaksena wrote:
Hi Woon Cherk,

Thanks for Reply.

Steps you've provided are perfect !!

We got it done.

But we are getting one error.
Shipping total couldn't be calculated

We debugged nopcommerce code and found that error is coming from

..\Libraries\Nop.Services\Orders\OrderProcessingService.cs
It's on line number 732 to 734 in nopcommerce 3.10 source code.

Here is code where we get error.


Discount shippingTotalDiscount = null;
                    orderShippingTotalInclTax = _orderTotalCalculationService.GetShoppingCartShippingTotal(cart, true, out taxRate, out shippingTotalDiscount);
                   //We are getting error in next line with message - Shipping Total Couldn't be calculated.
                    orderShippingTotalExclTax = _orderTotalCalculationService.GetShoppingCartShippingTotal(cart, false);
                    if (!orderShippingTotalInclTax.HasValue || !orderShippingTotalExclTax.HasValue)
                        throw new NopException("Shipping total couldn't be calculated");

                    if (shippingTotalDiscount != null && !appliedDiscounts.ContainsDiscount(shippingTotalDiscount))


We tried to find out reason for this and got result that it is not calculating shipping rates from plugin.

Actually for we are using third party plug-in for calculation shipping rates. This plugin is specially created as per our bussiness logic. It is working fine for normal checkout from nopcommerce site but when we are creating order from newly created function for web service we are receiving error.

I changed it to default fix rate shipping from nopcommerce admin and our code worked perfect to create order from web service.

So what could be the issue here?

If you can help us with you suggestion/view on this.

Thanks In Advance.


You have to set breakpoint in your custom shipping plugin. I don't think I can help here as only you have the plugin code. :D
Hace 10 años
Thank you Woon Cherk,

We created order web service with your help.

Steps Followed to Create Order Web Service :  
  • We need to get Prouducts from passed Product Ids / Product SKUs
  • Next, We need to load customer details.
  • Then, We have to add those products into shopping cart.
  • Once Shopping cart is created, We need to load shipping options with rates.
  • Then Finally, We can call Place Order methods to place an order with shipping rates we calcuated & all items in our shopping cart.

It's working fine. Thanks Again.

Here is another post for order by me.
https://www.nopcommerce.com/boards/t/27482/create-order-web-service.aspx#112394

Thank you Very Much.
Ajay Saksena
Hace 10 años
ajaysaksena wrote:
I also tried creating one web service in nopcommece. check out following post. But didn't get any response from forum.

https://www.nopcommerce.com/boards/t/27482/create-order-web-service.aspx

Please do not duplicate forum topics
Hace 9 años
Hi,

We need help with creating new orders. We are developing an extension which will allow orders to be placed by XML message. What objects are necessary to create the order?

Can you provide an example of your web service?
Hace 7 años
I am building a cXML/punchout web service to create orders. I'm using all nopCommerce logic and method calls (adding the items to the cart, creating a ProcessPaymentRequest and then calling PlaceOrder from the OrderProcessingService). All's well until I call Place Order and get "Payment Method can't be loaded." I am using the Purchase Order  plugin on the site which works well but it doesn't seem to be able to load it from the new application.

Is there something I need to configure for this to work. I tried copying the plugins folder into my app to see if that would work but it did not.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.