Last active
March 10, 2016 19:32
-
-
Save valdeir2000/7ecf1b0b270b63c391e5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<modification> | |
<name>Add Custom field invoice</name> | |
<code>valdeir_custom_field_invoice</code> | |
<version>1.5</version> | |
<author>Valdeir Santana</author> | |
<link>http://www.valdeirsantana.com.br</link> | |
<file path="catalog/view/theme/*/template/checkout/payment_address.tpl,catalog/view/theme/*/template/checkout/shipping_address.tpl"> | |
<operation error="skip"> | |
<search> | |
<![CDATA[<option value="<?php echo $address['address_id']; ?>" selected="selected"><?php echo $address['firstname']; ?> <?php echo $address['lastname']; ?>, <?php echo $address['address_1']; ?>, <?php echo $address['city']; ?>, <?php echo $address['zone']; ?>, <?php echo $address['country']; ?></option>]]> | |
</search> | |
<add position="replace"> | |
<![CDATA[<option value="<?php echo $address['address_id']; ?>" selected="selected"><?php echo $address['firstname']; ?> <?php echo $address['lastname']; ?>, <?php echo $address['address_1']; ?>, <?php echo $address['custom_field'][5]; ?>, <?php echo $address['address_2'] ?>, <?php echo $address['city']; ?>, <?php echo $address['zone']; ?>, <?php echo $address['country']; ?></option>]]> | |
</add> | |
</operation> | |
<operation error="skip"> | |
<search> | |
<![CDATA[<option value="<?php echo $address['address_id']; ?>"><?php echo $address['firstname']; ?> <?php echo $address['lastname']; ?>, <?php echo $address['address_1']; ?>, <?php echo $address['city']; ?>, <?php echo $address['zone']; ?>, <?php echo $address['country']; ?></option>]]> | |
</search> | |
<add position="replace"> | |
<![CDATA[<option value="<?php echo $address['address_id']; ?>"><?php echo $address['firstname']; ?> <?php echo $address['lastname']; ?>, <?php echo $address['address_1']; ?>, <?php echo $address['custom_field'][5]; ?>, <?php echo $address['address_2'] ?>, <?php echo $address['city']; ?>, <?php echo $address['zone']; ?>, <?php echo $address['country']; ?></option>]]> | |
</add> | |
</operation> | |
</file> | |
<file path="admin/controller/sale/order.php"> | |
<operation> | |
<search><![CDATA[$custom_fields = $this->model_sale_custom_field->getCustomFields();]]></search> | |
<add position="replace"><![CDATA[ | |
$custom_fields = $this->model_sale_custom_field->getCustomFields(array('sort' => 'cf.sort_order')); | |
]]></add> | |
</operation> | |
<operation> | |
<search><![CDATA[if ($order_info['payment_address_format']) {]]></search> | |
<add position="before"><![CDATA[ | |
if (version_compare(VERSION, '2.1', '<')) { | |
$this->load->model('sale/custom_field'); | |
$custom_fields = $this->model_sale_custom_field->getCustomFields(); | |
} else { | |
$this->load->model('customer/custom_field'); | |
$custom_fields = $this->model_customer_custom_field->getCustomFields(); | |
} | |
]]></add> | |
</operation> | |
<operation> | |
<search><![CDATA[$payment_address = str_replace(array("\r\n", "\r", "\n"), '<br />', preg_replace(array("/\s\s+/", "/\r\r+/", "/\n\n+/"), '<br />', trim(str_replace($find, $replace, $format))));]]></search> | |
<add position="before"><![CDATA[ | |
foreach ($custom_fields as $custom_field) { | |
if (isset($order_info['payment_custom_field'][$custom_field['custom_field_id']])){ | |
$format = str_replace('{custom_field_' . $custom_field['custom_field_id'] . '}', $order_info['payment_custom_field'][$custom_field['custom_field_id']], $format); | |
} | |
} | |
]]></add> | |
</operation> | |
<operation> | |
<search><![CDATA[$shipping_address = str_replace(array("\r\n", "\r", "\n"), '<br />', preg_replace(array("/\s\s+/", "/\r\r+/", "/\n\n+/"), '<br />', trim(str_replace($find, $replace, $format))));]]></search> | |
<add position="before"><![CDATA[ | |
foreach ($custom_fields as $custom_field) { | |
if (isset($order_info['shipping_custom_field'][$custom_field['custom_field_id']])){ | |
$format = str_replace('{custom_field_' . $custom_field['custom_field_id'] . '}', $order_info['shipping_custom_field'][$custom_field['custom_field_id']], $format); | |
} | |
} | |
]]></add> | |
</operation> | |
<operation> | |
<search><![CDATA['comment' => nl2br($order_info['comment'])]]></search> | |
<add position="replace"><![CDATA[ | |
'comment' => nl2br($order_info['comment']), | |
'account_custom_fields' => $account_custom_fields, | |
]]></add> | |
</operation> | |
<operation> | |
<search><![CDATA[$totals = $this->model_sale_order->getOrderTotals($order_id);]]></search> | |
<add position="before"><![CDATA[ | |
$account_custom_fields = array(); | |
$filter_data = array( | |
'sort' => 'cf.sort_order', | |
'order' => 'ASC', | |
); | |
if (version_compare(VERSION, '2.1', '<')) { | |
$custom_fields = $this->model_sale_custom_field->getCustomFields($filter_data); | |
} else { | |
$custom_fields = $this->model_customer_custom_field->getCustomFields($filter_data); | |
} | |
foreach ($custom_fields as $custom_field) { | |
if ($custom_field['location'] == 'account' && isset($order_info['custom_field'][$custom_field['custom_field_id']])) { | |
if ($custom_field['type'] == 'select' || $custom_field['type'] == 'radio') { | |
if (version_compare(VERSION, '2.1', '<')) { | |
$custom_field_value_info = $this->model_sale_custom_field->getCustomFieldValue($order_info['custom_field'][$custom_field['custom_field_id']]); | |
} else { | |
$custom_field_value_info = $this->model_customer_custom_field->getCustomFieldValue($order_info['custom_field'][$custom_field['custom_field_id']]); | |
} | |
if ($custom_field_value_info) { | |
$account_custom_fields[] = array( | |
'name' => $custom_field['name'], | |
'value' => $custom_field_value_info['name'] | |
); | |
} | |
} | |
if ($custom_field['type'] == 'checkbox' && is_array($order_info['custom_field'][$custom_field['custom_field_id']])) { | |
foreach ($order_info['custom_field'][$custom_field['custom_field_id']] as $custom_field_value_id) { | |
if (version_compare(VERSION, '2.1', '<')) { | |
$custom_field_value_info = $this->model_sale_custom_field->getCustomFieldValue($custom_field_value_id); | |
} else { | |
$custom_field_value_info = $this->model_customer_custom_field->getCustomFieldValue($custom_field_value_id); | |
} | |
if ($custom_field_value_info) { | |
$account_custom_fields[] = array( | |
'name' => $custom_field['name'], | |
'value' => $custom_field_value_info['name'] | |
); | |
} | |
} | |
} | |
if ($custom_field['type'] == 'text' || $custom_field['type'] == 'textarea' || $custom_field['type'] == 'file' || $custom_field['type'] == 'date' || $custom_field['type'] == 'datetime' || $custom_field['type'] == 'time') { | |
$account_custom_fields[] = array( | |
'name' => $custom_field['name'], | |
'value' => $order_info['custom_field'][$custom_field['custom_field_id']] | |
); | |
} | |
if ($custom_field['type'] == 'file') { | |
$upload_info = $this->model_tool_upload->getUploadByCode($order_info['custom_field'][$custom_field['custom_field_id']]); | |
if ($upload_info) { | |
$account_custom_fields[] = array( | |
'name' => $custom_field['name'], | |
'value' => $upload_info['name'] | |
); | |
} | |
} | |
} | |
} | |
]]></add> | |
</operation> | |
</file> | |
<file path="catalog/controller/account/address.php"> | |
<operation> | |
<search><![CDATA[$format = '{firstname} {lastname}' . "\n" . '{company}' . "\n" . '{address_1}' . "\n" . '{address_2}' . "\n" . '{city} {postcode}' . "\n" . '{zone}' . "\n" . '{country}';]]></search> | |
<add position="after" offset="1"><![CDATA[ | |
foreach ($result['custom_field'] as $key => $custom_field) { | |
$format = str_replace('{custom_field_' . $key . '}', $custom_field, $format); | |
} | |
]]></add> | |
</operation> | |
</file> | |
<file path="catalog/model/checkout/order.php"> | |
<operation> | |
<search><![CDATA[if ($order_info['payment_address_format']) {]]></search> | |
<add position="before"><![CDATA[ | |
$this->load->model('account/custom_field'); | |
$custom_fields = $this->model_account_custom_field->getCustomFields(); | |
]]></add> | |
</operation> | |
<operation> | |
<search><![CDATA[$data['payment_address'] = str_replace(array("\r\n", "\r", "\n"), '<br />', preg_replace(array("/\s\s+/", "/\r\r+/", "/\n\n+/"), '<br />', trim(str_replace($find, $replace, $format))));]]></search> | |
<add position="before"><![CDATA[ | |
foreach ($custom_fields as $custom_field) { | |
if (isset($order_info['payment_custom_field'][$custom_field['custom_field_id']])){ | |
$format = str_replace('{custom_field_' . $custom_field['custom_field_id'] . '}', $order_info['payment_custom_field'][$custom_field['custom_field_id']], $format); | |
} | |
} | |
$this->log->write('Format: ' . $format); | |
]]></add> | |
</operation> | |
<operation> | |
<search><![CDATA[$data['shipping_address'] = str_replace(array("\r\n", "\r", "\n"), '<br />', preg_replace(array("/\s\s+/", "/\r\r+/", "/\n\n+/"), '<br />', trim(str_replace($find, $replace, $format))));]]></search> | |
<add position="before"><![CDATA[ | |
foreach ($custom_fields as $custom_field) { | |
if (isset($order_info['shipping_custom_field'][$custom_field['custom_field_id']])){ | |
$format = str_replace('{custom_field_' . $custom_field['custom_field_id'] . '}', $order_info['shipping_custom_field'][$custom_field['custom_field_id']], $format); | |
} | |
} | |
$this->log->write('Format: ' . $format); | |
]]></add> | |
</operation> | |
</file> | |
<file path="catalog/controller/account/order.php"> | |
<operation> | |
<search off="1"><![CDATA[$this->load->model('account/order');]]></search> | |
<add position="after"><![CDATA[ | |
$this->load->model('checkout/order'); | |
]]></add> | |
</operation> | |
<operation> | |
<search offset="0"><![CDATA[$order_info = $this->model_account_order->getOrder($order_id);]]></search> | |
<add position="replace"><![CDATA[ | |
$order_info = $this->model_checkout_order->getOrder($order_id); | |
]]></add> | |
</operation> | |
<operation> | |
<search><![CDATA[if ($order_info['payment_address_format']) {]]></search> | |
<add position="before"><![CDATA[ | |
$this->load->model('account/custom_field'); | |
$custom_fields = $this->model_account_custom_field->getCustomFields(); | |
]]></add> | |
</operation> | |
<operation> | |
<search><![CDATA[$data['payment_address'] = str_replace(array("\r\n", "\r", "\n"), '<br />', preg_replace(array("/\s\s+/", "/\r\r+/", "/\n\n+/"), '<br />', trim(str_replace($find, $replace, $format))));]]></search> | |
<add position="before"><![CDATA[ | |
foreach ($custom_fields as $custom_field) { | |
if (isset($order_info['payment_custom_field'][$custom_field['custom_field_id']])){ | |
if (isset($order_info['payment_custom_field'][$custom_field['custom_field_id']])) { | |
$format = str_replace('{custom_field_' . $custom_field['custom_field_id'] . '}', $order_info['payment_custom_field'][$custom_field['custom_field_id']], $format); | |
} | |
} | |
} | |
]]></add> | |
</operation> | |
<operation> | |
<search><![CDATA[$data['shipping_address'] = str_replace(array("\r\n", "\r", "\n"), '<br />', preg_replace(array("/\s\s+/", "/\r\r+/", "/\n\n+/"), '<br />', trim(str_replace($find, $replace, $format))));]]></search> | |
<add position="before"><![CDATA[ | |
foreach ($custom_fields as $custom_field) { | |
if (isset($order_info['shipping_custom_field'][$custom_field['custom_field_id']])){ | |
$format = str_replace('{custom_field_' . $custom_field['custom_field_id'] . '}', $order_info['shipping_custom_field'][$custom_field['custom_field_id']], $format); | |
} | |
} | |
$this->log->write('Format: ' . $format); | |
]]></add> | |
</operation> | |
</file> | |
<file path="admin/view/template/sale/order_invoice.tpl"> | |
<operation> | |
<search index="1"><![CDATA[<table class="table table-bordered">]]></search> | |
<add position="before"><![CDATA[ | |
<table class="table table-bordered"> | |
<thead> | |
<tr> | |
<td colspan="2">Outros Dados</td> | |
</tr> | |
</thead> | |
<tbody> | |
<?php foreach($order['account_custom_fields'] as $custom_field) { ?> | |
<tr> | |
<td style="width: 100%;"> | |
<b><?php echo $custom_field['name'] ?></b> <?php echo $custom_field['value'] ?> | |
</td> | |
</tr> | |
<?php } ?> | |
</tbody> | |
</table> | |
]]></add> | |
</operation> | |
</file> | |
</modification> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment