public WoocommerceService() { WooCommerceNET.RestAPI rest = new WooCommerceNET.RestAPI(Statics.WooApi, Statics.ConsumerKey, Statics.ConsumerSecret); wc = new WooCommerceNET.WooCommerce.v2.WCObject(rest); }
private async void ImageButton_Clicked(object sender, EventArgs e) { //You cant checkout if your not logged in There are no Guest Checkouts(I can But would rather not) if (Users.Loggedin == true) { if (Lineitems == null) { Lineitems = new List <OrderLineItem>(); } RestAPI rest = new RestAPI("http://mm-app.co.za/wp-json/wc/v2/", "ck_a25f96835aabfc64b09613eb8ec4a8c9bcd5dcd0", "cs_8f247c22353f25b905c96171379b89714f8f4003"); WooCommerceNET.WooCommerce.v2.WCObject wc = new WooCommerceNET.WooCommerce.v2.WCObject(rest); Check(); var order = new WooCommerceNET.WooCommerce.v2.Order() { status = "on-hold", customer_id = Users.CId }; foreach (var item in z) { var a = Convert.ToInt32(item.Pquantity); if (item.variation_id <= 0) { item.variation_id = item.PId; } if (item.StockQuantity == 0) { NoMore = true; Productname.Add(item.Pname); } order.line_items = order.line_items ?? new List <OrderLineItem>(); order.line_items.Add(new OrderLineItem() { product_id = item.PId, variation_id = item.variation_id, quantity = a }); } if (NoMore) { var yx = await DisplayAlert("Order Cant be Placed", $"Not enough stock for {Productname}", "Back to Cart", "Home"); if (yx) { } else { await Navigation.PushAsync(new Home("Mica Market")); } } else { if (items != null) { await wc.Order.Add(order); var masterDetailPage = new Home(""); masterDetailPage.Detail = new NavigationPage(new Checkedout()); Application.Current.MainPage = masterDetailPage; } else { var masterDetailPage = new Home(""); masterDetailPage.Detail = new NavigationPage(new CartEmprty()); Application.Current.MainPage = masterDetailPage; } } } else { var y = await DisplayAlert("Woops", "Please Login to check Out", "Login", "Home"); if (y) { var masterDetailPage = new Home(""); masterDetailPage.Detail = new NavigationPage(new Login()); Application.Current.MainPage = masterDetailPage; } else { await Navigation.PushAsync(new Home("Mica Market")); } } }