public ApiV3WCObject(RestAPI restApi, IWCObject fallbackApi = null) { Condition.Requires(restApi, "restApi").IsNotNull(); this._wcObjectApiV3 = new WApiV3.WCObject(restApi); this._fallbackAPI = fallbackApi; }
public async Task InitAsync() { WCObject wc = new WCObject(rest); index = 0; productQuantity = 0; //Simple z = await wc.Product.Get(singleID); z._virtual = true; //Variable p = await wc.Product.Variations.GetAll(singleID); var xxxx = p; var indexer = 0; // NOt to sure how Threading works but I want this to run on its own Thread as its somewhat intense || Cant Test this but Hoping this calls the Method and Starts it on a new thread then auto kills it self when its done Thread SThread = new Thread(Orders.StringReplace); SThread.Start(); //Simple Quantity checks foreach (var item in z.meta_data) { if (z.meta_data[indexer].key == "group_of_quantity") { productQuantity = Convert.ToDouble(z.meta_data[indexer].value); indexer++; } else { indexer++; } } if (z.stock_quantity <= 0) { TempStockQ = 2; z.stock_quantity = 2; z.meta_data[1].value = 1; TempIsAvb = "Not in stock"; z._virtual = false; } if (z.stock_quantity == null) { isUnlimted = true; //If Stock is null it means unlimited so 9999999 will be per purchase instance var i = 999999; z.stock_quantity = i; z._virtual = true; TempIsAvb = "In Stock"; } else { z._virtual = true; TempStockQ = Convert.ToInt32(z.stock_quantity); } //Variable Quantity Checks foreach (var item in p) { if (z.meta_data[indexer].key == "group_of_quantity") { productQuantity = Convert.ToDouble(z.meta_data[indexer].value); } else { indexer++; } int value = 100000; var StockQ = Convert.ToInt32(z.stock_quantity); if (item.stock_quantity <= 0) { TempStockQ = 2; item.stock_quantity = 2; item.meta_data[1].value = 1; TempIsAvb = "Not in stock"; item._virtual = false; } if (item.stock_quantity == null) { isUnlimted = true; StockQ = value; TempIsAvb = "In Stock"; //If Stock is null it means unlimited so 9999999 will be per purchase instance var i = 999999; z.stock_quantity = i; z._virtual = true; } if (item.meta_data[2].value == null) { double i = productQuantity; item.meta_data[2].value = i; item._virtual = true; TempIsAvb = "In Stock"; } if (item.meta_data[2].value is string stringValue && String.IsNullOrWhiteSpace(stringValue)) { double i = productQuantity; item.meta_data[2].value = i; } if (item.meta_data[2].value is int intValue && intValue <= 0) { intValue = (int)item.meta_data[2].value; intValue = (int)item.meta_data[1].value; item.meta_data[2].value = intValue; }
//Checks for stock quantity for variable's and singles incase theres no more stocks left this needs IMMENSE testing. public async void Check() { RestAPI rest = new RestAPI("http://mm-app.co.za/wp-json/wc/v3/", "ck_a25f96835aabfc64b09613eb8ec4a8c9bcd5dcd0", "cs_8f247c22353f25b905c96171379b89714f8f4003"); WooCommerceNET.WooCommerce.v3.WCObject wc = new WooCommerceNET.WooCommerce.v3.WCObject(rest); foreach (var item in z) { var a = await wc.Product.Get(item.PId); //Variable var y = await wc.Product.Variations.GetAll(item.PId); if (a.variations == null) { if (item.StockQuantity == Convert.ToInt32(a.stock_quantity)) { if (a.stock_quantity == 0 || item.Pquantity > a.stock_quantity) { var yx = await DisplayAlert("Not Enough Products", $"There is this much Stock left:{a.stock_quantity}for{a.name}", "Back to Cart", "Keep Shopping"); if (yx) { item.StockQuantity = Convert.ToInt32(a.stock_quantity); items = new ItemList(FullCart.Cartlistz); cartView.ItemsSource = items.Items; } else { await Navigation.PushAsync(new Home("Mica Market")); } } } //Is Single } if (Orders.isUnlimted) { var x = item.StockQuantity - 1; item.StockQuantity = x; } else { foreach (var itemz in y) { if (itemz.stock_quantity == 0 || item.Pquantity > itemz.stock_quantity) { var yx = await DisplayAlert("Not Enough Products", $"There is this much Stock left:{a.stock_quantity}for{itemz.id}", "Back to Cart", "Home"); if (yx) { item.StockQuantity = Convert.ToInt32(itemz.stock_quantity); items = new ItemList(FullCart.Cartlistz); cartView.ItemsSource = items.Items; } else { await Navigation.PushAsync(new Home("Mica Market")); } } if (Orders.isUnlimted) { var x = itemz.stock_quantity - 1; itemz.stock_quantity = x; } } } } }