I'm trying to display the customer ID in the emails that Magento send when a logged in customer places a new order.
I read that the next line should work, but it doesn't: {{var customer.ID}}.
I read a lot of forums but I can't find the answer. Any help is very much appreciated!
I got it working (with thanks to Nadir!) withn the following example:
<h1>Hallo {{htmlescape var=$order.getCustomerName()}} (klant-ID: {{var customer.ID}}),</h1>
The customer object is not injected in the new order email template.
You can instead get the customer id from the order variable:
{{var order.getCustomerId()}}
Related
We need to add "Expected delivery date" in Transnational Email of Magento. Can anyone please tell me the predefined variable( or code) for expected delivery date in magento. If there are no predefined variable in magento for expected delivery date. Please tell me the right solution for this.
Thanks
You will have to extract it from order or shipping object then send it to transactional email variable and then you can get that variable in your email template.eb if your variable is var1 then you can get in email template like {{var var1}}.if you can explain it more i can define it more way
Thank you
I modified this once before, but I have forgotten where this part of magento invoice comes from.!
\app\design\frontend\default\MYTHEME\somewhere?
The email template for a new Invoice is located at app/locale/en_US/template/email/invoice_new.html around line 64. I believe the Payment Method content is generated in the following file: app/design/frontend/base/default/template/payment/info/default.phtml.
I've seen a bunch of articles (mostly 3-5 years old) detailing various methods of getting the customer's first name into the order confirmation email but I just get either a blank, or unparsed PHP.
For example this:
<?php echo $this->__('Hello, %s', Mage::getSingleton('customer/session')->getCustomer()->getFirstname()); ?>
Renders in the email like this:
__('Hello, %s', Mage::getSingleton('customer/session')->getCustomer()->getFirstname()); ?>
Could somebody point me in the right direction? This is on Community Edition 1.7.
Thanks
[EDITED] You can't use PHP code in your email-templates directly. If you want to insert dynamic data into your email-templates, you have two possibilities:
a) In every transactional email you can access the methods of the model, which is in charge for the transactional email, it is: for mails dealing with orders, this is the order-Model, for mails dealing with newsletters, this is the newsletter-model and so on. You can access the methods with the syntax:
{{var model.method()}}
So, in your case, to access the customer's first name in an order confirmation email, you need to look for a suiting method in the order Model, which is getCustomerFirstname() .
Then you can call it, following the given syntax:
{{var order.getCustomerFirstname()}}
b) You can include dynamic data into your email-template by creating a custom phtml-template and including it into your email-template via the {{block}} directive (as pointed out by benmarks in the comment below)
I'm trying to display the payment method in the email subject for new order emails in Magento. The reason being is so that our client can easily determine from the subject of emails send from Magento whether the order came via the payment gateway or Paypal Express.
I'm not entirely sure of the best way to achieve this, I would like to think there is already something available I could use for this.
{{var payment_html}}
returns the payment method block for email templates...
{{var paymentMethod}}
returns absolutely nothing in the email subject so unsure whether this is a depreciated variable now.
I suppose there is also the option of creating a custom attribute, calling it in a static block and then displaying this as a custom variable in the email templates but it seems a rather long winded approach just to purely get a text string of "via SagePay" or "via Paypal Express".
Any help would be greatly appreciated.
Thanks in advance.
You actually don't need to perform any customization, this variable is already available in the template though the object chain. This chain is supported by Magento template and allows usage of getters of the object.
In this case you need to retrieve order's payment object, then retrieve its method instance and retrieve method title from method instance. It is very simple construction:
{{var order.getPayment().getMethodInstance().getTitle()}}
This should help you!
Method Mage_Sales_Model_Order::sendNewOrderEmail() is responsible for sending new ordr emails.
$paymentBlock = Mage::helper('payment')->getInfoBlock($this->getPayment())
->setIsSecureMode(true);
$paymentBlock->getMethod()->setStore($storeId);
$paymentBlockHtml = $paymentBlock->toHtml();
...
$mailer->setTemplateParams(array(
'order' => $this,
'billing' => $this->getBillingAddress(),
'payment_html' => $paymentBlockHtml
)
payment_html is rendered html output of the block, so you can not use it.
You can add one more assoc key (using rewite or local/mage trick) with the payment method and add this param to the subject using transactional emails.
Is it possible to show the order details of last processed order, such as
Item Sku Qty Subtotal
in a separate page?
I tried adding the order details section from frontend/base/default/template/email/order/items/order/default.phtml in a separate cms page, by adding {{layout handle="sales_email_order_items" order=$order}} to it.
But, when I run this cms page after order being placed, it shows the following error:
Fatal error: Call to a member function getAllItems() on a non-object in D:\wamp\www\magento\app\design\frontend\base\default\template\email\order\items.phtml
Is this actually possible?
This is possible.. its already present in the magento system, when user places an order successfully they are shown with order number and a link to order details page.
the link to order page is like http://www.example.com/sales/order/view/order_id/25/
we can make system to be redirected directly to this page to accomplish this task.
the only this we needed is the order id this can be get using
Mage::getSingleton("checkout/session")->getLastOrderId();
Yes, most things are possible. You'd have to write your own module, with your own controller which would serve up your own template. There you can load up an order and display whatever you want.
Obviously, that isn't the answer you are hoping for, but your question isn't specific, and writing out how to accomplish what you want could easily take an entire blog article.