WooCommerce.NET icon indicating copy to clipboard operation
WooCommerce.NET copied to clipboard

Order.Add Issue's

Open Vliesie opened this issue 5 years ago • 4 comments

Make sure you have included the below details when open an issue. Thank you.

  • Latest Wordpress Woocom V4

  • Try to place a order with items in the Lineitems then awaiting the Order.Add

  • private async Task Succeed() { _spamClick = true; await wcV2.Order.Add(order);//Freezes here with the await Preferences.Clear("Cart");//With await this is unreachable _items.Items.Clear(); await Navigation.PopPopupAsync(); await DisplayAlert("Success", "Order has been Placed, Thank you!", "Ok"); }

Having a Problem with the Order.add When I place the order and await it, it gets stuck in an infinity loop it just never ends its forever just waiting for the order to finish but the order is placed on the Backend site wthout awaiting it im risking some errors but it works fine for smaller orders.

Curious if this is to do with the V4 update as this only showed up now after the V4 release

Vliesie avatar Apr 07 '20 08:04 Vliesie

Not sure what has changed in V4, but I will have a look.

XiaoFaye avatar Apr 08 '20 22:04 XiaoFaye

Hi! I have a similar problem, which happens from time to time. Im my case using this:

            this.wcApi = new RestAPI(url,key, secret, false);
            ...
            var wc = new WCObject.WCOrderItem(this.wcApi);
            var currentPage = 1;
            var pageSize = 20;
            do
            {
                var getall_params = new Dictionary<string, string>() { { "page", currentPage.ToString() }, { "per_page", pageSize.ToString() }, { "status", "processing" } };
                var orders = await wc.GetAll(getall_params);   /// sometimes, this waits forever....
                if (orders.Count == pageSize)
                {
                    // Can be more pages available
                    currentPage++;
                }
                else
                {
                    // No more pages, stop fetching
                    currentPage = -1;
                }
             ....
            }  while (currentPage > 0);

Any advice?

jacargentina avatar Jul 08 '20 12:07 jacargentina

@XiaoFaye I've found that this line may be the problematic one:

https://github.com/XiaoFaye/WooCommerce.NET/blob/10a4e08b43f9b088375e252771c3c6cbd4ef51ce/RestAPI.cs#L257

GetResponseAsync() is called, but there is not timeout mechanism anywhere. I've found other project which had a similar problem here https://github.com/JimBobSquarePants/ImageProcessor/issues/651

Maybe a solution could be refactor the code to Replace with HttpClient ?

I can try to build a PR if u think so?

jacargentina avatar Jul 08 '20 16:07 jacargentina

httpWebRequest timeout can be set using request filter.

XiaoFaye avatar Nov 20 '21 02:11 XiaoFaye