Hi, what is the best way to get the selected payment method on a completed order.
I need it in the e-mail confirmation so that I can write something like this "Dear customer, thanks for your order. you selected Paylpal as payment method" or whatever payment method the customer selected in the checkout process
I already have the Order in context from this code, so it should be easy:
var orderGuid = new Guid(umbraco.library.RequestQueryString("orderGuid")); var purchaseOrder = PurchaseOrder.All().Single(x => x.OrderGuid == orderGuid);
I know that in newer versions of uCommerce you can find the payment method by using something similar:
var order = PurchaseOrder.All().SingleOrDefault(x => x.OrderGuid == Guid.Empty);
var paymentMethod = order.Payments.FirstOrDefault().PaymentMethod;
var paymentMethodName = paymentMethod.Name;
If your shop supports more than one payment you should iterate over Payments instead. :-)
I've not been able to test the code since I don't have an installtion with uCommerce running 3.x but I'm quite sure it will work.
HI Martin, and thanks. My shop has more then one payment methods, so I can't just take the first or default. I need to find the method that the customer used to check out with.
So if I iterate over payments I need to know what to look for. I think I can find it in the db but thats the last way out :)
You can have multiple payment methods that does not affect the solution. The only case you can't use single/first (orDefault) is if your shop support split payments.
For instance you pay xxx eur with PayPal and then the remaining with a creditcard through DIBS (or some other provider). Unless your shop support this I'm quite sure single/first should do it :)
Get selected payment method on completed order
Hi, what is the best way to get the selected payment method on a completed order.
I need it in the e-mail confirmation so that I can write something like this "Dear customer, thanks for your order. you selected Paylpal as payment method" or whatever payment method the customer selected in the checkout process
I already have the Order in context from this code, so it should be easy:
var orderGuid = new Guid(umbraco.library.RequestQueryString("orderGuid"));
var purchaseOrder = PurchaseOrder.All().Single(x => x.OrderGuid == orderGuid);
I'm running uCommerce 3.6.3
Hi Kim,
I know that in newer versions of uCommerce you can find the payment method by using something similar:
If your shop supports more than one payment you should iterate over Payments instead. :-) I've not been able to test the code since I don't have an installtion with uCommerce running 3.x but I'm quite sure it will work.
Best regards Martin
HI Martin, and thanks. My shop has more then one payment methods, so I can't just take the first or default. I need to find the method that the customer used to check out with.
So if I iterate over payments I need to know what to look for. I think I can find it in the db but thats the last way out :)
Hi Kim,
You can have multiple payment methods that does not affect the solution. The only case you can't use single/first (orDefault) is if your shop support split payments.
For instance you pay xxx eur with PayPal and then the remaining with a creditcard through DIBS (or some other provider). Unless your shop support this I'm quite sure single/first should do it :)
Best regards Martin
is working on a reply...