handler on setting value change

[quote name='imac' timestamp='1437051792' post='223218']

Solution from [font=“arial, verdana, tahoma, sans-serif”][color=#282828]WSA team should work correctly. To see more example search the CS-Cart app/addons folder for “[/color][/font]fn_settings_actions_” there are several add-ons that add setting handlers.

[/quote]



Hm, for example for SEO module I see:



function fn_settings_actions_addons[color=#ff0000]seo[/color][color=#008000]seo_product_type[/color]($new_value, $old_value)



Please advise

[quote name='eComLabs' timestamp='1437054223' post='223227']

Hm, for example for SEO module I see:



function fn_settings_actions_addons[color=#ff0000]seo[/color][color=#008000]seo_product_type[/color]($new_value, $old_value)



Please advise

[/quote]

You are superb! Thanks for attention.



Here is the code from Settings.php


$addon_func_name = 'fn_settings_actions_addons_' . fn_strtolower($old_data['section_name']) . '_' . fn_strtolower($old_data['name']);
if (function_exists($addon_func_name)) {
$addon_func_name($data['value'], $old_data['value']);
}


Where

$old_data['section_name']) is add-on ID

$old_data['name'] - setting name



I updated the WSA post to save time for others.

Imac, thank you

Imac, thank you very much



best regards,

WSA team

Thanks all for replying, it's almost working, but not quite yet.



Two notes before I describe the issue:

  1. return true; appears to make no difference, I allready thought so, because the examples in [color=#282828][font=arial, verdana, tahoma, sans-serif]app/schemas/settings/actions.functions.php don't do that either.
  2. you said “[/font][/color][color=#282828][font=arial, verdana, tahoma, sans-serif]$old_data['name'] - setting name”, but I think it should be setting [/font][/color]item id[color=#282828][font=arial, verdana, tahoma, sans-serif], not setting name, because then (in my example) it would be E-mailaddress, not emailaddress?[/font][/color]



    The issue I'm now having is as followes.

    As you can see I have an input field in settings, when I enter something in it, for example 'test', it correctly saves and shows no notification.

    If I then go to settings again and leave the field empty, it saves and mistakenly shows no notification.

    When I then go to settings again and enter 'test' again (or something else) it saves the field and shows the notification that it shouldn't be empty.



    It seems like $new_value isn't actually $new_value, but the old value somehow.

    Also $new_value = $old_value; doesn't appear to work, because when I do get the notification, it still saves the value entered.



    Am I thinking about this the wrong way?

I just did some more testing with:


fn_set_notification('W', 'Check input', 'E-mailaddress cannot be empty: NEW: '.$new_value.' - OLD: '.$old_value, 'S');




And when I get the notification (previous value='', currently entered value='test') it shows:

[color=#C09853]E-mailaddress cannot be empty: NEW: - OLD: test[/color]

So for some reason it seems new_value and old_value are switched?

Sorry guys, I could have figured that one out myself, I mistakenly copied old and new value from the example functions.



In [color=#282828][font=arial, verdana, tahoma, sans-serif]app/schemas/settings/actions.functions.php all functions are function([/font][/color]$new_value, $old_value) and I somehow copied it and switched them to ($old_value, $new_value), so it's my own stupid mistake.



It's now working as expected.



Again thanks all for helping me out.