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.
Related
Json view of my paypal after payment is made
I am desperately trying to access the description which is under the transactions array but can't seem to find a way!
It's totally different if I want to access payment_method for instance all I do is this:
(By the way, I assigned this array to $method)
$method->payer->payment_method , but the same thing doesn't work if I want to access description. All I get is an error.
I'm using laravel 5.5, in case that makes a difference.
I'm doing this because I need to find a way to reference my product in the final page after the paypal payment has been made.
Looks like transactions in an array so if you would like the description of the first one that would look like this.
$method->transactions[0]->description
I am using magneto 1.9. How to i have change magento shipment email template payment Method block?
If you want to render a specific text/html for a particular payment method in shipment email template only then you have to override sendEmail function of Mage_Sales_Model_Order_Shipment class and play with $paymentBlockHtml variable.
In that function, you can add a condition like
if($order->getPayment()->getMethod()=='cashondelivery'){
$paymentBlockHtml = Mage::helper('sales')->__('Payment after delivery');
}
Hope it helps!
I have found found solution for payment block.
For change payment block need following below steps:
Step 1. Copy app\design\frontend\base\default\template\paygate\info\cc.phtml to app\design\frontend[Your Package][Your Theme]\template\paygate\info\cc.phtml
Step 2. Change here that you want to change
Step 3- Save
I'm working on a website where the client needs to have multiple separate contact forms (one for contact, one for "request a quote", another couple for stuff like that).
I've already managed to create another contact form with additional fields, but it was the contact one, so the fields were only name, email, subject and message.
Now I've got the "skeleton" of the others, but my question is: is there a way to take advantage of the "Contact" backend to send emails? Or do I need to have another controller to manage them?
If so, can you show me some links or piece of code to start off with?
Thanks in advance.
To do what you want, a custom controller is necessary to pass the POST data.
If you examine \app\code\core\Mage\Contacts\controllers\IndexController.php on line ~62 you'll find postAction() which is called by indexAction() - the default action of the controller.
This is the method that is collecting the passed POST parameters and using the core/email_template model to send off the e-mail. I'd use this code as a reference for your controller.
Be sure you put it all in your own module as always with functionality additions.
To know what you can and cannot pass to the core/email_template model, take a look at \app\code\core\Mage\Core\Model\Email\Template.php. It's got loads of documentation in there for you.
Heck, it's even got example code!
// Loading of template
$emailTemplate = Mage::getModel('core/email_template')
->load(Mage::getStoreConfig('path_to_email_template_id_config'));
$variables = array(
'someObject' => Mage::getSingleton('some_model')
'someString' => 'Some string value'
);
$emailTemplate->send('some#domain.com', 'Name Of User', $variables);
In particular take a look at line ~371, where it passes the variables you set to the layout-specified e-mail template.
/**
* Send mail to recipient
*
* #param array|string $email E-mail(s)
* #param array|string|null $name receiver name(s)
* #param array $variables template variables
* #return boolean
**/
public function send($email, $name = null, array $variables = array())
Magento is doing the same thing that you'd do with any contact form on a plain old PHP form processor. It just delegates everything out to models like the one above so you don't have to do so much work re-inventing the wheel, as it were. Just a new controller to accept the parameters in the POST data.
Feel free to follow up and I'll update the answer to help you where I can!
Here's a concise list of things you'll need to make this happen:
A custom controller to accept the form(s) POST data and pass it to the core/email_template model.
A custom form in the front-end pointing to your controller URL (already done!)
A custom e-mail template for the core/email_template to use to display the data in the e-mail the recipient sees.
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)
Modifying a payment module I'm not having any success changing the "payment name" that is placed in table sales_flat_order_payment in field "method".
For example if payment is check, it is populated with checkmo.
I've tried changing
protected $_code = '.........'; in payment.php with no success.
I'm guessing this name may need changing in multiple places?
I have researched this but any answers I can find are assuming I have the skill level to know how to duplicate or modify the extension.
magento ver 1.4.1.1
more info; I'm using a Western Union payment extension as a Bpay payment extension and that field method is used to SMS payment type to me (and it would be more elegant it said what it really was!)
It's better to have a separate payment method for this. You can duplicate some existing method, and use your custom name.
Create a new payment module by duplicate one of your other payment module that closest matches what you are trying to do.
If you are trying to create a payment module for check then take a look at create a new payment method