Post by straightlight » Mon Mar 21, 2022 3:33 am


Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by mikeinterserv » Mon Mar 21, 2022 4:15 am

No
I looked at and applied all the current fixes but the issue is not related to those.
To replicate - create the affiliate and the custom field (TEXT) etc. Go to front end and you will see default value. Edit and it WILL change and add to DB table customer affiliate.
Now go to ADMIN EDIT CUTOMER and look at affiliate TAB there you will see DEFAULT DATA not customers updated data. If you EDIT in ADMIN you will see it is saved in CUSTOMER TABLE. The EDIT is reflected in the ADMIN customer edit affiliate TAB correctly. This means ADMIN and CUSTOMER are totally disconnected from each others data in custom fields. Admin cannot see customers changes and customer cannot see admins changes.

Active Member

Posts

Joined
Thu May 28, 2020 6:55 am
Location - Wales

Post by straightlight » Mon Mar 21, 2022 4:34 am

mikeinterserv wrote:
Mon Mar 21, 2022 4:15 am
No
I looked at and applied all the current fixes but the issue is not related to those.
To replicate - create the affiliate and the custom field (TEXT) etc. Go to front end and you will see default value. Edit and it WILL change and add to DB table customer affiliate.
Now go to ADMIN EDIT CUTOMER and look at affiliate TAB there you will see DEFAULT DATA not customers updated data. If you EDIT in ADMIN you will see it is saved in CUSTOMER TABLE. The EDIT is reflected in the ADMIN customer edit affiliate TAB correctly. This means ADMIN and CUSTOMER are totally disconnected from each others data in custom fields. Admin cannot see customers changes and customer cannot see admins changes.
Best to create an issue or a Pull Request then ...

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by mikeinterserv » Mon Mar 21, 2022 9:11 am

Well in the end this worked
You have to fill ALL of the fields in affiliate tab on ADMIN CUSTOMER EDIT affiliate tab and select enabled at the bottom.
If you leave a field blank you will get NO ERROR. and you will see success message. If you selected ENABLED in the select box at the bottom with ANY field missing, like website or company or tax code etc it would throw an error saying check form carefully for errors but with NO INDICATION ANYWHERE which field is in error. Once ALL form fields are filled and ENABLED is selected at the bottom everything THEN gets saved to the correct table customer_affiliate.
Now BOTH admin AND customer see the same data. You cannot ENABLE STATUS with a blank field it will throw an ERROR but NOT tell you what the error is.

Now why this is messed up - is because the model is looking for $data[affiliate} which RELIES on the STATUS SELECT (enabled/disabled) to be ENABLED.
If it remains DISABLED everything appears to work EXCEPT this DATA SAVE PROBLEM - I left it disabled because that is how it defaults even though the status in the DB is set to 1 ENABLED. With the status DISABLED all appears well but $data['affiliate'] = ''; SO NOTHING gets written to the DB.
You can see in OPs VIDEO he leaves the select as DISABLED.

Some will think DUH that's obvious - but its NOT because with the status disabled everything still APPEARS to work NORMALLY front end and backend other than the admin data is NOT saved. The fact that a default status of 1 is in the DB ENABLES the affiliate section to be SHOWN in CUSTOMER ACCOUNT when if status is 0 it does NOT. WHY a status of 1 (enabled) is in the DB when the default select is DISABLED I have not looked into. IF the affiliate data DID NOT appear in customer account affiliate section ( as it SHOULD NOT until ENABLED ) Then it would become OBVIOUS that it has to be ENABLED in the ADMIN customer edit affiliate tab.
Last edited by mikeinterserv on Mon Mar 21, 2022 11:25 am, edited 1 time in total.

Active Member

Posts

Joined
Thu May 28, 2020 6:55 am
Location - Wales

Post by straightlight » Mon Mar 21, 2022 10:44 am

mikeinterserv wrote:
Mon Mar 21, 2022 9:11 am
Well in the end this worked
You have to fill ALL of the fields in affiliate tab on ADMIN CUSTOMER EDIT affiliate tab and select enabled at the bottom.
If you leave a field blank you will get NO ERROR. and you will see success message. If you selected ENABLED in the select box at the bottom with ANY field missing, like website or company or tax code etc it would throw an error saying check form carefully for errors but with NO INDICATION ANYWHERE which field is in error. Once ALL form fields are filled and ENABLED is selected at the bottom everything THEN gets saved to the correct table customer_affiliate.
Now BOTH admin AND customer see the same data. You cannot ENABLE STATUS with a blank field it will throw an ERROR but NOT tell you what the error is.

Now why this is messed up - is because the model is looking for $data[affiliate} which RELIES on the STATUS SELECT (enabled/disabled) to be ENABLED.
If it remains DISABLED everything appears to work EXCEPT this DATA SAVE PROBLEM - I left it disabled because that is how it defaults even though the status in the DB is set to 1 ENABLED. With the status DISABLED all appears well but $data['affiliate'] = ''; SO NOTHING gets written to the DB.
You can see in OPs VIDEO he leaves the select as DISABLED.

