/// <summary> /// Allow products to be searched via the built-in DNN Search /// </summary> /// <param name="moduleInfo"></param> /// <returns></returns> public DotNetNuke.Services.Search.SearchItemInfoCollection GetSearchItems(ModuleInfo moduleInfo) { SearchItemInfoCollection searchItemCollection = new SearchItemInfoCollection(); InitializeEntitySpaces(); int portalId = moduleInfo.PortalID; int moduleId = moduleInfo.ModuleID; // We need to always use the same ModuleID because DNN calls this method for each instance of our module that exists. // If we did NOT do this, there would be duplicate Products in the search results List <TabModuleMatch> moduleTabs = DnnHelper.GetTabsWithModuleByModuleDefinitionName(portalId, ModuleDefs.MainDispatch.DefinitionName); if (moduleTabs.Count > 0) { moduleId = moduleTabs[0].ModuleId; } DataModel.Store store = DataModel.Store.GetStoreByPortalId(portalId); if (store != null) { List <Product> allProductsInStore = ProductCollection.GetAll(store.Id.Value, true); foreach (Product p in allProductsInStore) { string description = ""; List <ProductDescriptor> descriptors = p.GetProductDescriptors(); if (descriptors.Count > 0) { description = descriptors[0].TextHtmlDecoded; } //string searchKey = p.Id.Value.ToString(); string searchKey = "DNNspot-Store-Product-" + p.Id.Value.ToString(); string searchContent = p.Name + " " + description; SearchItemInfo searchItem = new SearchItemInfo( p.Name, description.StripHtmlTags().ChopAtWithSuffix(200, "..."), Null.NullInteger, p.ModifiedOn.Value, moduleId, searchKey, searchContent, "product=" + p.Id.Value.ToString() ); searchItemCollection.Add(searchItem); } } return(searchItemCollection); }
private static DataModel.Store CreateInitialStoreForPortal(PortalSettings portalSettings) { //--- Create the Store for this Portal DataModel.Store newStore = new DataModel.Store(); newStore.PortalId = portalSettings.PortalId; newStore.Name = portalSettings.PortalName; newStore.Save(); //--- Set some sensible default settings newStore.UpdateSetting(StoreSettingNames.OrderCompletedEmailRecipient, portalSettings.Email); newStore.UpdateSetting(StoreSettingNames.CustomerServiceEmailAddress, portalSettings.Email); //--- Copy over the default email templates newStore.AddMissingEmailTemplates(); //--- Set the default payment processor to 'CardCaptureOnly' CardCaptureOnlyPaymentProvider cardCapturePaymentProvider = new CardCaptureOnlyPaymentProvider(newStore.GetPaymentProviderConfig(PaymentProviderName.CardCaptureOnly)); cardCapturePaymentProvider.IsEnabled = true; newStore.UpdatePaymentProviderConfig(cardCapturePaymentProvider.GetConfiguration()); //--- Add a default shipping service and rate type var newShippingService = new DataModel.ShippingService(); newShippingService.StoreId = newStore.Id.Value; newShippingService.ShippingProviderType = (short)ShippingProviderType.CustomShipping; newShippingService.Save(); Dictionary <string, string> settings = newShippingService.GetSettingsDictionary(); settings["IsEnabled"] = true.ToString(); newShippingService.UpdateSettingsDictionary(settings); var newRateType = new DataModel.ShippingServiceRateType(); newRateType.ShippingServiceId = newShippingService.Id.Value; newRateType.Name = "Standard"; newRateType.DisplayName = "Standard"; newRateType.Save(); var fedexService = new DataModel.ShippingService(); fedexService.StoreId = newStore.Id.Value; fedexService.ShippingProviderType = (short)ShippingProviderType.FedEx; fedexService.Save(); Dictionary <string, string> fedexSettings = fedexService.GetSettingsDictionary(); fedexSettings["IsEnabled"] = false.ToString(); fedexService.UpdateSettingsDictionary(fedexSettings); return(newStore); }
internal Dictionary <string, string> GetOrderTokens(Order order, bool isEmail) { //StoreContext fakeContext = new StoreContext(HttpContext.Current.Request); //StoreUrls storeUrls = new StoreUrls(fakeContext); Dictionary <string, string> tokens = new Dictionary <string, string>(); DataModel.Store store = order.UpToStoreByStoreId; tokens["store.name"] = store.Name; string customerServiceEmail = store.GetSetting(StoreSettingNames.CustomerServiceEmailAddress); if (!string.IsNullOrEmpty(customerServiceEmail)) { tokens["store.contactemail"] = customerServiceEmail; } tokens["customer.userid"] = order.UserId.HasValue ? order.UserId.Value.ToString() : "anonymous"; tokens["customer.firstname"] = order.CustomerFirstName; tokens["customer.lastname"] = order.CustomerLastName; tokens["customer.email"] = order.CustomerEmail; tokens["order.number"] = order.OrderNumber; tokens["order.status"] = order.OrderStatus.ToString(); tokens["order.payment.status"] = order.PaymentStatus.ToString(); tokens["order.payment.summary"] = isEmail ? order.PaymentSummaryForEmail : order.PaymentSummary; tokens["order.date"] = order.CreatedOn.Value.ToString(); tokens["order.date.monthname"] = order.CreatedOn.Value.ToString("MMMM"); tokens["order.date.day"] = order.CreatedOn.Value.Day.ToString(); tokens["order.date.year"] = order.CreatedOn.Value.Year.ToString(); tokens["order.subtotal"] = storeContext.CurrentStore.FormatCurrency(order.SubTotal.GetValueOrDefault(0)); tokens["order.shippingcost"] = storeContext.CurrentStore.FormatCurrency(order.ShippingAmount.GetValueOrDefault(0)); tokens["order.discount"] = storeContext.CurrentStore.FormatCurrency(order.DiscountAmount.GetValueOrDefault(0)); tokens["order.couponcodes"] = order.GetCoupons().ToDelimitedString(", ", t => t.CouponCode); tokens["order.tax"] = storeContext.CurrentStore.FormatCurrency(order.TaxAmount.GetValueOrDefault(0)); tokens["order.total"] = storeContext.CurrentStore.FormatCurrency(order.Total.GetValueOrDefault(0)); tokens["order.billing.address1"] = order.BillAddress1; tokens["order.billing.address2"] = order.BillAddress2; tokens["order.billing.city"] = order.BillCity; tokens["order.billing.region"] = order.BillRegion; tokens["order.billing.postalcode"] = order.BillPostalCode; tokens["order.billing.countrycode"] = order.BillCountryCode; tokens["order.billing.telephone"] = order.BillTelephone; tokens["order.billing.creditcardtype"] = order.CreditCardType; tokens["order.billing.creditcardlast4"] = order.CreditCardNumberLast4; tokens["order.billing.creditcardexpiration"] = order.CreditCardExpiration; tokens["order.shipping.recipientname"] = order.ShipRecipientName + (!string.IsNullOrEmpty(order.ShipRecipientBusinessName) ? "<br />" + order.ShipRecipientBusinessName : ""); tokens["order.shipping.address1"] = order.ShipAddress1; tokens["order.shipping.address2"] = order.ShipAddress2; tokens["order.shipping.city"] = order.ShipCity; tokens["order.shipping.region"] = order.ShipRegion; tokens["order.shipping.postalcode"] = order.ShipPostalCode; tokens["order.shipping.countrycode"] = order.ShipCountryCode; tokens["order.shipping.telephone"] = order.ShipTelephone; tokens["order.shipping.option"] = order.ShippingServiceOption; tokens["order.shipping.cost"] = order.ShippingAmount.GetValueOrDefault(0).ToString("C2"); tokens["order.shipping.trackingnumber"] = order.TrackingNumbers.ToDelimitedString(", "); tokens["order.ordernotes"] = order.OrderNotes; List <OrderItem> orderItems = order.OrderItemCollectionByOrderId.ToList(); if (orderItems.Count > 0) { tokens["order.itemsdelim"] = GetOrderItemsDelimitedString(orderItems); tokens["order.itemstable"] = GetOrderItemsTable(order); tokens["order.itemstablenoprice"] = GetOrderItemsTable(order, false); try { tokens["order.itemsjson"] = GetOrderItemsJson(orderItems); } catch (Exception ex) { Exceptions.LogException(ex); if (tokens.ContainsKey("order.itemsjson")) { tokens.Remove("order.itemsjson"); } } } tokens["order.xml"] = XmlHelper.ToXml(order); return(tokens); }
public string SendEmailTemplate(EmailTemplateNames templateName, Dictionary <string, string> tokens, string sendToEmail, DataModel.Store store) { //string storeEmail = storeContext.CurrentStore.GetSetting(StoreSettingNames.OrderCompletedEmailRecipient); string storeEmail = store.GetSetting(StoreSettingNames.OrderCompletedEmailRecipient); string customerServiceEmail = store.GetSetting(StoreSettingNames.CustomerServiceEmailAddress); string hostEmail = HostSettings.GetHostSetting("HostEmail"); string from = !string.IsNullOrEmpty(customerServiceEmail) ? customerServiceEmail : hostEmail; vStoreEmailTemplate emailTemplate = store.GetStoreEmailTemplate(templateName); string subject = tokenizer.ReplaceTokensInString(HttpUtility.HtmlDecode(emailTemplate.SubjectTemplate), tokens); string body = tokenizer.ReplaceTokensInString(HttpUtility.HtmlDecode(emailTemplate.BodyTemplate), tokens); body = InjectEmailCssIntoBody(body); return(SendEmail(from, sendToEmail, subject, body, true)); }