Hello,

I created a rule to send an email to a "product owner" so they can see a summary of an order. I have just about everything set up, but I don't know how to get the Payment method to show up in the email. I added "Commerce Payment Transaction" as a data type in the rule settings, but I'm not sure what condition to add to bring payment method into scope. "Entity has field" and "entity of type" don't seem to make sense for me.

Any tips?

Thanks in advance!

Here's the rule export:

{ "rules_notify_product_owner_if_field_notify_email_is_present" : {
    "LABEL" : "Notify Product Owner if \u0022field_notify\u0022 email is present",
    "PLUGIN" : "rule",
    "REQUIRES" : [ "rules" ],
    "USES VARIABLES" : {
      "line_item" : { "label" : "Line Item", "type" : "commerce_line_item" },
      "commerce_order" : { "label" : "Commerce order", "type" : "commerce_order" },
      "payment" : { "label" : "Payment", "type" : "commerce_payment_transaction" }
    },
    "IF" : [
      { "entity_has_field" : { "entity" : [ "line-item" ], "field" : "commerce_product" } },
      { "entity_has_field" : { "entity" : [ "line-item:commerce-product" ], "field" : "field_notify" } }
    ],
    "DO" : [
      { "LOOP" : {
          "USING" : { "list" : [ "line-item:commerce-product:field-notify" ] },
          "ITEM" : { "notification_email" : "Notification email" },
          "DO" : [
            { "mail" : {
                "to" : [ "notification-email" ],
                "subject" : "Someone submitted payment for [line-item:line-item-label] on the website!\u000D\u000A",
                "message" : "Someone submitted payment for [line-item:line-item-label] on the website!\u000D\u000A\u000D\u000A[line-item:line-item-label]\u000D\u000A[line-item:commerce_total]\u000D\u000A\u000D\u000A\u000D\u000A\u000D\u000A[line-item:field_contributor_name]\u000D\u000AAd or Memo: \u000D\u000A[line-item:field_ad_text] [line-item:field-memo]\u000D\u000ACustomer info: \u000D\u000A\u000D\u000A[commerce-order:commerce_customer_billing]\u000D\u000A[commerce-order:mail]\u000D\u000A\u000D\u000A~Admin\u000D\u000A-------------------------------------\u000D\u000A[commerce-order:commerce-webform-submission]\u000D\u000A------------------------------------",
                "language" : [ "" ]
              }
            }
          ]
        }
      }
    ]
  }
}

Comments

rszrama’s picture

Title: How to put "Payment method" on an order using Rules in an email » Add a "payment method" token for use in order e-mails
Version: 7.x-1.3 » 7.x-1.x-dev
Component: Order » Payment
Category: support » feature

There really isn't any way to do this outside of code. I suppose what we can do is investigate adding a "payment method" token that could indicate either 1) the payment method selected by the customer in checkout or 2) the payment method corresponding to the first successful payment transaction associated with an order. In Drupal Commerce, though, the "payment method" isn't a property of an order, and any given order may actually have transactions from multiple payment methods (or none at all).

There may be an open issue for this already, so please mark this one or the other duplicate if you see it.

(Also, just to highlight what the issue submission form guidelines state, support requests are not going to be answered in the queue. Future questions should be posted to http://www.drupalcommerce.org/questions instead.)

tevih’s picture

I had no idea this was a feature request. Thought it was a simple thing I just didn't understand how to do. :)

Thanks

rszrama’s picture

No worries, it all worked out. I feel like I've talked someone through this before, so I'm guessing we just didn't make it a full feature request at that time for some reason. Will be happy to try and get this in for 1.4.

rszrama’s picture

Issue tags: +low-hanging fruit

Tagging.

adpo’s picture

I'm using Drupal Commerce 7.x-1.5 and the payment methods tokens still do not exist in emails.
I presume I need to create my own custom tokens for this purpose, as described below:

http://www.drupalfoo.com/drupal-7-creating-custom-token-user-defined-tag

rszrama’s picture

Nope, if it had made it in this would be marked fixed or closed (fixed). ; )

rszrama’s picture

Status: Active » Fixed

However, thanks for reminding me. I just added the tokens [commerce-order:payment-method], [commerce-order:payment-method-title], and [commerce-order:payment-method-short-title].

Commit: http://drupalcode.org/project/commerce.git/commitdiff/3fa8194

adpo’s picture

Thank you rszrama

Automatically closed -- issue fixed for 2 weeks with no activity.

kopeboy’s picture

Status: Closed (fixed) » Needs review

I am sorry to reopen this after long time, but I don't see any payment method token. There is a custom condition in Rules to check if an order has a selected Payment method, but I don't have a token to use in text fields. Am I missing something, or this feature has been erased in later versions, or has never been included in a stable release in 2 years?

My bad. There is some bug I think that won't load my replacement patterns. I went checking another commerce rule and there is a token.

kopeboy’s picture

Status: Needs review » Closed (fixed)