before combination:
Account Custom Fields
color yellow
color green
color red
image 3ba9557e23ecb68b0152683e2623dd72907bdfff
image MPX2102AP.jpg
size big
size small
after combination, the chart will show like:
Account Custom Fields
color: yellow,green,red
image: 3ba9557e23ecb68b0152683e2623dd72907bdfff, MPX2102AP.jpg
size: big, small
how to do it?
Attachments
how to combine duplicate custom_field name with value - combine.jpg (41.45 KiB) Viewed 942 times
https://www.ectransistors.com/
https://www.transistormosfet.com/
UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk
In admin/controller/customer/custom_field.php file,
find:
Code: Select all
$data['custom_fields'] = array();
$filter_data = array(
'sort' => $sort,
'order' => $order,
'start' => ($page - 1) * $this->config->get('config_limit_admin'),
'limit' => $this->config->get('config_limit_admin')
);
$custom_field_total = $this->model_customer_custom_field->getTotalCustomFields();
$results = $this->model_customer_custom_field->getCustomFields($filter_data);
foreach ($results as $result) {
$type = '';
switch ($result['type']) {
case 'select':
$type = $this->language->get('text_select');
break;
case 'radio':
$type = $this->language->get('text_radio');
break;
case 'checkbox':
$type = $this->language->get('text_checkbox');
break;
case 'input':
$type = $this->language->get('text_input');
break;
case 'text':
$type = $this->language->get('text_text');
break;
case 'textarea':
$type = $this->language->get('text_textarea');
break;
case 'file':
$type = $this->language->get('text_file');
break;
case 'date':
$type = $this->language->get('text_date');
break;
case 'datetime':
$type = $this->language->get('text_datetime');
break;
case 'time':
$type = $this->language->get('text_time');
break;
}
$data['custom_fields'][] = array(
'custom_field_id' => $result['custom_field_id'],
'name' => $result['name'],
'location' => $this->language->get('text_' . $result['location']),
'type' => $type,
'status' => $result['status'],
'sort_order' => $result['sort_order'],
'edit' => $this->url->link('customer/custom_field/edit', 'user_token=' . $this->session->data['user_token'] . '&custom_field_id=' . $result['custom_field_id'] . $url, true)
);
}
Code: Select all
$data['custom_fields'] = array();
$custom_field_values = array();
$filter_data = array(
'sort' => $sort,
'order' => $order,
'start' => ($page - 1) * $this->config->get('config_limit_admin'),
'limit' => $this->config->get('config_limit_admin')
);
$custom_field_total = $this->model_customer_custom_field->getTotalCustomFields();
$results = $this->model_customer_custom_field->getCustomFields($filter_data);
foreach ($results as $result) {
$type = '';
switch ($result['type']) {
case 'select':
$type = $this->language->get('text_select');
break;
case 'radio':
$type = $this->language->get('text_radio');
break;
case 'checkbox':
$type = $this->language->get('text_checkbox');
break;
case 'input':
$type = $this->language->get('text_input');
break;
case 'text':
$type = $this->language->get('text_text');
break;
case 'textarea':
$type = $this->language->get('text_textarea');
break;
case 'file':
$type = $this->language->get('text_file');
break;
case 'date':
$type = $this->language->get('text_date');
break;
case 'datetime':
$type = $this->language->get('text_datetime');
break;
case 'time':
$type = $this->language->get('text_time');
break;
}
$data['custom_fields'][] = array(
'custom_field_id' => $result['custom_field_id'],
'name' => $result['name'],
'location' => $this->language->get('text_' . $result['location']),
'type' => $type,
'status' => $result['status'],
'sort_order' => $result['sort_order'],
'edit' => $this->url->link('customer/custom_field/edit', 'user_token=' . $this->session->data['user_token'] . '&custom_field_id=' . $result['custom_field_id'] . $url, true)
);
$name = $result['name'];
$value = $result['value'];
$custom_field_values[$name][] = $name . '|' . $value;
}
$tmp_custom_fields = array();
foreach ($custom_field_values as $key => $values) {
if (!empty($values) && is_array($values)) {
foreach ($values as $value) {
$value_exploded = explode('|', trim($value));
$tmp_custom_fields[$value_exploded[0]][] = $value_exploded[1];
}
}
}
$data['custom_field_values'] = array();
foreach ($tmp_custom_fields as $key => $values) {
$commas = implode(', ', $values);
$data['custom_field_values'][$key][] = $commas;
}
Code: Select all
<td class="text-left">{{ custom_field.name }}</td>
Code: Select all
<td class="text-left">{% for key,values in custom_field_values %}
{% if key == custom_field.name %}
{{ custom_field.name }}:
{% for value in values %}
{{ value }}
{% endfor %}
{% endif %}
{% endfor %}
</td>
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
not working.straightlight wrote: ↑Tue Jun 21, 2022 9:21 amThis request seem to have been in demand for quite sometime now. It's been routed to the opencart-3 as well. Let's give this a try without an event, this time, since it may also be a core experience.
In admin/controller/customer/custom_field.php file,
find:
replace with:Code: Select all
$data['custom_fields'] = array(); $filter_data = array( 'sort' => $sort, 'order' => $order, 'start' => ($page - 1) * $this->config->get('config_limit_admin'), 'limit' => $this->config->get('config_limit_admin') ); $custom_field_total = $this->model_customer_custom_field->getTotalCustomFields(); $results = $this->model_customer_custom_field->getCustomFields($filter_data); foreach ($results as $result) { $type = ''; switch ($result['type']) { case 'select': $type = $this->language->get('text_select'); break; case 'radio': $type = $this->language->get('text_radio'); break; case 'checkbox': $type = $this->language->get('text_checkbox'); break; case 'input': $type = $this->language->get('text_input'); break; case 'text': $type = $this->language->get('text_text'); break; case 'textarea': $type = $this->language->get('text_textarea'); break; case 'file': $type = $this->language->get('text_file'); break; case 'date': $type = $this->language->get('text_date'); break; case 'datetime': $type = $this->language->get('text_datetime'); break; case 'time': $type = $this->language->get('text_time'); break; } $data['custom_fields'][] = array( 'custom_field_id' => $result['custom_field_id'], 'name' => $result['name'], 'location' => $this->language->get('text_' . $result['location']), 'type' => $type, 'status' => $result['status'], 'sort_order' => $result['sort_order'], 'edit' => $this->url->link('customer/custom_field/edit', 'user_token=' . $this->session->data['user_token'] . '&custom_field_id=' . $result['custom_field_id'] . $url, true) ); }
Then, in admin/view/template/customer/custom_field.twig file, find:Code: Select all
$data['custom_fields'] = array(); $custom_field_values = array(); $filter_data = array( 'sort' => $sort, 'order' => $order, 'start' => ($page - 1) * $this->config->get('config_limit_admin'), 'limit' => $this->config->get('config_limit_admin') ); $custom_field_total = $this->model_customer_custom_field->getTotalCustomFields(); $results = $this->model_customer_custom_field->getCustomFields($filter_data); foreach ($results as $result) { $type = ''; switch ($result['type']) { case 'select': $type = $this->language->get('text_select'); break; case 'radio': $type = $this->language->get('text_radio'); break; case 'checkbox': $type = $this->language->get('text_checkbox'); break; case 'input': $type = $this->language->get('text_input'); break; case 'text': $type = $this->language->get('text_text'); break; case 'textarea': $type = $this->language->get('text_textarea'); break; case 'file': $type = $this->language->get('text_file'); break; case 'date': $type = $this->language->get('text_date'); break; case 'datetime': $type = $this->language->get('text_datetime'); break; case 'time': $type = $this->language->get('text_time'); break; } $data['custom_fields'][] = array( 'custom_field_id' => $result['custom_field_id'], 'name' => $result['name'], 'location' => $this->language->get('text_' . $result['location']), 'type' => $type, 'status' => $result['status'], 'sort_order' => $result['sort_order'], 'edit' => $this->url->link('customer/custom_field/edit', 'user_token=' . $this->session->data['user_token'] . '&custom_field_id=' . $result['custom_field_id'] . $url, true) ); $name = $result['name']; $value = $result['value']; $custom_field_values[$name][] = $name . '|' . $value; } $tmp_custom_fields = array(); foreach ($custom_field_values as $key => $values) { $values_exploded = explode('|', trim($values)); $tmp_custom_fields[$values_exploded[0]][] = $values_exploded[1]; } $data['custom_field_values'] = array(); foreach ($tmp_custom_fields as $key => $values) { $commas = implode(', ', $values); $data['custom_field_values'][$key][] = $commas; }
replace with:Code: Select all
<td class="text-left">{{ custom_field.name }}</td>
See if that solves the issue.Code: Select all
<td class="text-left">{% for key,values in custom_field_values %} {% if key == custom_field.name %} {% for value in values %} {{ custom_field.name }}: {{ value }} {% endfor %} {% endif %} {% endfor %} </td>
it says:
Warning: trim() expects parameter 1 to be string, array given in /admin/controller/customer/custom_field.php on line 232
Notice: Undefined offset: 1 in /admin/controller/customer/custom_field.php on line 234
https://www.ectransistors.com/
https://www.transistormosfet.com/
before combination:
after combination:
the modification should be as the after-combination.
https://www.ectransistors.com/
https://www.transistormosfet.com/
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
this time, no php errors, but the value is blank, don't show up.straightlight wrote: ↑Tue Jun 21, 2022 6:25 pmYou don't need to re-post the same screenshots for PHP errors. The code has been edited on the above now. Please try again.
please help again.
Attachments
value is blank - value-is-blank.jpg (6.4 KiB) Viewed 871 times
https://www.ectransistors.com/
https://www.transistormosfet.com/
please help modify admin/controller/sale/order.php and /admin/view/template/sale/order_info.twig under account_custom_field.straightlight wrote: ↑Tue Jun 21, 2022 6:25 pmYou don't need to re-post the same screenshots for PHP errors. The code has been edited on the above now. Please try again.
not admin/controller/customer/custom_field.php and admin/view/template/customer/custom_field_list.twig
https://www.ectransistors.com/
https://www.transistormosfet.com/
What you are acquiring may require extensive coding. Therefore, I would suggest to create a new service request in the Commercial Support section of the forum to get this done as a custom job.chongshengdz wrote: ↑Wed Jun 22, 2022 3:25 amplease help modify admin/controller/sale/order.php and /admin/view/template/sale/order_info.twig under account_custom_field.straightlight wrote: ↑Tue Jun 21, 2022 6:25 pmYou don't need to re-post the same screenshots for PHP errors. The code has been edited on the above now. Please try again.
not admin/controller/customer/custom_field.php and admin/view/template/customer/custom_field_list.twig
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
at thebeginning, you are doing wrong, please help me againstraightlight wrote: ↑Wed Jun 22, 2022 6:28 amWhat you are acquiring may require extensive coding. Therefore, I would suggest to create a new service request in the Commercial Support section of the forum to get this done as a custom job.chongshengdz wrote: ↑Wed Jun 22, 2022 3:25 amplease help modify admin/controller/sale/order.php and /admin/view/template/sale/order_info.twig under account_custom_field.straightlight wrote: ↑Tue Jun 21, 2022 6:25 pmYou don't need to re-post the same screenshots for PHP errors. The code has been edited on the above now. Please try again.
not admin/controller/customer/custom_field.php and admin/view/template/customer/custom_field_list.twig
https://www.ectransistors.com/
https://www.transistormosfet.com/
The reason was also indicated on your posted commit from Github Opencart. More implications would need to be involved than simply adding those commas in the end. However, if you do require assistance specifically on this request, again, please create a new service request in the Commercial Support section of the forum.chongshengdz wrote: ↑Wed Jun 22, 2022 6:45 amat thebeginning, you are doing wrong, please help me againstraightlight wrote: ↑Wed Jun 22, 2022 6:28 amWhat you are acquiring may require extensive coding. Therefore, I would suggest to create a new service request in the Commercial Support section of the forum to get this done as a custom job.chongshengdz wrote: ↑Wed Jun 22, 2022 3:25 am
please help modify admin/controller/sale/order.php and /admin/view/template/sale/order_info.twig under account_custom_field.
not admin/controller/customer/custom_field.php and admin/view/template/customer/custom_field_list.twig
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
hello, please help me check again, the {{ value }} don't show up anything,straightlight wrote: ↑Wed Jun 22, 2022 10:06 amThe reason was also indicated on your posted commit from Github Opencart. More implications would need to be involved than simply adding those commas in the end. However, if you do require assistance specifically on this request, again, please create a new service request in the Commercial Support section of the forum.chongshengdz wrote: ↑Wed Jun 22, 2022 6:45 amat thebeginning, you are doing wrong, please help me againstraightlight wrote: ↑Wed Jun 22, 2022 6:28 am
What you are acquiring may require extensive coding. Therefore, I would suggest to create a new service request in the Commercial Support section of the forum to get this done as a custom job.
is there anything wrong?
https://www.ectransistors.com/
https://www.transistormosfet.com/
Users browsing this forum: Baidu [Spider] and 18 guests