1

My ultimate goal is to include the type of credit card (Visa, Mastercard etc.) into order emails. Assume that customer always chooses to pay with a card.

I tried adding {{var order.getPayment().getCcType()}} in order_new.html email template, but it prints nothing. order variable is set correctly, I can get some other properties of order.getPayment() to display in the email.

In order to debug this, here is what I do in an observer that fires at email_order_set_template_vars_before event:

/** @var Payment $payment */
$payment = $observer->getData('transport')['order']->getPayment();
var_dump($payment->getCcType());
die;

Then I go to Admin panel, choose an order I placed that is to be paid with a credit card, and press "Send email" at the order page, to resend the email a test customer should have received. The observer (code above) prints NULL.

I don't know what else I can try. Why is $payment->getCcType() NULL when I chose a credit card?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.