Hook Path Question

I thought I had a pretty good grip on using TPL hooks, but I am baffled as to why the current hook I am trying to target isn't working. I am betting it's my path and I was hoping to get some feedback on where I might be going wrong.



I am trying to add a tiny bit of code right above the promo code input field on the cart page, and as luck would have it there is a hook for that particular block:



{hook name="checkout:discount_coupons"}




Now if I understand how hooks work ( and I must be making a mistake here somewhere ) the code that I would like executed before this hook should be created in the following directory:



themes/basic/templates/addons/my_changes/hooks/checkout/




The file that should be placed in the above location in my case should be:



discount_coupons.pre.tpl




This file would include whatever items I would like to appear before the hook.



I have created everything above, uploaded it, verified that is on the server, cleared my browsers cache, cleared the carts cache ( ?cc ) and yet nothing seems to get my simple html addition to display.



It was my understanding that if you are using a hook you would take the first part of the hook name, in this case “checkout” and that would be the directory you would create in the “hooks” folder. Then the file name would be based off of the 2nd part of the hook with either pre, post or override appended to the name…



I should also mention that I am using CS-Cart v4 and I have caching disabled.



Am I missing something or am I off on the wrong track here?

All looks good to me. Both the path and filename are correct. Out of interest, do you get any different results if you use “discount_coupons.override.tpl” instead of 'pre'. Conventionally there should be no difference in terms of getting it to render, but I have experienced this before where a pre nor post would work, but override did. Why, I have no idea…and never got an answer from support on it either.



Might be a stupid question to ask, but is the my_changes addon actually enabled?

[quote name='StellarBytes' timestamp='1375397573' post='166200'] All looks good to me. Both the path and filename are correct. Out of interest, do you get any different results if you use “discount_coupons.override.tpl” instead of 'pre'. Conventionally there should be no difference in terms of getting it to render, but I have experienced this before where a pre nor post would work, but override did. Why, I have no idea…and never got an answer from support on it either. Might be a stupid question to ask, but is the my_changes addon actually enabled? [/quote]



Thanks for the quick reply StellarBytes!



I just now tried to use “post” and “override” and I cleared the site/store cache before each test. Unfortunately, it didn't yield any different results…



I am at a complete loss as to why this isn't working if my paths are correct. The addon My_Changes is activated and I have other hooks working as well.

Have you tried:-

design/frontend/skins/1/basic/templates/addons/my_changes/hooks/checkout/discount_coupons.pre.tpl

Where '1' is active skin ID.



Are your other working hook pre/post/override in the same setup, ie:-


themes/basic/templates/addons/my_changes/hooks/index/blah.post.tpl

[quote name='StellarBytes' timestamp='1375443339' post='166221']

Have you tried:-

design/frontend/skins/1/basic/templates/addons/my_changes/hooks/checkout/discount_coupons.pre.tpl

Where '1' is active skin ID.



Are your other working hook pre/post/override in the same setup, ie:-


themes/basic/templates/addons/my_changes/hooks/index/blah.post.tpl


[/quote]





Thank you for all of your suggestions so far, I really appreciate it!



I saw the first path in another forum post when I was trying to dig up some answers, but I thought that was only for cs-cart versions below 4? As the new version doesn't have the directories:


design/frontend/skins



cs-cart 4 has:


design/themes/[theme_name]



I did however try and add the theme files into a “1” directory and unfortunately it didn't work.



To answer your 2nd question all of my other hooks are set up the same way and work as they should (thankfully):


themes/basic/templates/addons/my_changes/hooks/index/styles.post.tpl


themes/basic/templates/addons/my_changes/hooks/buttons/add_to_cart.override.tpl



Could this be another addon/template overriding my changes that I can't see? I wish there were better docs for design/development, makes tracking these things down pretty damn tough…

If another addon is doing an override and it's priority is higher than your addon then any pre, post or override will be thrown away and their override will establish a new “base” for further pre/post operations.

.

I believe that a standard cs-cart V4 configured to use one store will not use a store_id designator in the path. I.e. in my development environment there are no store id's in the theme paths.



You might try adding a {debug} tag in your hooked file along with a comment like:


and then view the page source to see if it shows.

[quote name=‘tbirnseth’ timestamp=‘1375468345’ post=‘166239’]

If another addon is doing an override and it’s priority is higher than your addon then any pre, post or override will be thrown away and their override will establish a new “base” for further pre/post operations.

.

I believe that a standard cs-cart V4 configured to use one store will not use a store_id designator in the path. I.e. in my development environment there are no store id’s in the theme paths.



You might try adding a {debug} tag in your hooked file along with a comment like:


and then view the page source to see if it shows.

[/quote]



Gave {debug} and a shot, but unfortunately it didn’t return anything either on the page or in the source code. I was really hoping that would give me a clue… On the upside, I didn’t know about the smarty debug tag :-)

It sounds like your file is being overridden by another addon. Generally the priority of my_changes is the highest. But if someone created an addon with the same priority and it's name would sort first (ascending) then it will override the my_changes hooks.

Thank you all for this post, I was having the same issue with the same hook and I discovered it was the Gift Certificate addon overriding the whole hook in my case. I would have never through to look at other addons!

Thank you all for this post, I was having the same issue with the same hook and I discovered it was the Gift Certificate addon overriding the whole hook in my case. I would have never through to look at other addons!

May I know how did you achieve on this. I too encounter the issue that I am unable to override a template file on My_changes which the same file is overridden by another addon.

Please advise. Thanks a lot.

May I know how did you achieve on this. I too encounter the issue that I am unable to override a template file on My_changes which the same file is overridden by another addon.

Please advise. Thanks a lot.

I am afraid, you cannot override override

I am afraid, you cannot override override

Ooh! I see..Is there any other way for override to override tpl?

Thanks a lot.

Ooh! I see..Is there any other way for override to override tpl?

Thanks a lot.

As it was mentioned earlier, play with addons priority. Not sure why it does not work in your case, but we solved such issues with priority settings

As it was mentioned earlier, play with addons priority. Not sure why it does not work in your case, but we solved such issues with priority settings

Hi eComLabs,

Thanks a lot for the reply.

Since it is not working priority based addon at my side, I have switched to Single page checkout layout.

Thanks much again for the support.

But if the priority of your template is higher then your override should be the one that is used.

Hi EZ,

Thanks much for your suggestion.

As you mentioned, understood that I need to keep the priority value is 0 for the "my_changes" addon in the cscart_addons table. Then, it solves my override problem with personal help of SoftSolid team.

Thanks all for sharing your time to help on this and thanks to SoftSolid team as well.

See other post. Any php hooks you may use, you may want to run them with an explicit high priority call to fn_register_hooks() to ensure my_changes gets priority for both php and template hooks.

See other post. Any php hooks you may use, you may want to run them with an explicit high priority call to fn_register_hooks() to ensure my_changes gets priority for both php and template hooks.

Hi EZ,

Sorry for the late reply.

Awesome, I will try accordingly.

Thanks.