Adding Payment Instructions for Purchase Order Method in Magento
Magento 1.9.1 provides options for adding payment instructions for Bank Transfer and Cash on Delivery, but it lacks this feature for the Purchase Order method. In this guide, we’ll walk through the process of enabling payment instructions for Purchase Order across various sections of your store.
Configuring Payment Instructions in Admin Panel
First, you need to enable the “Payment from Purchse Order” option under System > Configuration > Sales > Payment Methods and set your bank details if required. However, this won’t provide an instruction field by default.
To add instructions for Purchase Order:
- Go to
app/code/core/Mage/Payment/etc/config.xml. - Find the
<payment>node withmodel="purchaseorder". - Add a new child node
<instructions>under<payment>.
The updated code should look like this:
<default>
<payment active="1">
<purchaseorder>
<active>1</active>
<title>Purchase Order</title>
<min_order_total>0.00</min_order_total>
<max_order_total>999999.99</max_order_total>
<sort_order>57</sort_order>
<instructions>
<field id="purchaseorder_instructions">
<title translate="true">Payment Instructions</title>
<visible_on_front>true</visible_onFront>
</field>
</instructions>
</purchaseorder>
</payment>
</default>
Adding Payment Instructions to Onepage Checkout
Next, you need to add the instruction field to the onepage checkout payment type for Purchase Order.
- Go to
app/code/core/Mage/Checkout/template/payment/form.phtml. - Find the
<div class="payment-method_id">line. - Paste the following code right after it:
<?php if ($_code =='purchaseorder') : ?>
<?php echo $this->getMethodFormFields($_method); ?>
<label for="purchaseorder_instructions"><?php echo $this->__('Payment Instructions'); ?></label>
<textarea id="purchaseorder_instructions" name="payment[purchaseorder][instructions]" rows="2" cols="5"></textarea>
<?php endif; ?>
This will add a textarea field for payment instructions when the user selects Purchase Order as their payment method on the onepage checkout.
Displaying Instructions in Order Review and Receipt
To display the instruction entered by the customer in the order review and receipt page, you need to make changes in two files:
app/code/core/Mage/Sales/template/review/summary/items.phtml: Add the following line right after the<th>Payment Method</th>line:
<th style="text-align:center;"><?php echo $this->__('Payment Instructions'); ?></th>
Then add this code inside the foreach loop for each item:
<?php if ($item->getPaymentInstructions()) : ?>
<td style="padding-left:10px;">
<?php echo $this->escapeHtml($item->getPaymentInstructions()); ?>
</td>
<?php endif; ?>
app/code/core/Mage/Sales/etc/config.xml: Find the<sales_review_block>node and add a newfieldfor instructions.
Conclusion
With these changes, you can now provide customers with an option to enter payment instructions when selecting the Purchase Order method during checkout in Magento 1.9.1. This enhances the user experience by allowing them to communicate any special requirements or details regarding their order.
Remember to clear your cache after making these modifications for them to take effect. If you need further assistance with customizing your Magento store, feel free to reach out to our team at LaravelCompany.