Jump to content

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

How To Override Core Functions? Rate Topic   * * * * * 1 votes

 
  • nil2567
  • Member
  • Trial users
  • Join Date: 24-Dec 14
  • 19 posts

Posted 11 January 2015 - 12:49 PM #1

I have this function:

fn_user_logout( ...

and I want to override it

in init.php i have:

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

fn_register_hooks(
'get_category_data_pre',
'fn_advanced_addon_fn_user_logout_pre'
);

in func.php I have:

fn_advanced_addon_fn_user_logout_pre( ....


what mI doing wrong here?

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

Posted 12 January 2015 - 10:17 AM #2

The fn_user_logout function does not contain any hooks. Therefore you cannot make any changes with this function. Please find more details about PHP hooks here:

http://docs.cs-cart..../php_hooks.html

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


 
  • nil2567
  • Member
  • Trial users
  • Join Date: 24-Dec 14
  • 19 posts

Posted 13 January 2015 - 06:41 PM #3

The fn_user_logout function does not contain any hooks. Therefore you cannot make any changes with this function. Please find fore details about PHP hooks here:

http://docs.cs-cart..../php_hooks.html


thanks, just 2 question:

*if I want to override that funcion on my addon, how can I do that?

*is there a way to know what functions has a hook to use?

Thanks

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

Posted 14 January 2015 - 09:21 AM #4

*if I want to override that funcion on my addon, how can I do that?


Unfortunately there is no way to do it without hooks.

*is there a way to know what functions has a hook to use?


You can check required function and find similar code:

fn_set_hook('hook_name', $param1,  $param2, .... $paramN);

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


 
  • Kuldeep
  • Newbie
  • Trial users
  • Join Date: 01-Mar 17
  • 13 posts

Posted 03 April 2017 - 09:06 AM #5

Unfortunately there is no way to do it without hooks.



You can check required function and find similar code:
 

fn_set_hook('hook_name', $param1,  $param2, .... $paramN);

 

 

Hi eComLabs,

 

I want to override  following  function in my_changes add on. So, Can you please suggest me How to create directory for this in cs cart ?

 

Thanks.

 fn_set_hook('get_categories', $params, $join, $condition, $fields, $group_by, $sortings, $lang_code);


 
  • Kuldeep
  • Newbie
  • Trial users
  • Join Date: 01-Mar 17
  • 13 posts

Posted 03 April 2017 - 10:07 AM #6

Hi eComLabs,

 

Is there any way to reverse Parent category order like Des without change order of sub categories using below hook ?

 

 

Hi eComLabs,

 

I want to override  following  function in my_changes add on. So, Can you please suggest me How to create directory for this in cs cart ?

 

Thanks.

 fn_set_hook('get_categories', $params, $join, $condition, $fields, $group_by, $sortings, $lang_code);


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

Posted 03 April 2017 - 02:11 PM #7

Hi eComLabs,

 

Is there any way to reverse Parent category order like Des without change order of sub categories using below hook ?

 

It is better to use the get_categories_post hook for this task


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


 
  • Kuldeep
  • Newbie
  • Trial users
  • Join Date: 01-Mar 17
  • 13 posts

Posted 03 April 2017 - 02:29 PM #8

Hi eComLabs,

Thanks for this.

 

It is better to use the get_categories_post hook for this task

 

Can you please give some more details about this ? because  I am developing this first time.

Thanks.



 
  • oleg.gorshkov
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 06-Dec 13
  • 2694 posts

Posted 03 April 2017 - 05:25 PM #9

Hi eComLabs,

Thanks for this.

 

 

Can you please give some more details about this ? because  I am developing this first time.

Thanks.

 

1. Create the ini.php file in app/addons/my_changes/ and declare hook in it:

fn_register_hooks(
   'get_categories_post'
);

2. Create the func.php file in app/addons/my_changes/ and add the following function:

fn_my_changes_get_categories_post($categories_list, $params, $lang_code)

In this function you can make the modification you want.

 

You can find more details in this documentation.


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

Mega SEO Package - All you need for your SEO


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

Posted 04 April 2017 - 06:36 AM #10

Note that if you want to change the $categories_list array, use

fn_my_changes_get_categories_post(&$categories_list, $params, $lang_code)

instead of

fn_my_changes_get_categories_post($categories_list, $params, $lang_code)

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


 
  • Kuldeep
  • Newbie
  • Trial users
  • Join Date: 01-Mar 17
  • 13 posts

Posted 04 April 2017 - 10:32 AM #11

Thanks Simtech for reply.

 

I had checked $categories_list but there is no option for name based sorting because no name available for category in array.

 

1. Create the ini.php file in app/addons/my_changes/ and declare hook in it:

fn_register_hooks(
   'get_categories_post'
);

2. Create the func.php file in app/addons/my_changes/ and add the following function:

fn_my_changes_get_categories_post($categories_list, $params, $lang_code)

In this function you can make the modification you want.

 

You can find more details in this documentation.



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

Posted 04 April 2017 - 02:08 PM #12

Thanks Simtech for reply.

 

I had checked $categories_list but there is no option for name based sorting because no name available for category in array.

 

What do you see if you print the content of the array?

fn_print_r($categories_list);

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


 
  • Kuldeep
  • Newbie
  • Trial users
  • Join Date: 01-Mar 17
  • 13 posts

Posted 04 April 2017 - 02:29 PM #13

 

What do you see if you print the content of the array?

fn_print_r($categories_list);

Hi eComLabs,

 

When i print the array i got following content:
It is not full array code.sorry.

Array
(
    [1] => Array
        (
            [category_id] => 1
            [parent_id] => 0
            [id_path] => 1
            [category] => one
            [position] => 10
            [status] => A
            [company_id] => 1
            [level] => 0
            [has_children] => 4
            [subcategories] => Array
                (
                    [0] => Array
                        (
                            [category_id] => 4
                            [parent_id] => 1
                            [id_path] => 1/4
                            [category] => one-c
                            [position] => 40
                            [status] => A
                            [company_id] => 1
                            [level] => 1
                        )

                )

        )

    [2] => Array
        (
            [category_id] => 2
            [parent_id] => 0
            [id_path] => 2
            [category] => two
            [position] => 20
            [status] => A
            [company_id] => 1
            [level] => 0
            [has_children] => 5
            [subcategories] => Array


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

Posted 05 April 2017 - 06:58 AM #14

 

Hi eComLabs,

 

When i print the array i got following content:
It is not full array code.sorry.

 

As you can see, category names exist in the array. Just find a way to sort array by these values


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


 
  • Kuldeep
  • Newbie
  • Trial users
  • Join Date: 01-Mar 17
  • 13 posts

Posted 05 April 2017 - 12:47 PM #15

As you can see, category names exist in the array. Just find a way to sort array by these values

Thanks eComLabs.



 
  • elsevero
  • Newbie
  • Members
  • Join Date: 07-Oct 09
  • 6 posts

Posted 25 April 2018 - 03:22 PM #16

Hi there,

 

Not sure if this is the proper topic but do I have any hooks for the fn_init_language ?. Looking to intercept the part where the CS-Cart sets the default language based on browser settings.

 

Looking forward for an answer.



 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 10551 posts

Posted 25 April 2018 - 09:46 PM #17

There are no hooks for the fn_init_language() function.  However, you might be able to set a REQUEST varaible in an init.pre.php controller to force the language or to apply different logic for determining language.  I.e.

$_REQUEST['sl'] = 'en';

 

Should force the language to be English (en) regardless of what the browser comes up with.


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


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

Posted 26 April 2018 - 06:26 AM #18

I am afraid, it will not work since fn_init_language is called before any controller


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


 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 10551 posts

Posted 26 April 2018 - 04:56 PM #19

But it can redirect if CART_LANGUAGE is not what you want. It would then stick for future pages.

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.