Is there anyway to send an email to the customer, when an order has been completed in Umbraco. Atm I am sending a mail when I call CommerceLibrary:Checkout() in my xslt. But I would also like to send an email, when the order has been handled by the merchant.
I have set up an email profile in Umbraco, and tried to connect it to "ToCompletedOrder.config" like so (but I am not sure I am doing it right, or at the right place):
<configuration> <components> <!-- Pipeline Instance --> <component id="ToCompletedOrder" service="UCommerce.Pipelines.IPipeline`1[[UCommerce.EntitiesV2.PurchaseOrder, UCommerce]], UCommerce" type="UCommerce.Pipelines.OrderProcessing.OrderProcessingPipeline, UCommerce.Pipelines" lifestyle="Thread"> <parameters> <tasks> <value>${ToCompletedOrder.SendPayedEmail}</value> <!-- Payment processing vendors ussually require additional subscription fees for you to be able to access their API. Please consult your agreement to see if API access is supported for your particular plan. --> <!--<value>${ToCompletedOrder.AcquirePaymentTask}</value>--> </array> </tasks> </parameters> </component> <!-- Pipeline Tasks--> <component id="ToCompletedOrder.AcquirePaymentTask" service="UCommerce.Pipelines.IPipelineTask`1[[UCommerce.EntitiesV2.PurchaseOrder, UCommerce]], UCommerce" type="UCommerce.Pipelines.OrderProcessing.AcquirePaymentTask, UCommerce.Pipelines" lifestyle="Thread" /> <component id="ToCompletedOrder.SendPayedEmail" service="UCommerce.Pipelines.IPipelineTask`1[[UCommerce.EntitiesV2.PurchaseOrder, UCommerce]], UCommerce" type="UCommerce.Pipelines.Common.SendEmailTask, UCommerce.Pipelines" lifestyle="Thread"> <parameters> <emailTypeName>OrderPayedEmail</emailTypeName> </parameters> </component> </components> </configuration>
I get this error i Umbraco when I try to change the order status (Even though the order changes status)
[InvalidOperationException: No product catalog group supporting the url "http://mywebsitet.com:80/umbraco/ucommerce/orders/changeorderstatus.aspx?id=352&rndo=13" found.]
[PipelineException: Exception occoured while processing pipeline 'UCommerce.Pipelines.OrderProcessing.OrderProcessingPipeline'. See inner exception for details.]
The config of your pipeline task is correct as the pipeline is getting called as expected.
The SendEmail task is trying to find the current product catalog group, which is not available from in the backend unless you're running the admin console on the same domain as the frontend.
You have a couple of options to fix this:
1) Have the backend run on the same domain name as the frontend
2) Override the ICatalogContext to provide the current catalog group name even in a context when the URL is not available.
I'll log a work item to support this scenario better going forward.
You can inherit the CatalogContext class and override the CurrentCatalogName, CurrentCatalogGroupName.
Here's some code:
class MyCustomCatalogContext : CatalogContext { public override string CurrentCatalogGroupName { // Use default if present, or use the first catalog available otherwise return base.CurrentCatalogGroupName ?? ProductCatalogGroup.All().First().Name; } }
With that done you just have to register the MyCustomCatalogContext in /umbraco/ucommerce/components.config replacing the existing one.
BTW the fix for this is available in uCommerce 3.0.0.12286 if you don't want to mess around with it.
Im new to .NET, but I would like to try it out for our problem.
I'm working in Mono instead of Visual Studio, and I got this code so far:
using System; using UCommerce.Runtime; using UCommerce.EntitiesV2; using System.Linq;
class MyCustomCatalogContext : CatalogContext { publicoverridestring CurrentCatalogGroupName { // Use default if present, or use the first catalog available otherwise returnbase.CurrentCatalogGroupName ?? ProductCatalogGroup.All().First().Name; } }
But I get a "A get or set accessor expected" for the "return" statement
classMyCustomCatalogContext:CatalogContext { publicoverridestringCurrentCatalogGroupName { get { // Use default if present, or use the first catalog available otherwise returnbase.CurrentCatalogGroupName??ProductCatalogGroup.All().First().Name; } set { base.CurrentCatalogGroupName = value; } } }
Hi again. Thats great, I was reading up upon get & set properties just now :)
I do get this error now: "The type 'Ucommerce.Runtime.CatalogContext' does not contain a constructor that takes '0' arguments". I can't seem to figure that one out?
I got no error when building the project, if I do this:
using System; using UCommerce.Runtime; using UCommerce.EntitiesV2; using System.Linq; using System.Collections.Generic; using System.Web; using UCommerce.Content;
class MyCustomCatalogContext:CatalogContext { publicoverridestring CurrentCatalogGroupName{
get { returnbase.CurrentCatalogGroupName ?? ProductCatalogGroup.All().First().Name; }
set { base.CurrentCatalogGroupName = value; } } public MyCustomCatalogContext(IContentService contentService) : base(contentService) { }
}
So after copying the "MyCustomCatalogContext.dll" to the bin folder, I am a little confused on how to set up the components.config file.
Steven, thanks for being awesome and posting the solution.
The gist of it is that you need to have constructor on an inheriting class if the inherited class (super class) defines a constructur with params and no empty constructor.
I am still a little confused about how I set up the components.config file. I have tried the following, but with no luck. I dont know if it is the way I try to implement the changes to the componemts.config file, or if it is because I have an error in my C# code. The error I get when I implement it is all of my xslt files fail to execute properly.
Pretty much. uCommerce will migrate your version 2 setup.
There are some breaking API changes that you may or may not be affected by depending on which APIs you're using. The code update required is trivial though.
You might want to take a look at Checklist for Updating uCommerce too. It lists all the things you can check to verify the update.
Sending an order complete mail
Hi
Is there anyway to send an email to the customer, when an order has been completed in Umbraco. Atm I am sending a mail when I call CommerceLibrary:Checkout() in my xslt. But I would also like to send an email, when the order has been handled by the merchant.
I have set up an email profile in Umbraco, and tried to connect it to "ToCompletedOrder.config" like so (but I am not sure I am doing it right, or at the right place):
I get this error i Umbraco when I try to change the order status (Even though the order changes status)
[InvalidOperationException: No product catalog group supporting the url "http://mywebsitet.com:80/umbraco/ucommerce/orders/changeorderstatus.aspx?id=352&rndo=13" found.]
UCommerce.Runtime.CatalogContext.FindProductCatalogGroupForDomain() +1061
UCommerce.Runtime.CatalogContext.get_CurrentCatalogSet() +16
UCommerce.Pipelines.Common.SendEmailTask.Execute(PurchaseOrder purchaseOrder) +280
UCommerce.Pipelines.Pipeline`1.Execute(T subject) +178
[PipelineException: Exception occoured while processing pipeline 'UCommerce.Pipelines.OrderProcessing.OrderProcessingPipeline'. See inner exception for details.]
UCommerce.Pipelines.Pipeline`1.Execute(T subject) +488
UCommerce.Transactions.OrderService.ChangeOrderStatus(PurchaseOrder purchaseOrder, OrderStatus newOrderStatus, String userName) +196
UCommerceWeb.Umbraco.UCommerce.Orders.ChangeOrderStatus.SaveOrderStatus() +355
UCommerceWeb.Umbraco.UCommerce.Orders.ChangeOrderStatus.SaveButton_Clicked(Object sender, EventArgs e) +18
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +118
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +112
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1
Hi Steven,
The config of your pipeline task is correct as the pipeline is getting called as expected.
The SendEmail task is trying to find the current product catalog group, which is not available from in the backend unless you're running the admin console on the same domain as the frontend.
You have a couple of options to fix this:
1) Have the backend run on the same domain name as the frontend
2) Override the ICatalogContext to provide the current catalog group name even in a context when the URL is not available.
I'll log a work item to support this scenario better going forward.
Sorry about the inconvenience.
Hey Søren
Thanks for you reply. Can you give an example or an idea to how I can override the ICatalogContext?
/Steven
Sure thing:
You can inherit the CatalogContext class and override the CurrentCatalogName, CurrentCatalogGroupName.
Here's some code:
With that done you just have to register the MyCustomCatalogContext in /umbraco/ucommerce/components.config replacing the existing one.
BTW the fix for this is available in uCommerce 3.0.0.12286 if you don't want to mess around with it.
Hi Søren thanks for you reply!
Im new to .NET, but I would like to try it out for our problem.
I'm working in Mono instead of Visual Studio, and I got this code so far:
using System;
using UCommerce.Runtime;
using UCommerce.EntitiesV2;
using System.Linq;
class MyCustomCatalogContext : CatalogContext
{
public override string CurrentCatalogGroupName
{
// Use default if present, or use the first catalog available otherwise
return base.CurrentCatalogGroupName ?? ProductCatalogGroup.All().First().Name;
}
}
But I get a "A get or set accessor expected" for the "return" statement
Thanks
Sorry. I forgot to include the setter:
Hi again. Thats great, I was reading up upon get & set properties just now :)
I do get this error now: "The type 'Ucommerce.Runtime.CatalogContext' does not contain a constructor that takes '0' arguments".
I can't seem to figure that one out?
Hey Søren
I got no error when building the project, if I do this:
using System;
using UCommerce.Runtime;
using UCommerce.EntitiesV2;
using System.Linq;
using System.Collections.Generic;
using System.Web;
using UCommerce.Content;
class MyCustomCatalogContext:CatalogContext
{
public override string CurrentCatalogGroupName{
get { return base.CurrentCatalogGroupName ?? ProductCatalogGroup.All().First().Name; }
set { base.CurrentCatalogGroupName = value; }
}
public MyCustomCatalogContext(IContentService contentService) : base(contentService) { }
}
So after copying the "MyCustomCatalogContext.dll" to the bin folder, I am a little confused on how to set up the components.config file.
If have tried the following with no luck:
<component id="MyCustomCatalogContext"
service="UCommerce.Runtime.ICatalogContext, UCommerce"
type="UCommerce.Runtime.MyCustomCatalogContext, UCommerce" lifestyle="PerWebRequest"/>
I have outcommentet the original registrered catalogcontext, but the only result I have gotten so far is all of the XSLT functions to give an error :)
Steven, thanks for being awesome and posting the solution.
The gist of it is that you need to have constructor on an inheriting class if the inherited class (super class) defines a constructur with params and no empty constructor.
Hi Søren
Sorry for my late reply.
I am still a little confused about how I set up the components.config file. I have tried the following, but with no luck.
I dont know if it is the way I try to implement the changes to the componemts.config file, or if it is because I have an error in my C# code.
The error I get when I implement it is all of my xslt files fail to execute properly.
<component id="MyCustomCatalogContext" service="UCommerce.Runtime.ICatalogContext, UCommerce" type="UCommerce.Runtime.MyCustomCatalogContext, UCommerce" lifestyle="PerWebRequest"/>
Hi Steven,
I have added a fix to uCommerce 3, which fixes this issue. You might want to consider updating to the latest version.
Hi Søren
Yeah thats also the solution we are heading at :)
I can just download and install the new Ucommerce package, and thats it for an update? :)
Pretty much. uCommerce will migrate your version 2 setup.
There are some breaking API changes that you may or may not be affected by depending on which APIs you're using. The code update required is trivial though.
You might want to take a look at Checklist for Updating uCommerce too. It lists all the things you can check to verify the update.
Thanks Søren
It has been great with all your help :)
is working on a reply...