Hi All, I am using Merchello for one of my e-commerce site.I want to add "offer" with each product so while adding any product to basket i am adding offer as an extended data like
I am using Merchello Notification Gateway Provider for Order Confirmation email. I have written following in Order Confirmation email Template {{IterationStart[Invoice.Items]}} {{Item.Name}} {{Item.Sku}} {{Item.UnitPrice}} {{Item.Quantity}} {{Item.TotalPrice}} {{IterationEnd[Invoice.Items]}}
How can i add offer added as extended data into this Iteration? Please reply as soon as possible. Thanks in Advance
This is a lot, harder than it should be. The good news is we have a plan to refactor the notifications to make it easier in the future, but for the time being you will need to create your own notification "Monitor" in your solution - changing the namespace and the class name.
The monitor will resolve so there is no need to modify the Merchello source.
Update the attribute that decorates the class. Create a new GUID and update the first property of the attribute. Merchello uses this internally to create a relationship between the monitor and your message.
You should also change the name (last property) so that it is easy to identify in the Merchello back office.
[MonitorFor("[NEW GUID HERE]", typeof(OrderConfirmationTrigger), "YOUR NAME HERE (Pattern Replace)")]
Since you need to add the offer in the iteration, you can't just add a new pattern so you need to generate the keys for the pattern match.
You could write your own to supplement Merchello's ... so something like
public static IEnumerable<IReplaceablePattern> OfferLineItemReplaceablePatterns(this ILineItemContainer container)
{
var patterns = new List<IReplaceablePattern>();
var token = "Invoice.Items";
var iterateItems =
container.Items.Where(
x => x.LineItemType == LineItemType.Product || x.LineItemType == LineItemType.Custom).ToArray();
for (var i = 0; i < iterateItems.Count(); i++)
{
offerText = iterateItems[i].extendedData.GetValue("offer");
if (!string.IsNullOrWhitespace(offerText)) {
var offerReplace = new ReplaceablePattern(string.Format("{0}.{1}.{2}", token, "Offer", i), string.Format("{0}Item.Offer.{1}{2}", "{{", i, "}}"), offerText);
patterns.Add(offerReplace);
}
}
return patterns.Where(x => x != null);
}
Finally, back in the monitor you created, in the body of the OnNext method somewhere after the formatter is instantiated:
Server Error in '/' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0117: 'Merchello.Core.Formatters.PatternReplaceFormatter' does not contain a definition for 'GetPatternReplaceFormatter'
Source Error:
Line 36:
Line 37: if (!Messages.Any()) return;
Line 38: var formatter = PatternReplaceFormatter.GetPatternReplaceFormatter();
Line 39: // Add the replaceable patterns from the invoice
Line 40: formatter.AddOrUpdateReplaceablePattern(value.Invoice.ReplaceablePatterns(value.CurrencySymbol));
Merchello Extended Data
Hi All, I am using Merchello for one of my e-commerce site.I want to add "offer" with each product so while adding any product to basket i am adding offer as an extended data like
extendedData.SetValue("offer", Convert.ToString(Umbraco.StripHtml(offer)));
Offer is just a text.
I am using Merchello Notification Gateway Provider for Order Confirmation email. I have written following in Order Confirmation email Template {{IterationStart[Invoice.Items]}} {{Item.Name}} {{Item.Sku}} {{Item.UnitPrice}} {{Item.Quantity}} {{Item.TotalPrice}} {{IterationEnd[Invoice.Items]}}
How can i add offer added as extended data into this Iteration? Please reply as soon as possible. Thanks in Advance
This is a lot, harder than it should be. The good news is we have a plan to refactor the notifications to make it easier in the future, but for the time being you will need to create your own notification "Monitor" in your solution - changing the namespace and the class name. The monitor will resolve so there is no need to modify the Merchello source.
You can use https://github.com/Merchello/Merchello/blob/merchello-dev/src/Merchello.Core/Gateways/Notification/Monitors/OrderConfirmationMonitor.cs as a starting spot.
Update the attribute that decorates the class. Create a new GUID and update the first property of the attribute. Merchello uses this internally to create a relationship between the monitor and your message.
You should also change the name (last property) so that it is easy to identify in the Merchello back office.
Since you need to add the offer in the iteration, you can't just add a new pattern so you need to generate the keys for the pattern match.
Here is the extension Merchello uses as a reference : https://github.com/Merchello/Merchello/blob/merchello-dev/src/Merchello.Core/Models/LineItemExtensions.cs#L428
You could write your own to supplement Merchello's ... so something like
Finally, back in the monitor you created, in the body of the
OnNext
method somewhere after theformatter
is instantiated:add the line
Hi Rusty,
Thanks for your response.
I am getting following compilation error.
Server Error in '/' Application. Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0117: 'Merchello.Core.Formatters.PatternReplaceFormatter' does not contain a definition for 'GetPatternReplaceFormatter'
Source Error:
Line 36: Line 37: if (!Messages.Any()) return; Line 38: var formatter = PatternReplaceFormatter.GetPatternReplaceFormatter(); Line 39: // Add the replaceable patterns from the invoice Line 40: formatter.AddOrUpdateReplaceablePattern(value.Invoice.ReplaceablePatterns(value.CurrencySymbol));
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion