Last active
August 5, 2020 23:41
-
-
Save yasinkuyu/afc0b045b5eae610ff01f0b769d10773 to your computer and use it in GitHub Desktop.
Opencart Custom Field view Invoice/Mail (2.0.x) (ocmod) 2.0.x
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>Custom Field view Invoice/Mail (2.0.x)</name> | |
<code>custom_field_invoice</code> | |
<version>3.0</version> | |
<author>Yasin Kuyu</author> | |
<link>http://insya.com</link> | |
<file path="admin/view/template/sale/custom_field_list.tpl"> | |
<operation> | |
<search><![CDATA[<td style="width: 1px;" class="text-center"><input type="checkbox" onclick="$('input[name*=\'selected\']').prop('checked', this.checked);" /></td>]]></search> | |
<add position="after"><![CDATA[<td style="width: 1px;" class="text-center">Id</td>]]></add> | |
</operation> | |
<operation> | |
<search><![CDATA[<td class="text-left"><?php echo $custom_field['name']; ?></td>]]></search> | |
<add position="before"><![CDATA[<td class="text-center"><?php echo $custom_field['custom_field_id']; ?></td>]]></add> | |
</operation> | |
<operation> | |
<search><![CDATA[<td class="text-center" colspan="6"><?php echo $text_no_results; ?></td>]]></search> | |
<add position="replace"><![CDATA[<td class="text-center" colspan="7"><?php echo $text_no_results; ?></td>]]></add> | |
</operation> | |
</file> | |
<file path="admin/model/localisation/country.php"> | |
<operation> | |
<search><![CDATA[$this->db->query("UPDATE " . DB_PREFIX . "country SET name = '" . $this->db->escape($data['name']) . "', iso_code_2 = '" . $this->db->escape($data['iso_code_2']) . "', iso_code_3 = '" . $this->db->escape($data['iso_code_3']) . "', address_format = '" . $this->db->escape($data['address_format']) . "', postcode_required = '" . (int)$data['postcode_required'] . "', status = '" . (int)$data['status'] . "' WHERE country_id = '" . (int)$country_id . "'");]]></search> | |
<add position="after"><![CDATA[$this->db->query("UPDATE " . DB_PREFIX . "order SET shipping_address_format = '" . $this->db->escape($data['address_format']) . "', payment_address_format = '" . $this->db->escape($data['address_format']) . "'");]]></add> | |
</operation> | |
</file> | |
<file path="admin/controller/sale/order.php"> | |
<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="after"><![CDATA[$data['payment_address'] = ($order_info['payment_firstname']) ? $data['payment_address'] : '';]]></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[ | |
$this->load->model('sale/custom_field'); | |
$custom_fields = $this->model_sale_custom_field->getCustomFields(); | |
foreach ($custom_fields as $custom_field) { | |
if (isset($order_info['payment_custom_field'][$custom_field['custom_field_id']])) { | |
$payment_custom_field_value = $order_info['payment_custom_field'][$custom_field['custom_field_id']]; | |
} | |
if (isset($order_info['custom_field'][$custom_field['custom_field_id']])) { | |
$payment_custom_field_value = $order_info['custom_field'][$custom_field['custom_field_id']]; | |
} | |
if (isset($payment_custom_field_value)) { | |
if ($custom_field['type'] == 'select' || $custom_field['type'] == 'radio' || $custom_field['type'] == 'checkbox') { | |
$custom_field_options = $this->model_sale_custom_field->getCustomFieldValues($custom_field['custom_field_id']); | |
foreach ($custom_field_options as $custom_field_option) { | |
if ($custom_field_option['custom_field_value_id'] == $payment_custom_field_value) { | |
$payment_custom_field_value = $custom_field_option['name']; | |
} | |
} | |
} | |
$format = str_replace('{custom_field_' . $custom_field['custom_field_id'] . '}', $payment_custom_field_value, $format); | |
} | |
} | |
$format = preg_replace('/(({custom_field(.*?)?}))/sim', '', $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="after"><![CDATA[$data['shipping_address'] = ($order_info['shipping_firstname']) ? $data['shipping_address'] : '';]]></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']])) { | |
$shipping_custom_field_value = $order_info['shipping_custom_field'][$custom_field['custom_field_id']]; | |
} | |
if (isset($order_info['custom_field'][$custom_field['custom_field_id']])) { | |
$shipping_custom_field_value = $order_info['custom_field'][$custom_field['custom_field_id']]; | |
} | |
if (isset($shipping_custom_field_value)) { | |
if ($custom_field['type'] == 'select' || $custom_field['type'] == 'radio' || $custom_field['type'] == 'checkbox') { | |
$custom_field_options = $this->model_sale_custom_field->getCustomFieldValues($custom_field['custom_field_id']); | |
foreach ($custom_field_options as $custom_field_option) { | |
if ($custom_field_option['custom_field_value_id'] == $shipping_custom_field_value) { | |
$shipping_custom_field_value = $custom_field_option['name']; | |
} | |
} | |
} | |
$format = str_replace('{custom_field_' . $custom_field['custom_field_id'] . '}', $shipping_custom_field_value, $format); | |
} | |
} | |
$format = preg_replace('/(({custom_field(.*?)?}))/sim', '', $format); | |
]]></add> | |
</operation> | |
<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[foreach ($orders as $order_id) {]]></search> | |
<add position="before"><![CDATA[ | |
$this->load->model('sale/custom_field'); | |
$custom_fields = $this->model_sale_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="after"><![CDATA[$payment_address = ($order_info['payment_firstname']) ? $payment_address : '';]]></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']])) { | |
$payment_custom_field_value = $order_info['payment_custom_field'][$custom_field['custom_field_id']]; | |
} | |
if (isset($order_info['custom_field'][$custom_field['custom_field_id']])) { | |
$payment_custom_field_value = $order_info['custom_field'][$custom_field['custom_field_id']]; | |
} | |
if (isset($payment_custom_field_value)) { | |
if ($custom_field['type'] == 'select' || $custom_field['type'] == 'radio' || $custom_field['type'] == 'checkbox') { | |
$custom_field_options = $this->model_sale_custom_field->getCustomFieldValues($custom_field['custom_field_id']); | |
foreach ($custom_field_options as $custom_field_option) { | |
if ($custom_field_option['custom_field_value_id'] == $payment_custom_field_value) { | |
$payment_custom_field_value = $custom_field_option['name']; | |
} | |
} | |
} | |
$format = str_replace('{custom_field_' . $custom_field['custom_field_id'] . '}', $payment_custom_field_value, $format); | |
} | |
} | |
$format = preg_replace('/(({custom_field(.*?)?}))/sim', '', $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="after"><![CDATA[$shipping_address = ($order_info['shipping_firstname']) ? $shipping_address : '';]]></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']])) { | |
$shipping_custom_field_value = $order_info['shipping_custom_field'][$custom_field['custom_field_id']]; | |
} | |
if (isset($order_info['custom_field'][$custom_field['custom_field_id']])) { | |
$shipping_custom_field_value = $order_info['custom_field'][$custom_field['custom_field_id']]; | |
} | |
if (isset($shipping_custom_field_value)) { | |
if ($custom_field['type'] == 'select' || $custom_field['type'] == 'radio' || $custom_field['type'] == 'checkbox') { | |
$custom_field_options = $this->model_sale_custom_field->getCustomFieldValues($custom_field['custom_field_id']); | |
foreach ($custom_field_options as $custom_field_option) { | |
if ($custom_field_option['custom_field_value_id'] == $shipping_custom_field_value) { | |
$shipping_custom_field_value = $custom_field_option['name']; | |
} | |
} | |
} | |
$format = str_replace('{custom_field_' . $custom_field['custom_field_id'] . '}', $shipping_custom_field_value, $format); | |
} | |
} | |
$format = preg_replace('/(({custom_field(.*?)?}))/sim', '', $format); | |
]]></add> | |
</operation> | |
</file> | |
<file path="catalog/model/account/order.php"> | |
<operation> | |
<search><![CDATA['payment_address_format' => $order_query->row['payment_address_format'],]]></search> | |
<add position="after"><![CDATA[ | |
'custom_field' => unserialize($order_query->row['custom_field']), | |
'payment_custom_field' => unserialize($order_query->row['payment_custom_field']), | |
'shipping_custom_field' => unserialize($order_query->row['shipping_custom_field']), | |
]]></add> | |
</operation> | |
</file> | |
<file path="catalog/controller/account/address.php"> | |
<operation> | |
<search><![CDATA[foreach ($results as $result) {]]></search> | |
<add position="before"><![CDATA[ | |
$this->load->model('account/custom_field'); | |
$account_custom_fields = $this->model_account_custom_field->getCustomFields(); | |
]]></add> | |
</operation> | |
<operation> | |
<search><![CDATA[$find = array(]]></search> | |
<add position="before"><![CDATA[ | |
foreach ($result['custom_field'] as $key => $custom_field) { | |
$account_custom_field_value = $custom_field; | |
if ($account_custom_fields[$key]['type'] == 'select' || $account_custom_fields[$key]['type'] == 'radio' || $account_custom_fields[$key]['type'] == 'checkbox') { | |
foreach ($account_custom_fields[$key]['custom_field_value'] as $custom_field_option) { | |
if ($custom_field_option['custom_field_value_id'] == $account_custom_field_value) { | |
$account_custom_field_value = $custom_field_option['name']; | |
} | |
} | |
} | |
$format = str_replace('{custom_field_' . $key . '}', $account_custom_field_value, $format); | |
} | |
$format = preg_replace('/(({custom_field(.*?)?}))/sim', '', $format); | |
]]></add> | |
</operation> | |
</file> | |
<file path="catalog/controller/account/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']])) { | |
$payment_custom_field_value = $order_info['payment_custom_field'][$custom_field['custom_field_id']]; | |
} | |
if (isset($order_info['custom_field'][$custom_field['custom_field_id']])) { | |
$payment_custom_field_value = $order_info['custom_field'][$custom_field['custom_field_id']]; | |
} | |
if (isset($payment_custom_field_value)) { | |
if ($custom_field['type'] == 'select' || $custom_field['type'] == 'radio' || $custom_field['type'] == 'checkbox') { | |
foreach ($custom_field['custom_field_value'] as $custom_field_option) { | |
if ($custom_field_option['custom_field_value_id'] == $payment_custom_field_value) { | |
$payment_custom_field_value = $custom_field_option['name']; | |
} | |
} | |
} | |
$format = str_replace('{custom_field_' . $custom_field['custom_field_id'] . '}', $payment_custom_field_value, $format); | |
} | |
} | |
$format = preg_replace('/(({custom_field(.*?)?}))/sim', '', $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']])) { | |
$shipping_custom_field_value = $order_info['shipping_custom_field'][$custom_field['custom_field_id']]; | |
} | |
if (isset($order_info['custom_field'][$custom_field['custom_field_id']])) { | |
$shipping_custom_field_value = $order_info['custom_field'][$custom_field['custom_field_id']]; | |
} | |
if (isset($shipping_custom_field_value)) { | |
if ($custom_field['type'] == 'select' || $custom_field['type'] == 'radio' || $custom_field['type'] == 'checkbox') { | |
foreach ($custom_field['custom_field_value'] as $custom_field_option) { | |
if ($custom_field_option['custom_field_value_id'] == $shipping_custom_field_value) { | |
$shipping_custom_field_value = $custom_field_option['name']; | |
} | |
} | |
} | |
$format = str_replace('{custom_field_' . $custom_field['custom_field_id'] . '}', $shipping_custom_field_value, $format); | |
} | |
} | |
$format = preg_replace('/(({custom_field(.*?)?}))/sim', '', $format); | |
]]></add> | |
</operation> | |
</file> | |
<file path="catalog/model/checkout/order.php"> | |
<operation> | |
<search><![CDATA[if ($order_info) {]]></search> | |
<add position="after"><![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']])) { | |
$payment_custom_field_value = $order_info['payment_custom_field'][$custom_field['custom_field_id']]; | |
} | |
if (isset($order_info['custom_field'][$custom_field['custom_field_id']])) { | |
$payment_custom_field_value = $order_info['custom_field'][$custom_field['custom_field_id']]; | |
} | |
if (isset($payment_custom_field_value)) { | |
if ($custom_field['type'] == 'select' || $custom_field['type'] == 'radio' || $custom_field['type'] == 'checkbox') { | |
foreach ($custom_field['custom_field_value'] as $custom_field_option) { | |
if ($custom_field_option['custom_field_value_id'] == $payment_custom_field_value) { | |
$payment_custom_field_value = $custom_field_option['name']; | |
} | |
} | |
} | |
$format = str_replace('{custom_field_' . $custom_field['custom_field_id'] . '}', $payment_custom_field_value, $format); | |
} | |
} | |
$format = preg_replace('/(({custom_field(.*?)?}))/sim', '', $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']])) { | |
$shipping_custom_field_value = $order_info['shipping_custom_field'][$custom_field['custom_field_id']]; | |
} | |
if (isset($order_info['custom_field'][$custom_field['custom_field_id']])) { | |
$shipping_custom_field_value = $order_info['custom_field'][$custom_field['custom_field_id']]; | |
} | |
if (isset($shipping_custom_field_value)) { | |
if ($custom_field['type'] == 'select' || $custom_field['type'] == 'radio' || $custom_field['type'] == 'checkbox') { | |
foreach ($custom_field['custom_field_value'] as $custom_field_option) { | |
if ($custom_field_option['custom_field_value_id'] == $shipping_custom_field_value) { | |
$shipping_custom_field_value = $custom_field_option['name']; | |
} | |
} | |
} | |
$format = str_replace('{custom_field_' . $custom_field['custom_field_id'] . '}', $shipping_custom_field_value, $format); | |
} | |
} | |
$format = preg_replace('/(({custom_field(.*?)?}))/sim', '', $format); | |
]]></add> | |
</operation> | |
</file> | |
</modification> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment