Jump to content

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

How To Ensure That User Data To Be Saved Uppercase Letter? Rate Topic   * * * * * 1 votes

 
  • ooaykac
  • Senior Member
  • Members
  • Join Date: 22-Nov 12
  • 297 posts

Posted 23 January 2015 - 04:26 PM #1

I want that user adress data such as address line and name/sir name fields to be saved in uppercase letter while saving. How to do this? Which function should I use and where to make changes? Or on which controllers should I make changes?

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

Posted 26 January 2015 - 09:35 AM #2

I want that user adress data such as address line and name/sir name fields to be saved in uppercase letter while saving. How to do this? Which function should I use and where to make changes? Or on which controllers should I make changes?


Use the update_user_pre hook which is located in the fn_update_user function

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 руб.


 
  • ooaykac
  • Senior Member
  • Members
  • Join Date: 22-Nov 12
  • 297 posts

Posted 26 January 2015 - 07:10 PM #3

Use the update_user_pre hook which is located in the fn_update_user function

Thanks eComLabs.

I want apply this change to all profile fields. What code should I use not to add all profile fields in codes?

function fn_my_addon_update_user_pre(&$user_id, &$user_data, &$auth, &$ship_to_another, &$notify_user, &$send_password)
{
	    $user_data['b_address'] = strtoupper($user_data['b_address']);

    return true;
}

I don't want add all profile fields here manually (line by line). How can I specify all profile fields with a shot code?

 
  • Anaconda
  • Senior Member
  • Members
  • Join Date: 19-Sep 14
  • 151 posts

Posted 26 January 2015 - 08:19 PM #4

And if you place the strtoupper in the function.
Example:
function strtoupper(str) {
  //   example 1: strtoupper('Name);
  //   returns 1: 'NAME'
  return (str + '')
    .toUpperCase();
}
Hope this help you further.

Regards

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

Posted 27 January 2015 - 08:25 AM #5

Thanks eComLabs.

I want apply this change to all profile fields. What code should I use not to add all profile fields in codes?

function fn_my_addon_update_user_pre(&$user_id, &$user_data, &$auth, &$ship_to_another, &$notify_user, &$send_password)
{
		$user_data['b_address'] = strtoupper($user_data['b_address']);

	return true;
}

I don't want add all profile fields here manually (line by line). How can I specify all profile fields with a shot code?


Add the following string to find which fields should not be uppercased:

fn_print_r($user_data);

Then add a code similar to this:

foreach ($user_data as $k => $v) {
  if (!is_array($v) && !in_array($k, array('first_key_to_skip', 'second_key_to_skip', 'etc'))) {
    $user_data[$k] = strtoupper($v);
  }
}

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 руб.


 
  • ooaykac
  • Senior Member
  • Members
  • Join Date: 22-Nov 12
  • 297 posts

Posted 27 January 2015 - 09:15 AM #6

Thanks.

 
  • vin86
  • Member
  • Members
  • Join Date: 16-Nov 09
  • 28 posts

Posted 09 January 2019 - 11:29 PM #7

hi, i have created init.php and func.php in app/addons/my_changes with code

function fn_my_addon_update_user_pre(&$user_id, &$user_data, &$auth, &$ship_to_another, &$notify_user, &$send_password)
{
		$user_data['b_address'] = strtoupper($user_data['b_address']);

	return true;
}

but i can see any changes



 
  • galtinbaeva
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 06-Dec 13
  • 3364 posts

Posted 10 January 2019 - 05:22 AM #8

hi, i have created init.php and func.php in app/addons/my_changes with code

function fn_my_addon_update_user_pre(&$user_id, &$user_data, &$auth, &$ship_to_another, &$notify_user, &$send_password)
{
		$user_data['b_address'] = strtoupper($user_data['b_address']);

	return true;
}

but i can see any changes

 

Hello,

 

Function name should be fn_my_changes_update_user_pre


Simtech Development | sales@simtechdev.com | www.simtechdev.com
CERTIFIED CS-CART PARTNER | LICENSES | DEVELOPMENT | ADD-ONS | DESIGN | UPGRADE

Google Analytics Enhanced Ecommerce - get advanced ecommerce analytics


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

Posted 10 January 2019 - 05:36 AM #9

hi, i have created init.php and func.php in app/addons/my_changes with code

function fn_my_addon_update_user_pre(&$user_id, &$user_data, &$auth, &$ship_to_another, &$notify_user, &$send_password)
{
		$user_data['b_address'] = strtoupper($user_data['b_address']);

	return true;
}

but i can see any changes

 

Also clear cache since used hooks are cached


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 руб.


 
  • vin86
  • Member
  • Members
  • Join Date: 16-Nov 09
  • 28 posts

Posted 10 January 2019 - 08:46 AM #10

nothing, any changes :-(

 

init.php

<?php
fn_register_hooks(
   'update_user_pre'
);
?>

func.php

<?php

if ( !defined('AREA') ) { die('Access denied'); }

function fn_my_changes_update_user_pre(&$user_id, &$user_data, &$auth, &$ship_to_another, &$notify_user, &$send_password)
{

	$user_data['b_firstname'] = strtoupper($user_data['b_firstname']);	
	$user_data['b_address'] = strtoupper($user_data['b_address']);	
	$user_data['b_address_2'] = strtoupper($user_data['b_address_2']);
	$user_data['b_city'] = strtoupper($user_data['b_city']);

	return true;
}

?>

I want change text from lowercase to uppercase when users insert data from checkout step

 

i also clear cache and template



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

Posted 10 January 2019 - 01:17 PM #11

Please temporary add fn_print_r($user_data); to the function and check if this function is called. Debug information should be printed out to the screen


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 руб.


 
  • vin86
  • Member
  • Members
  • Join Date: 16-Nov 09
  • 28 posts

Posted 10 January 2019 - 10:50 PM #12

ok, it works only for registered users but not for guest users. why?



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

Posted 11 January 2019 - 06:38 AM #13

ok, it works only for registered users but not for guest users. why?

 

Yes, since mentioned function works with registered users only. 

 

Additionally, you can use checkout.pre.php controller and change the $_REQUEST['user_data'] values in the update_steps mode


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 руб.