Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


These support forums are now closed for new topics and comments.
Please head on over to http://eureka.ucommerce.net/ for support.

  • Kim Søjborg Pedersen 71 posts 275 karma points
    Apr 06, 2015 @ 17:39
    Kim Søjborg Pedersen
    0

    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

     

  • Martin 181 posts 740 karma points
    Apr 07, 2015 @ 20:33
    Martin
    0

    Hi Kim,

    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.

    Best regards Martin

  • Kim Søjborg Pedersen 71 posts 275 karma points
    Apr 08, 2015 @ 08:45
    Kim Søjborg Pedersen
    0

    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 :)

  • Martin 181 posts 740 karma points
    Apr 08, 2015 @ 12:29
    Martin
    100

    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

Please Sign in or register to post replies

Write your reply to:

Draft