/// <summary> /// Register that a shipment has been shipped. /// </summary> /// <param name="shipDate">Date the shipment has been shipped.</param> /// <param name="updateGoogleCheckout">If the order associated with this shipment is a GoogleCheckout /// order, this flag indicates whether to send an update notification to GoogleCheckout or not.</param> public void Ship(DateTime shipDate, bool updateGoogleCheckout) { this.ShipDate = shipDate; this.Save(); //FORCE ASSOCIATED ORDER TO RELOAD FROM DATABASE this._Order = OrderDataSource.Load(this.OrderId, false); //TRIGGER THE SHIPMENT SHIPPED EVENT Stores.StoreEventEngine.ShipmentShipped(this); //RECALCULATE SHIPMENT STATUS this.Order.RecalculateShipmentStatus(); //if the order was a google checkout order, update gooogle checkout if (updateGoogleCheckout) { if (!string.IsNullOrEmpty(this.Order.GoogleOrderNumber)) { GoogleCheckout instance = GoogleCheckout.GetInstance(); TrackingNumber number = GetLastTrackingNumber(); string carrier = GetGCCarrier(number); string trNumber = (number == null || string.IsNullOrEmpty(number.TrackingNumberData)) ? null : number.TrackingNumberData; instance.AddTrackingData(this.Order.GoogleOrderNumber, carrier, trNumber); //If order has not yet shipped completely, notify that it is under processing if (this.Order.ShipmentStatus == OrderShipmentStatus.Unshipped || this.Order.ShipmentStatus == OrderShipmentStatus.Unspecified) { instance.ProcessOrder(this.Order.GoogleOrderNumber); } } } }
/// <summary> /// Processes an order cancelled event /// </summary> /// <param name="order">Order that has been cancelled</param> public static void OrderCancelled(Order order) { order.Notes.Add(new OrderNote(order.OrderId, order.UserId, LocaleHelper.LocalNow, Properties.Resources.OrderCancelled, NoteType.SystemPrivate)); order.Notes.Save(); UpdateOrderStatus(StoreEvent.OrderCancelled, order); //if this is a google checkout order update google checkout if (!string.IsNullOrEmpty(order.GoogleOrderNumber)) { GoogleCheckout instance = GoogleCheckout.GetInstance(); string comment = order.GetLastPublicNote(); if (string.IsNullOrEmpty(comment)) { comment = "N/A"; } instance.CancelOrder(order.GoogleOrderNumber, comment); } // DELETE ALL ASSOCIATED SUBSCRIPTIONS SubscriptionDataSource.DeleteForOrder(order.OrderId); Hashtable parameters = new Hashtable(); parameters["order"] = order; parameters["customer"] = order.User; parameters["payments"] = order.Payments; ProcessEmails(StoreEvent.OrderCancelled, parameters); }
/// <summary> /// Processes an order shipped event /// </summary> /// <param name="order">Order that has been shipped</param> public static void OrderShipped(Order order) { order.Notes.Add(new OrderNote(order.OrderId, order.UserId, LocaleHelper.LocalNow, Properties.Resources.OrderShipped, NoteType.SystemPrivate)); order.Notes.Save(); order.ShipmentStatus = OrderShipmentStatus.Shipped; order.Save(); UpdateOrderStatus(StoreEvent.OrderShipped, order); //if the order was a google checkout order, update gooogle checkout if (!string.IsNullOrEmpty(order.GoogleOrderNumber)) { GoogleCheckout instance = GoogleCheckout.GetInstance(); TrackingNumber number = order.GetLastTrackingNumber(); instance.DeliverOrder(order.GoogleOrderNumber, number); } Hashtable parameters = new Hashtable(); parameters["order"] = order; parameters["customer"] = order.User; parameters["payments"] = order.Payments; ProcessEmails(StoreEvent.OrderShipped, parameters); }