Jump to content

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

Your Add-On Needs A New Hook In Cs-Cart. Post It Here. Rate Topic   * * * * * 1 votes

 
  • imac
  • CTO
  • CS-Cart Architects
  • Join Date: 22-Nov 05
  • 1,849 posts

Posted 08 June 2015 - 09:02 AM #1

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.

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);


No strict rules for templates, so please provide some explanation what exactly are you going to do with template hook.
Ilya Makarov,
CS-Cart Architect Team
Suggest and vote for new features | Report a bug

 
  • eucgroup
  • Advanced Member
  • Members
  • Join Date: 08-Apr 15
  • 65 posts

Posted 08 June 2015 - 03:42 PM #2

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

 

Posted 08 June 2015 - 03:51 PM #3

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


I can second that...

Car Stickers and Decals
Cs-Cart 4.6.3 / Future Hosting Private Dedicated Server - Xeon E5-2420, 32Gb, 480 SSD x4
2 Storefronts - Over 60,000 Products / 400+ Categories / 140k Monthly Visitors


 
  • imac
  • CTO
  • CS-Cart Architects
  • Join Date: 22-Nov 05
  • 1,849 posts

Posted 08 June 2015 - 04:41 PM #4

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

I can second that...


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

 

Posted 08 June 2015 - 04:42 PM #5

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.


That would be nice...

Car Stickers and Decals
Cs-Cart 4.6.3 / Future Hosting Private Dedicated Server - Xeon E5-2420, 32Gb, 480 SSD x4
2 Storefronts - Over 60,000 Products / 400+ Categories / 140k Monthly Visitors


 
  • ilib
  • Advanced Member
  • Members
  • Join Date: 22-Mar 12
  • 84 posts

Posted 08 June 2015 - 11:05 PM #6

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....

 
  • Hungryweb
  • Senior Member
  • Authorized Reseller
  • Join Date: 10-Feb 12
  • 1,177 posts

Posted 09 June 2015 - 05:37 AM #7

Hi Imac,

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

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

Posted Image

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

Posted Image

and new tpl hook request :D

1.

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

this can be very helpful, for the add-on Fancy Color Filter we use override but is not so good to use overrides

more hooks will follow :)

Thank you,

---
Valentin
part of hungryweb.net

 
  • imac
  • CTO
  • CS-Cart Architects
  • Join Date: 22-Nov 05
  • 1,849 posts

Posted 09 June 2015 - 09:55 AM #8

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....


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

 
  • imac
  • CTO
  • CS-Cart Architects
  • Join Date: 22-Nov 05
  • 1,849 posts

Posted 09 June 2015 - 10:49 AM #9

1. http://forum.cs-cart...-renegerate-id/
2. http://forum.cs-cart...hooks-requests/
3. blocks/product_filters/original.tpl

Thanks Vali,

I've created a task for this.
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
  • 16,128 posts

Posted 11 June 2015 - 01:32 PM #10

Functions which works with destinations do not have any hooks at all. Please check
GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration

Certified CS-Cart RU Developer | Сертифицированный разработчик на CS-Cart Русская Версия

 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 10,140 posts

Posted 12 June 2015 - 12:15 AM #11

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.

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
  • 16,128 posts

Posted 12 June 2015 - 09:20 AM #12

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.


Please share your idea. Do you change core files during the installation?
GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration

Certified CS-Cart RU Developer | Сертифицированный разработчик на CS-Cart Русская Версия

 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 10,140 posts

Posted 12 June 2015 - 08:33 PM #13

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.

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.


 
  • P-Pharma
  • Junior Member
  • Members
  • Join Date: 30-Jun 10
  • 1,073 posts

Posted 12 June 2015 - 10:38 PM #14

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.

 
  • eucgroup
  • Advanced Member
  • Members
  • Join Date: 08-Apr 15
  • 65 posts

Posted 14 June 2015 - 03:42 PM #15

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.


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

 
  • imac
  • CTO
  • CS-Cart Architects
  • Join Date: 22-Nov 05
  • 1,849 posts

Posted 17 June 2015 - 01:20 PM #16

1. http://forum.cs-cart...-renegerate-id/
2. http://forum.cs-cart...hooks-requests/
3. blocks/product_filters/original.tpl


Will be available in 4.3.3
Ilya Makarov,
CS-Cart Architect Team
Suggest and vote for new features | Report a bug

 
  • Hungryweb
  • Senior Member
  • Authorized Reseller
  • Join Date: 10-Feb 12
  • 1,177 posts

Posted 17 June 2015 - 02:04 PM #17

Will be available in 4.3.3

Thank you

 
  • Hungryweb
  • Senior Member
  • Authorized Reseller
  • Join Date: 10-Feb 12
  • 1,177 posts

Posted 18 June 2015 - 06:29 AM #18

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


Thank you,

---
Valentin
part of hungryweb.net

 

Posted 23 June 2015 - 03:09 PM #19

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)


 
  • imac
  • CTO
  • CS-Cart Architects
  • Join Date: 22-Nov 05
  • 1,849 posts

Posted 30 June 2015 - 09:57 PM #20

Maybe considering adding hooks like:

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


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

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)


Will be there in 4.3.4 or 4.3.5
Ilya Makarov,
CS-Cart Architect Team
Suggest and vote for new features | Report a bug