Ejemplo n.º 1
0
        public int SendCustomerNotice(Order order, string licenseTable, int languageId)
        {
            if (order == null)
            {
                throw new ArgumentNullException("order");
            }

            var store = _storeService.GetStoreById(order.StoreId) ?? _storeContext.CurrentStore;

            languageId = EnsureLanguageIsActive(languageId, store.Id);

            var messageTemplate = GetLocalizedActiveMessageTemplate("Nop.Misc.Licenses.Customer.SendLicense", languageId, store.Id);

            if (messageTemplate == null)
            {
                return(0);
            }
            //email account
            var emailAccount = GetEmailAccountOfMessageTemplate(messageTemplate, languageId);

            //tokens
            var tokens = new List <Token>();

            _messageTokenProvider.AddStoreTokens(tokens, store, emailAccount);
            _messageTokenProvider.AddOrderTokens(tokens, order, languageId);
            _messageTokenProvider.AddCustomerTokens(tokens, order.Customer);
            tokens.Add(new Token("LicenseTable", licenseTable, true));

            var toEmail = order.BillingAddress.Email;
            var toName  = string.Format("{0} {1}", order.BillingAddress.FirstName, order.BillingAddress.LastName);

            return(SendNotification(messageTemplate, emailAccount,
                                    languageId, tokens,
                                    toEmail, toName));
        }
Ejemplo n.º 2
0
        private IList <Token> GenerateTokens(Order order, int languageId)
        {
            var tokens = new List <Token>();

            _messageTokenProvider.AddStoreTokens(tokens);
            _messageTokenProvider.AddOrderTokens(tokens, order, languageId);

            return(tokens);
        }
Ejemplo n.º 3
0
        private IList <Token> GenerateTokens(Order order, int languageId, bool ShowCheckOutAttribute)
        {
            var tokens = new List <Token>();

            _messageTokenProvider.AddStoreTokens(tokens);
            _messageTokenProvider.AddOrderTokens(tokens, order, languageId, ShowCheckOutAttribute);
            _messageTokenProvider.AddCustomerTokens(tokens, order.Customer);

            return(tokens);
        }
        /// <summary>
        /// Method to send error notification to store owner
        /// </summary>
        /// <param name="order"></param>
        /// <param name="languageId"></param>
        /// <param name="nopShiprocketOrder"></param>
        /// <returns></returns>
        public virtual int SendOrderShiprocketErrorStoreOwnerNotification(Order order, int languageId, NopShiprocketOrder nopShiprocketOrder)
        {
            if (order == null)
            {
                throw new ArgumentNullException(nameof(order));
            }

            var store = _storeService.GetStoreById(order.StoreId) ?? _storeContext.CurrentStore;

            languageId = EnsureLanguageIsActive(languageId, store.Id);

            var messageTemplates = GetActiveMessageTemplates(MessageTemplateSystemNames.OrderPlacedStoreOwnerNotification, store.Id);

            if (!messageTemplates.Any())
            {
                return(0);
            }

            //email account
            var emailAccount = GetEmailAccountOfMessageTemplate(messageTemplates.FirstOrDefault(), languageId);

            //tokens
            var tokens = new List <Token>();

            _messageTokenProvider.AddStoreTokens(tokens, store, emailAccount);
            _messageTokenProvider.AddOrderTokens(tokens, order, languageId);
            _messageTokenProvider.AddCustomerTokens(tokens, _customerService.GetCustomerById(order.CustomerId));

            //event notification
            _eventPublisher.MessageTokensAdded(messageTemplates.FirstOrDefault(), tokens);

            var toEmail = emailAccount.Email;
            var toName  = emailAccount.DisplayName;

            return(SendErrorNotification(messageTemplates.FirstOrDefault(), emailAccount, languageId, tokens, toEmail, toName, null, null, null, null, null, null, null, nopShiprocketOrder));
        }