Your Add-On Needs A New Hook In Cs-Cart. Post It Here.

Guys,



What if we start post all the hooks you need in this thread. I understand how important hooks are for add-on development.

The format of request should be.



file, function, which hook do you need.



Several words about how we add PHP hooks, it's important please read.

There are 4 possible type of hooks each hook name should have name same as function name and can have on of the suffixes:

  1. “_pre” hook - located at function beginning and should pass all the parameters function accepts. e.g.:

fn_set_hook('add_feature_variant_pre', $feature_id, $variant);

2. “_post” hook - located at the end of function and should pass all the parameters function accepts plus important paramters that were defined in function body. e.g.:

fn_set_hook('delete_product_option_post', $option_id, $pid, $option_deleted);

3. “_sql” hook or no-prefix hook - hook that used to execute SQL query, or exist in the function body. We do not add hooks to cycles.

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

4. other suffixes like “_before”, “_after” e.g.:

fn_set_hook('update_page_before', $page_data, $page_id, $lang_code);



I recommend to provide request for the hook in the following format.

[quote]

I need a hook in fn.catalog.php in fn_delete_product_files


function fn_delete_product_files($file_id, $product_id = 0)
{
fn_set_hook('delete_product_files_pre', $file_id, $product_id);


[/quote]



No strict rules for templates, so please provide some explanation what exactly are you going to do with template hook.

i want to learn…but still i dont get it… lol ^_^

[quote name=‘eucgroup’ timestamp=‘1433778133’ post=‘217866’]

i want to learn…but still i dont get it… lol ^_^

[/quote]



I can second that…

[quote name=‘eucgroup’ timestamp=‘1433778133’ post=‘217866’]

i want to learn…but still i dont get it… lol ^_^

[/quote]

[quote name=‘CarStickersDecals’ timestamp=‘1433778672’ post=‘217870’]

I can second that…

[/quote]



Our Russian youtube channel has a series of amazing screencast on how to start developing for CS-Cart. Lots of Russian clients begin to code add-ons by themselves. I hope sooner or later I will adapt these screencasts for english.

[quote name='imac' timestamp='1433781695' post='217880']

Our Russian youtube channel has a series of amazing screencast on how to start developing for CS-Cart. Lots of Russian clients begin to code add-ons by themselves. I hope sooner or later I will adapt these screencasts for english.

[/quote]



That would be nice…

Hi, Imac

Is that (theoretically) possibly to modify the process of cscart upgrade in such a way so any hooks (fn_set_hook or {hook foo:bar}…{/hook}) to be not deemed as modification of code and transferred to corresponding place of newer version somehow?

For example if the strings before and after the hook in new and old versions are identical, so the hook can be copied into the new file, otherwise an exception will be logged.

Because most likely you will not change more that a few percents of the code of any php or tpl file during upgrade.

That way developers may add hooks by themselves wherever they wish…

Hi Imac,



Until now on forum we had already 2 php hooks requests:



1. http://forum.cs-cart…-renegerate-id/







2. http://forum.cs-cart…hooks-requests/







and new tpl hook request :D



1.



#file ```php
blocks/product_filters/original.tpl

#before ```php
<br />
		{if $filter.slider}<br />
			{if $filter.feature_type == "ProductFeatures::DATE"|enum}<br />
				{include file="blocks/product_filters/components/product_filter_datepicker.tpl" filter_uid=$filter_uid filter=$filter}<br />
			{else}<br />
				{include file="blocks/product_filters/components/product_filter_slider.tpl" filter_uid=$filter_uid filter=$filter}<br />
			{/if}<br />
		{else}<br />
			{include file="blocks/product_filters/components/product_filter_variants.tpl" filter_uid=$filter_uid filter=$filter collapse=$collapse}<br />
		{/if}<br />

```<br />
#after```php
<br />
		{hook name="products:filter_variants"}<br />
		{if $filter.slider}<br />
			{if $filter.feature_type == "ProductFeatures::DATE"|enum}<br />
				{include file="blocks/product_filters/components/product_filter_datepicker.tpl" filter_uid=$filter_uid filter=$filter}<br />
			{else}<br />
				{include file="blocks/product_filters/components/product_filter_slider.tpl" filter_uid=$filter_uid filter=$filter}<br />
			{/if}<br />
		{else}<br />
			{include file="blocks/product_filters/components/product_filter_variants.tpl" filter_uid=$filter_uid filter=$filter collapse=$collapse}<br />
		{/if}<br />
		{/hook}<br />

```<br />
<br />
this can be very helpful, for the add-on [url="https://www.hungryweb.net/cs-cart-addons/fancy-color-filter.html"][b]Fancy Color Filter[/b][/url] we use override but is not so good to use overrides<br />
<br />
more hooks will follow <img src="upload://rA9Qa8gnUPZzRZRdI8kt3dpjkrs.png" class="bbc_emoticon" alt=":)"><br />
<br />
Thank you,<br />
<br />
[color=#282828][font=arial, verdana, tahoma, sans-serif]---[/font][/color]<br />
[color=#282828][font=arial, verdana, tahoma, sans-serif]Valentin[/font][/color]<br />
[color=#808080][font=arial, verdana, tahoma, sans-serif][size=2]part of hungryweb.net[/size][/font][/color][color=#282828][font=arial, verdana, tahoma, sans-serif] [/font][/color]

[quote name='ilib' timestamp='1433804758' post='217911']

Hi, Imac

Is that (theoretically) possibly to modify the process of cscart upgrade in such a way so any hooks (fn_set_hook or {hook foo:bar}…{/hook}) to be not deemed as modification of code and transferred to corresponding place of newer version somehow?

For example if the strings before and after the hook in new and old versions are identical, so the hook can be copied into the new file, otherwise an exception will be logged.

Because most likely you will not change more that a few percents of the code of any php or tpl file during upgrade.

That way developers may add hooks by themselves wherever they wish…

[/quote]



ilib, that's not a good thing to implement because in this case we will have many stores of the same version with different core files.

The right solution is to have all the required hooks in CS-Cart core.

[quote name='Vali' timestamp='1433828261' post='217938']

1. http://forum.cs-cart…-renegerate-id/

2.[color=#282828][font=arial, verdana, tahoma, sans-serif] [/font][/color]http://forum.cs-cart…hooks-requests/

3. [color=#000000][size=2]blocks[/size][/color][color=#666600][size=2]/[/size][/color][color=#000000][size=2]product_filters[/size][/color][color=#666600][size=2]/[/size][/color][color=#000000][size=2]original[/size][/color][color=#666600][size=2].[/size][/color][color=#000000][size=2]tpl[/size][/color]

[/quote]

Thanks Vali,



I've created a task for this.

Functions which works with destinations do not have any hooks at all. Please check

Please search my older submissions to helpdesk regarding requsts for added hooks. The response was always that they were forwarded to the developmers but there was never a response nor were the hooks ever implemented. I'd given up and simply started creating my own on the fly during installation.

[quote name='tbirnseth' timestamp='1434068146' post='218483']

Please search my older submissions to helpdesk regarding requsts for added hooks. The response was always that they were forwarded to the developmers but there was never a response nor were the hooks ever implemented. I'd given up and simply started creating my own on the fly during installation.

[/quote]



Please share your idea. Do you change core files during the installation?

Generally as part of my installation environment I have a specification that can be set up to add either PHP, Admin tpl or Customer tpl hooks. It's really rare that I use them anymore but for some addons (like payment capture), more info is needed from Anet than cs-cart captures in the payment info. These were only used for addon products, not custom addon development.



This is all part of a tool set we developed early on due to lack of any addon upgrade mechanism in cs-cart and given that most of our requests for hooks seemed to just fall into a black hole. I think only one of our current addons uses a PHP hook and I don't think anything any longer uses custom customer/admin template hooks. So it's become somewhat moot.

I know i submitted various hook requests in past years. AFAIk these were never implemented. IIRC one of my request was to have hooks in the js related files so that I can apply javascript / jQuery effects to one storefront without affecting the other storefronts.

Currently when I add a javascript effect (like fading tabs) to one style, it even affects the admincp.



it would be great if hooks could be added to resolve that. Or if sharing of js could be avoided.

[quote name='imac' timestamp='1433781695' post='217880']

Our Russian youtube channel has a series of amazing screencast on how to start developing for CS-Cart. Lots of Russian clients begin to code add-ons by themselves. I hope sooner or later I will adapt these screencasts for english.

[/quote]



Oh, i will be waiting for your screencast… i want to learn of coding add-ons… i hope this is not hard…lol

[quote name='Vali' timestamp='1433828261' post='217938']

1. http://forum.cs-cart…-renegerate-id/

2.[color=#282828][font=arial, verdana, tahoma, sans-serif] [/font][/color]http://forum.cs-cart…hooks-requests/

3.[size=4] [color=#000000]blocks[/color][color=#666600]/[/color][color=#000000]product_filters[/color][color=#666600]/[/color][color=#000000]original[/color][color=#666600].[/color][color=#000000]tpl[/color][/size]

[/quote]



Will be available in 4.3.3

[quote name='imac' timestamp='1434547235' post='219174']

Will be available in 4.3.3

[/quote]

Thank you

Maybe considering adding hooks like:


{hook name="pages:page_content_`$page.page_id`"}
...
{/hook}




also for backend can be very helpful the hooks


{hook name="index:meta"}{/hook}


{hook name="index:footer"}{/hook}



which are missing right now





[color=#282828][font=arial, verdana, tahoma, sans-serif]Thank you,[/font][/color]



[color=#282828][font=arial, verdana, tahoma, sans-serif]—[/font][/color]

[color=#282828][font=arial, verdana, tahoma, sans-serif]Valentin[/font][/color]

[color=#808080][font=arial, verdana, tahoma, sans-serif][size=2]part of hungryweb.net[/size][/font][/color][color=#282828][font=arial, verdana, tahoma, sans-serif] [/font][/color]

There is currently a hook in the fn_get_banners function in banners/func.php, it would be really useful to have a similar hook in the fn_get_banner_data function

My current code:


// Line 131 in app/addons/banners/func.php
fn_set_hook('get_banner_data_post', $banner)

[quote name='Vali' timestamp='1434608946' post='219242']

Maybe considering adding hooks like:


{hook name="pages:page_content_`$page.page_id`"}
...
{/hook}




[/quote]



What template do you mean? I actually don't like the idea of dynamic hooks.

This can affect the performance.

[quote name='matthew.erwin' timestamp='1435072179' post='220106']

There is currently a hook in the fn_get_banners function in banners/func.php, it would be really useful to have a similar hook in the fn_get_banner_data function

My current code:


// Line 131 in app/addons/banners/func.php
fn_set_hook('get_banner_data_post', $banner)


[/quote]



Will be there in 4.3.4 or 4.3.5