Page 1 of 1

How to remove empty stings from custom_fields that are not in use in Database?

Posted: Wed May 29, 2024 7:12 am
by spstore
Hello,

I am relatively new to opencart but i am trying to adjust it to my needs.

My OC version is 3.0.3.8 with Journal theme.


I am trying to bring the custom_fields to a visible part of the order info page instead of searching it through the "Additional" tab so my employees can clearly see if there is any additional information (ex. VAT. No., etc)

I managed to modify the /admin/view/template/sale/order_info.twig so if there are values it brings the custom_field tab to the front place. (check screenshot).

The problem is that when a customer is registered, OC stores some empty stings on the custom_field column in the oc_customer table even if there aren't any available custom fields for his group. (ex. "Receipt" instead of "Commercial Invoice").
For example, the custom_field cell contains empty stings: {"19":"","20":""} when the custom fields are not in use as the customer belongs to the "Receipt" group, that doesn't require any extra info-fields.

This result is to show an empty table without values. (check screenshot)
I would like to know how can I fix this and remove these empty strings when a customer is registered so my modification could work properly without showing empty tables.
Or
If there is a way to exclude empty strings by modifying the twig template.

Extra info:
1)I am not yet a developer.
2)The twig variable that I use to display or not the custom fields is: {% if account_custom_fields %} / {% if not account_custom_fields %}
3) Journal registration form doesn't affect it.
4) If the customer is not registered the custom_field remains empty.

Thanks in advance

Re: How to remove empty stings from custom_fields that are not in use in Database?

Posted: Wed May 29, 2024 5:54 pm
by IP_CAM
Well, you're using a commercial Journal Theme Extension, not supported in the 'free' Opencart Forum, you therefore better post in the commercal OC Forum, if you expect someone to be of assistance. Or then, use the official Journal User Forum, to get some help.

Re: How to remove empty stings from custom_fields that are not in use in Database?

Posted: Thu May 30, 2024 5:50 am
by spstore
IP_CAM wrote:
Wed May 29, 2024 5:54 pm
Well, you're using a commercial Journal Theme Extension, not supported in the 'free' Opencart Forum, you therefore better post in the commercial OC Forum, if you expect someone to be of assistance. Or then, use the official Journal User Forum, to get some help.
Thanks for your reply.

I thought that someone could help since this is not really related with Journal theme and has to do with the backend and the default code.
Actually, I am using the default theme for the test now since I also thought that there may be an issue with journals registration form, but its not.
The same issue exists with the default theme.

I know that most of the developers hate Journal but this is not a reason for ignoring an issue that is not related with Journal.

Re: How to remove empty stings from custom_fields that are not in use in Database?

Posted: Fri May 31, 2024 4:19 am
by ADD Creative
If a custom field is not enabled for a customer group then no data should be stored. I think the issue maybe if the a customer changes group or the custom fields are removed from a from a group.

Re: How to remove empty stings from custom_fields that are not in use in Database?

Posted: Sat Jun 08, 2024 1:33 am
by spstore
ADD Creative wrote:
Fri May 31, 2024 4:19 am
If a custom field is not enabled for a customer group then no data should be stored. I think the issue maybe if the a customer changes group or the custom fields are removed from a from a group.
Thanks for your reply.

That's what I thought also. But this issue existed from the beginning as I checked the database entries. When a customer is registered to the "RECEIPT" group that there is no custom field added for VAT number in the database adds an entry like {"19":""}. So actually inserts an empty string (as I understand).
In the admin panel obviously there is no value displayed but activates the "Additional" Tab.

So in this case I want to find a way to ignore empty stings and don't activate the "Additional" Tab or I don't know if there is a way to correct this issue and change the code and fix this so there will not be at all entries in groups without custom fields when a customer is registered.

Any suggestions?

Re: How to remove empty stings from custom_fields that are not in use in Database?

Posted: Sun Jun 09, 2024 7:01 am
by ADD Creative
Yes I see what you mean, if another group has a field it will be saved for all groups.

The bit of code you may want to change is.
https://github.com/opencart/opencart/bl ... 1042-L1047

You could try filtering by customer_group_id.

Code: Select all

'filter_customer_group_id' =>  $order_info['customer_group_id'],

Re: How to remove empty stings from custom_fields that are not in use in Database?

Posted: Sun Jun 09, 2024 5:13 pm
by OSWorX
ADD Creative wrote:
Sun Jun 09, 2024 7:01 am
Yes I see what you mean, if another group has a field it will be saved for all groups.

The bit of code you may want to change is.
https://github.com/opencart/opencart/bl ... 1042-L1047

You could try filtering by customer_group_id.

Code: Select all

'filter_customer_group_id' =>  $order_info['customer_group_id'],
Should'nt that also be an "issue" for the core?

Re: How to remove empty stings from custom_fields that are not in use in Database?

Posted: Mon Jun 10, 2024 5:07 pm
by IP_CAM
I know that most of the developers hate Journal but this is not a reason for ignoring an issue that is not related with Journal.
Well, the main problem is the plain Fact, that most Journal Theme Users, coming here for Support, do not use a 'legal' Journal Copy, but a 'stolen' one, and therefore cannot use the official Journal Support, if they run into a Problem. And why should they then be assisted (for free) ? :crazy:
So better don't take it personal, if you don't belong to them, but understand the situation, as it exists.