Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/API/Grand.Api/Controllers/TokenWebController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public TokenWebController(
[HttpPost]
public async Task<IActionResult> Guest()
{
var customer = await _customerService.InsertGuestCustomer(_storeHelper.HostStore);
var customer = await _customerService.InsertGuestCustomer(_storeHelper.StoreHost);
var claims = new Dictionary<string, string> {
{ "Guid", customer.CustomerGuid.ToString()}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ private async Task<StringBuilder> PrepareFormattedAttribute(Product product, ILi
fileName = WebUtility.HtmlEncode(fileName);
if (allowHyperlinks)
{
var downloadLink = string.Format("{0}/download/getfileupload/?downloadId={1}", _workContext.CurrentStore.Url.TrimEnd('/'), download.DownloadGuid);
var downloadLink = string.Format("{0}/download/getfileupload/?downloadId={1}", _workContext.CurrentHost.Url.TrimEnd('/'), download.DownloadGuid);
attributeText = string.Format("<a href=\"{0}\" class=\"fileuploadattribute\">{1}</a>", downloadLink, fileName);
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public virtual async Task<string> FormatAttributes(IList<CustomAttribute> custom
if (allowHyperlinks)
{
//hyperlinks are allowed
var downloadLink = string.Format("{0}/download/getfileupload/?downloadId={1}", _workContext.CurrentStore.Url.TrimEnd('/'), download.DownloadGuid);
var downloadLink = string.Format("{0}/download/getfileupload/?downloadId={1}", _workContext.CurrentHost.Url.TrimEnd('/'), download.DownloadGuid);
attributeText = string.Format("<a href=\"{0}\" class=\"fileuploadattribute\">{1}</a>", downloadLink, fileName);
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ public static string GenerateUrl(this Affiliate affiliate, IWorkContext workCont
if (workContext == null)
throw new ArgumentNullException(nameof(workContext));

var storeUrl = workContext.CurrentStore.Url.TrimEnd('/');
var url = !String.IsNullOrEmpty(affiliate.FriendlyUrlName) ?
var storeUrl = workContext.CurrentHost == null ? workContext.CurrentStore.Url : workContext.CurrentHost.Url.TrimEnd('/');
var url = !string.IsNullOrEmpty(affiliate.FriendlyUrlName) ?
CommonExtensions.ModifyQueryString(storeUrl, "affiliate", affiliate.FriendlyUrlName) : CommonExtensions.ModifyQueryString(storeUrl, "affiliateid", affiliate.Id);

return url;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Grand.Infrastructure;

namespace Grand.Business.Marketing.Services.Campaigns
{
Expand All @@ -33,6 +34,7 @@ public partial class CampaignService : ICampaignService
private readonly ICustomerActivityService _customerActivityService;
private readonly ITranslationService _translationService;
private readonly ILanguageService _languageService;
private readonly IWorkContext _workContext;

public CampaignService(IRepository<Campaign> campaignRepository,
IRepository<CampaignHistory> campaignHistoryRepository,
Expand All @@ -44,7 +46,8 @@ public CampaignService(IRepository<Campaign> campaignRepository,
IMediator mediator,
ICustomerActivityService customerActivityService,
ITranslationService translationService,
ILanguageService languageService)
ILanguageService languageService,
IWorkContext workContext)
{
_campaignRepository = campaignRepository;
_campaignHistoryRepository = campaignHistoryRepository;
Expand All @@ -59,6 +62,7 @@ public CampaignService(IRepository<Campaign> campaignRepository,
_customerActivityService = customerActivityService;
_translationService = translationService;
_languageService = languageService;
_workContext = workContext;
}

/// <summary>
Expand Down Expand Up @@ -326,11 +330,11 @@ public virtual async Task<int> SendCampaign(Campaign campaign, EmailAccount emai
store = (await _storeService.GetAllStores()).FirstOrDefault();

builder.AddStoreTokens(store, language, emailAccount)
.AddNewsLetterSubscriptionTokens(subscription, store);
.AddNewsLetterSubscriptionTokens(subscription, store, _workContext.CurrentHost);

if (customer != null)
{
builder.AddCustomerTokens(customer, store, language)
builder.AddCustomerTokens(customer, store, _workContext.CurrentHost, language)
.AddShoppingCartTokens(customer, store, language);
}

Expand Down Expand Up @@ -392,7 +396,7 @@ public virtual async Task SendCampaign(Campaign campaign, EmailAccount emailAcco
var customer = await _customerService.GetCustomerByEmail(email);
if (customer != null)
{
builder.AddCustomerTokens(customer, store, language)
builder.AddCustomerTokens(customer, store, _workContext.CurrentHost, language)
.AddShoppingCartTokens(customer, store, language);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public virtual async Task<string> FormatAttributes(
if (allowHyperlinks)
{
//hyperlinks are allowed
var downloadLink = string.Format("{0}download/getfileupload/?downloadId={1}", _workContext.CurrentStore.Url.TrimEnd('/'), download.DownloadGuid);
var downloadLink = string.Format("{0}/download/getfileupload/?downloadId={1}", _workContext.CurrentHost.Url.TrimEnd('/'), download.DownloadGuid);
attributeText = string.Format("<a href=\"{0}\" class=\"fileuploadattribute\">{1}</a>", downloadLink, fileName);
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ protected async Task<bool> SendEmail(Customer customer, CustomerReminder custome

var builder = new LiquidObjectBuilder(_mediator);
builder.AddStoreTokens(store, language, emailAccount)
.AddCustomerTokens(customer, store, language)
.AddCustomerTokens(customer, store, null, language)
.AddShoppingCartTokens(customer, store, language);

LiquidObject liquidObject = await builder.BuildAsync();
Expand Down Expand Up @@ -171,9 +171,9 @@ protected async Task<bool> SendEmail(Customer customer, Order order, CustomerRem

var builder = new LiquidObjectBuilder(_mediator);
builder.AddStoreTokens(store, language, emailAccount)
.AddCustomerTokens(customer, store, language)
.AddCustomerTokens(customer, store, null, language)
.AddShoppingCartTokens(customer, store, language)
.AddOrderTokens(order, customer, await _storeService.GetStoreById(order.StoreId));
.AddOrderTokens(order, customer, await _storeService.GetStoreById(order.StoreId), null);

var liquidObject = await builder.BuildAsync();
var body = LiquidExtensions.Render(liquidObject, reminderLevel.Body);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class GetMerchandiseReturnTokensCommand : IRequest<LiquidMerchandiseRetur
public MerchandiseReturn MerchandiseReturn { get; set; }
public Store Store { get; set; }
public Order Order { get; set; }
public DomainHost Host { get; set; }
public Language Language { get; set; }
public MerchandiseReturnNote MerchandiseReturnNote { get; set; } = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class GetOrderTokensCommand : IRequest<LiquidOrder>
public Order Order { get; set; }
public Customer Customer { get; set; }
public Store Store { get; set; }
public DomainHost Host { get; set; }
public OrderNote OrderNote { get; set; } = null;
public Vendor Vendor { get; set; } = null;
public double RefundedAmount { get; set; } = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class GetShipmentTokensCommand : IRequest<LiquidShipment>
public Shipment Shipment { get; set; }
public Order Order { get; set; }
public Store Store { get; set; }
public DomainHost Host { get; set; }
public Language Language { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ namespace Grand.Business.Messages.DotLiquidDrops
{
public partial class LiquidAskQuestion : Drop
{
private string message;
private string email;
private string fullName;
private string phone;
private readonly string message;
private readonly string email;
private readonly string fullName;
private readonly string phone;

public LiquidAskQuestion(string message, string email, string fullName, string phone)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Grand.Business.Messages.DotLiquidDrops
{
public partial class LiquidAttributeCombination : Drop
{
private ProductAttributeCombination _combination;
private readonly ProductAttributeCombination _combination;

public LiquidAttributeCombination(ProductAttributeCombination combination)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ namespace Grand.Business.Messages.DotLiquidDrops
{
public partial class LiquidAuctions : Drop
{
private Product _product;
private Bid _bid;
private readonly Product _product;
private readonly Bid _bid;

public LiquidAuctions(Product product, Bid bid = null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,24 @@ namespace Grand.Business.Messages.DotLiquidDrops
{
public partial class LiquidBlogComment : Drop
{
private BlogComment _blogComment;
private BlogPost _blogPost;
private Store _store;
private readonly BlogComment _blogComment;
private readonly BlogPost _blogPost;
private readonly Store _store;
private readonly DomainHost _host;
private readonly Language _language;
public LiquidBlogComment(BlogComment blogComment, BlogPost blogPost, Store store, Language language)

private string url;

public LiquidBlogComment(BlogComment blogComment, BlogPost blogPost, Store store, DomainHost host, Language language)
{
_blogComment = blogComment;
_blogPost = blogPost;
_store = store;
_host = host;
_language = language;

url = _host?.Url.Trim('/') ?? (_store.SslEnabled ? _store.SecureUrl.Trim('/') : _store.Url.Trim('/'));

AdditionalTokens = new Dictionary<string, string>();
}

Expand All @@ -31,7 +39,15 @@ public string BlogPostURL
{
get
{
return $"{(_store.SslEnabled ? _store.SecureUrl.Trim('/') : _store.Url.Trim('/'))}/{_blogPost.GetSeName(_language.Id)}";
return $"{url}/{_blogPost.GetSeName(_language.Id)}";
}
}

public string BlogPostCommentText
{
get
{
return _blogComment?.CommentText;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ namespace Grand.Business.Messages.DotLiquidDrops
{
public partial class LiquidContactUs : Drop
{
private string senderEmail;
private string senderName;
private string body;
private string attributeDescription;
private readonly string senderEmail;
private readonly string senderName;
private readonly string body;
private readonly string attributeDescription;

public LiquidContactUs(string senderEmail, string senderName, string body, string attributeDescription)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,18 @@ namespace Grand.Business.Messages.DotLiquidDrops
{
public partial class LiquidCustomer : Drop
{
private Customer _customer;
private CustomerNote _customerNote;
private Store _store;

public LiquidCustomer(Customer customer, Store store, CustomerNote customerNote = null)
private readonly Customer _customer;
private readonly CustomerNote _customerNote;
private readonly Store _store;
private readonly DomainHost _host;
private readonly string url;
public LiquidCustomer(Customer customer, Store store, DomainHost host, CustomerNote customerNote = null)
{
_customer = customer;
_customerNote = customerNote;
_store = store;
_host = host;
url = _host?.Url.Trim('/') ?? (_store.SslEnabled ? _store.SecureUrl.Trim('/') : _store.Url.Trim('/'));
AdditionalTokens = new Dictionary<string, string>();
}

Expand Down Expand Up @@ -105,17 +108,17 @@ public string VatNumberStatus

public string PasswordRecoveryURL
{
get { return string.Format("{0}/passwordrecovery/confirm?token={1}&email={2}", (_store.SslEnabled ? _store.SecureUrl.Trim('/') : _store.Url.Trim('/')), _customer.GetUserFieldFromEntity<string>(SystemCustomerFieldNames.PasswordRecoveryToken), WebUtility.UrlEncode(_customer.Email)); }
get { return string.Format("{0}/passwordrecovery/confirm?token={1}&email={2}", url, _customer.GetUserFieldFromEntity<string>(SystemCustomerFieldNames.PasswordRecoveryToken), WebUtility.UrlEncode(_customer.Email)); }
}

public string AccountActivationURL
{
get { return string.Format("{0}/account/activation?token={1}&email={2}", (_store.SslEnabled ? _store.SecureUrl.Trim('/') : _store.Url.Trim('/')), _customer.GetUserFieldFromEntity<string>(SystemCustomerFieldNames.AccountActivationToken), WebUtility.UrlEncode(_customer.Email)); ; }
get { return string.Format("{0}/account/activation?token={1}&email={2}", url, _customer.GetUserFieldFromEntity<string>(SystemCustomerFieldNames.AccountActivationToken), WebUtility.UrlEncode(_customer.Email)); ; }
}

public string WishlistURLForCustomer
{
get { return string.Format("{0}/wishlist/{1}", (_store.SslEnabled ? _store.SecureUrl.Trim('/') : _store.Url.Trim('/')), _customer.CustomerGuid); }
get { return string.Format("{0}/wishlist/{1}", url, _customer.CustomerGuid); }
}

public string NewNoteText
Expand All @@ -130,7 +133,7 @@ public string NewTitleText

public string CustomerNoteAttachmentUrl
{
get { return string.Format("{0}/download/customernotefile/{1}", (_store.SslEnabled ? _store.SecureUrl.Trim('/') : _store.Url.Trim('/')), _customerNote.Id); }
get { return string.Format("{0}/download/customernotefile/{1}", url, _customerNote.Id); }
}

public string Token
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace Grand.Business.Messages.DotLiquidDrops
{
public partial class LiquidEmail : Drop
{
private string _emailId { get; set; }
private readonly string _emailId;

public LiquidEmail(string emailId)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ namespace Grand.Business.Messages.DotLiquidDrops
{
public partial class LiquidEmailAFriend : Drop
{
private string _personalMessage;
private string _customerEmail;
private string _friendsEmail;
private readonly string _personalMessage;
private readonly string _customerEmail;
private readonly string _friendsEmail;

public LiquidEmailAFriend(string personalMessage, string customerEmail, string friendsEmail)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Grand.Business.Messages.DotLiquidDrops
{
public partial class LiquidGiftVoucher : Drop
{
private GiftVoucher _giftVoucher;
private readonly GiftVoucher _giftVoucher;

public LiquidGiftVoucher(GiftVoucher giftVoucher)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,40 @@ namespace Grand.Business.Messages.DotLiquidDrops
{
public partial class LiquidKnowledgebase : Drop
{
private KnowledgebaseArticle _article;
private KnowledgebaseArticleComment _articleComment;
private Store _store;
private Language _language;
private readonly KnowledgebaseArticle _article;
private readonly KnowledgebaseArticleComment _articleComment;
private readonly Store _store;
private readonly DomainHost _host;
private readonly Language _language;

public LiquidKnowledgebase(KnowledgebaseArticle article, KnowledgebaseArticleComment articleComment, Store store, Language language)
private string url;

public LiquidKnowledgebase(KnowledgebaseArticle article, KnowledgebaseArticleComment articleComment, Store store, DomainHost host, Language language)
{
_article = article;
_articleComment = articleComment;
_store = store;
_host = host;
_language = language;

url = _host?.Url.Trim('/') ?? (_store.SslEnabled ? _store.SecureUrl.Trim('/') : _store.Url.Trim('/'));

AdditionalTokens = new Dictionary<string, string>();
}

public string ArticleCommentTitle
public string ArticleTitle
{
get { return _article.Name; }
}
public string ArticleCommentText {
get { return _articleComment.CommentText; }
}

public string ArticleCommentUrl
{
get
{
return $"{(_store.SslEnabled ? _store.SecureUrl.Trim('/') : _store.Url.Trim('/'))}/{_article.GetSeName(_language.Id)}";
return $"{url}/{_article.GetSeName(_language.Id)}";
}
}

Expand Down
Loading