Some will think DUH that's obvious - but its NOT because with the status disabled everything still APPEARS to work NORMALLY front end and backend other than the admin data is NOT saved. The fact that a default status of 1 is in the DB ENABLES the affiliate section to be SHOWN in CUSTOMER ACCOUNT when if status is 0 it does NOT. WHY a status of 1 (enabled) is in the DB when the default select is DISABLED I have not looked into. IF the affiliate data DID NOT appear in customer account affiliate section ( as it SHOULD NOT until ENABLED ) Then it would become OBVIOUS that it has to be ENABLED in the ADMIN customer edit affiliate tab. AND after ALL the ADMIN CUSTOM FIELD STILL did NOT get saved correctly.
Have you tested with print_r and exit function once the affiliate option is enabled to see what does get saved at this point?

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by mikeinterserv » Mon Mar 21, 2022 11:29 am

Yes
Everything gets saved now. You can see admin changes in customer for all fields.
You can edit in CUSTOMER account and see all fields reflected in ADMIN other than the CUSTOM FIELD.
I made so many changes looking at this it may now be a simple error on my part as I am sure I saw them all working correctly at one point.
OK it is working now.
In short
This fix must be applied which I guess the OP has done, line 636 here specifically for txt field, but 631 in my file.
https://github.com/opencart/opencart/pu ... 51ba73a084
Also the code I posted earlier for affiliate edit must be applied. Then it will work as described at length earlier.
error checking needs checking. The STATUS SELECT INPUT in admin needs updating to enabled on addaffilaite function. I guess it only gets set to DISABLED in DB if the NEEDS APPROVAL is checked for affiliates. There is something wrong with that. IF affiliate accounts don't need APPROVAL then they should be active and ENABLED by default thus avoiding this issue.

Active Member

Posts

Joined
Thu May 28, 2020 6:55 am
Location - Wales

Post by xxvirusxx » Mon Mar 21, 2022 2:57 pm

mikeinterserv wrote:
Mon Mar 21, 2022 11:29 am
OK it is working now.
90% is fixed.
Still remain database custom_field values insert bug (not checked in controller yet)

Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by straightlight » Mon Mar 21, 2022 7:18 pm

mikeinterserv wrote:
Mon Mar 21, 2022 11:29 am
Yes
Everything gets saved now. You can see admin changes in customer for all fields.
You can edit in CUSTOMER account and see all fields reflected in ADMIN other than the CUSTOM FIELD.
I made so many changes looking at this it may now be a simple error on my part as I am sure I saw them all working correctly at one point.
OK it is working now.
In short
This fix must be applied which I guess the OP has done, line 636 here specifically for txt field, but 631 in my file.
https://github.com/opencart/opencart/pu ... 51ba73a084
Also the code I posted earlier for affiliate edit must be applied. Then it will work as described at length earlier.
error checking needs checking. The STATUS SELECT INPUT in admin needs updating to enabled on addaffilaite function. I guess it only gets set to DISABLED in DB if the NEEDS APPROVAL is checked for affiliates. There is something wrong with that. IF affiliate accounts don't need APPROVAL then they should be active and ENABLED by default thus avoiding this issue.
addAffiliate method.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by mikeinterserv » Mon Mar 21, 2022 10:52 pm

xxvirusxx wrote:
Mon Mar 21, 2022 2:57 pm
90% is fixed.
Still remain database custom_field values insert bug (not checked in controller yet)
No 100% fixed.
Custom fields insert into DB fine in customer account and admin edit.

Active Member

Posts

Joined
Thu May 28, 2020 6:55 am
Location - Wales

Post by xxvirusxx » Mon Mar 21, 2022 11:23 pm

mikeinterserv wrote:
Mon Mar 21, 2022 10:52 pm
No 100% fixed.

1. Create a custom field for account location. Custom field to be non required
2. From database, remove custom_field values from customer and customer_affiliate table from same customer_id
3. Go to admin, edit a customer ( who is also affiliate), then go to Affiliate tab and fill that custom field for affiliate.
4. Save

5. Go again to database oc_customer table and you will see something like this in custom_field

Code: Select all

{"2":"","1":"my_text_from_affiliate"}
custom_field from oc_customer should not have any values...because you have typed only in the affiliate custom field. An the custom field from account was empty, no text in.
6. Same data is inserted in custom_field from customer_affiliate table. And should be only this, because you have typed only in the custom field from Affiliate.

Code: Select all

{"1":"my_text_from_affiliate"}

Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by mikeinterserv » Mon Mar 21, 2022 11:33 pm

I will do that
This is what I currently get
{"4":"Customer End"} in customer_affiliate table
{"4":"Admin End Test"} in customer table.
Which is the custom field ID plus the DATA.
Customer table ONLY gets updated from admin which adds data to customer table custom field AND also customer affiliate.
Customer_affiliate table ONLY gets updated by customer.
The data changes CORRECTLY on EDIT from admin OR account.
In account I write customer .... in admin I write admin... to verify.

Active Member

Posts

Joined
Thu May 28, 2020 6:55 am
Location - Wales
Who is online

Users browsing this forum: No registered users and 52 guests