Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

handler on setting value change Rate Topic   - - - - -

 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 19833 posts

Posted 16 July 2015 - 01:43 PM #21

Solution from WSA team should work correctly. To see more example search the CS-Cart app/addons folder for "fn_settings_actions_" there are several add-ons that add setting handlers.


Hm, for example for SEO module I see:

function fn_settings_actions_addons_seo_seo_product_type($new_value, $old_value)

Please advise

GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    CS-Cart RU                         24500 руб.
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      CS-Cart RU + UniTheme    36000 руб.


 
  • imac
  • Head of Product
  • CS-Cart Architects
  • Join Date: 22-Nov 05
  • 2074 posts

Posted 16 July 2015 - 02:50 PM #22

Hm, for example for SEO module I see:

function fn_settings_actions_addons_seo_seo_product_type($new_value, $old_value)

Please advise

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.
Ilya Makarov,
CS-Cart Architect Team
Suggest and vote for new features | Report a bug

 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 19833 posts

Posted 16 July 2015 - 03:43 PM #23

Imac, thank you

GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    CS-Cart RU                         24500 руб.
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      CS-Cart RU + UniTheme    36000 руб.


 

Posted 16 July 2015 - 05:02 PM #24

Imac, thank you very much

best regards,
WSA team

 
  • RagingRaven
  • Member
  • Trial users
  • Join Date: 26-Mar 13
  • 44 posts

Posted 17 July 2015 - 12:20 PM #25

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 app/schemas/settings/actions.functions.php don't do that either.
2. you said "
$old_data['name'] - setting name", but I think it should be setting item id, not setting name, because then (in my example) it would be E-mailaddress, not emailaddress?

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?

 
  • RagingRaven
  • Member
  • Trial users
  • Join Date: 26-Mar 13
  • 44 posts

Posted 17 July 2015 - 12:34 PM #26

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:
E-mailaddress cannot be empty: NEW: - OLD: test
So for some reason it seems new_value and old_value are switched?

 
  • RagingRaven
  • Member
  • Trial users
  • Join Date: 26-Mar 13
  • 44 posts

Posted 17 July 2015 - 12:45 PM #27

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

In app/schemas/settings/actions.functions.php all functions are function($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.