Ejemplo n.º 1
0
        internal void UpdateOrderStatus(Order order, OrderStatusName orderStatusName, PaymentStatusName paymentStatusName)
        {
            OrderStatusName   oldOrderStatus   = order.OrderStatus;
            PaymentStatusName oldPaymentStatus = order.PaymentStatus;

            order.PaymentStatus = paymentStatusName;
            order.OrderStatus   = orderStatusName;

            //if (order.PaymentStatus == PaymentStatusName.Completed && !(order.OrderStatus == OrderStatusName.Paid || order.OrderStatus == OrderStatusName.Completed))
            //{
            //    order.OrderStatus = OrderStatusName.Paid;
            //}

            order.Save();

            if (oldPaymentStatus != paymentStatusName)
            {
                //--- Payment Status has changed...
                if (paymentStatusName == PaymentStatusName.Completed && WA.Parser.ToBool(storeContext.CurrentStore.GetSetting(StoreSettingNames.SendPaymentCompleteEmail)).GetValueOrDefault(true))
                {
                    // send "PaymentCompleted" email
                    EmailController             emailController = new EmailController();
                    TokenHelper                 tokenHelper     = new TokenHelper(storeContext);
                    Dictionary <string, string> emailTokens     = tokenHelper.GetOrderTokens(order, true);

                    string emailResponse = emailController.SendEmailTemplate(EmailTemplateNames.PaymentCompleted, emailTokens, order.CustomerEmail, order.UpToStoreByStoreId);
                }
            }
            if (oldOrderStatus != orderStatusName)
            {
                // TODO Order Status has changed... send emails ??
            }
        }
        private void SendOrderEmails(CheckoutResult checkoutResult, Order submittedOrder, Dictionary <string, string> orderTokens)
        {
            try
            {
                EmailController emailController = new EmailController();

                string adminEmailResponse = emailController.SendEmailTemplate(EmailTemplateNames.OrderReceivedAdmin, orderTokens, storeContext.CurrentStore.GetSetting(StoreSettingNames.OrderCompletedEmailRecipient), storeContext.CurrentStore);
                if (WA.Parser.ToBool(storeContext.CurrentStore.GetSetting(StoreSettingNames.SendOrderReceivedEmail)).GetValueOrDefault(true))
                {
                    string emailResponse = emailController.SendEmailTemplate(EmailTemplateNames.OrderReceived, orderTokens, submittedOrder.CustomerEmail, storeContext.CurrentStore);

                    if (!string.IsNullOrEmpty(emailResponse))
                    {
                        checkoutResult.Warnings.Add(string.Format(@"Something went wrong when we tried to email your order receipt. {0}", emailResponse));
                    }
                }
            }
            catch (Exception ex)
            {
                checkoutResult.Warnings.Add(string.Format(@"Something went wrong when we tried to email your order receipt. {0}", ex.Message));
            }
        }
Ejemplo n.º 3
0
        internal void SendShippingEmail(Order order)
        {
            // send "shipping update" email...
            try
            {
                TokenHelper tokenHelper = new TokenHelper(this.storeContext);
                var         tokens      = tokenHelper.GetOrderTokens(order, true);

                EmailController emailer = new EmailController();
                emailer.SendEmailTemplate(EmailTemplateNames.ShippingUpdate, tokens, order.CustomerEmail, this.storeContext.CurrentStore);
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
            }
        }