I have made a hook named checkoutConfirmation to show a message on checkout_confirmation using listen_injectFormDisplay.
It works but want it to show above the existing Legal MATC - it currently shows below this.
How do I change it's position?
Thank you for any pointers.
Making a Hook
-
heatherbell
- Senior Contributor
- Posts: 2540
- Joined: Mon Oct 07, 2019 4:39 am
- Phoenix Version:
- Has thanked: 35 times
- Been thanked: 243 times
-
ecartz
- Core Team
- Posts: 3084
- Joined: Tue Nov 05, 2019 6:02 pm
- Phoenix Version:
- Has thanked: 4 times
- Been thanked: 208 times
Re: Making a Hook
Look up the name of the MATC hook and then pick a name for your new hook that sorts before it.
MATC: hook_shop_siteWide_MATC
So the hook name is MATC (who'd have guessed). Sorting after it would be MATD, atc, zz, _MATC, etc. Before it would be MATB, AAA, 0MATC, 9MATC, etc. The rules are numbers, then uppercase letters (in alphabetical order), then _, then lowercase letters.
MATC: hook_shop_siteWide_MATC
So the hook name is MATC (who'd have guessed). Sorting after it would be MATD, atc, zz, _MATC, etc. Before it would be MATB, AAA, 0MATC, 9MATC, etc. The rules are numbers, then uppercase letters (in alphabetical order), then _, then lowercase letters.
-
heatherbell
- Senior Contributor
- Posts: 2540
- Joined: Mon Oct 07, 2019 4:39 am
- Phoenix Version:
- Has thanked: 35 times
- Been thanked: 243 times
Re: Making a Hook
The sorting of lower case after upper case caught me out so, in my case, changing name from checkoutConfirmation to CheckoutConfirmation makes it show above MATC as expected.ecartz wrote: ↑Tue Feb 23, 2021 1:40 pm Look up the name of the MATC hook and then pick a name for your new hook that sorts before it.
MATC: hook_shop_siteWide_MATC
So the hook name is MATC (who'd have guessed). Sorting after it would be MATD, atc, zz, _MATC, etc. Before it would be MATB, AAA, 0MATC, 9MATC, etc. The rules are numbers, then uppercase letters (in alphabetical order), then _, then lowercase letters.
Thanks so much for helping and for the explanation.
-
heatherbell
- Senior Contributor
- Posts: 2540
- Joined: Mon Oct 07, 2019 4:39 am
- Phoenix Version:
- Has thanked: 35 times
- Been thanked: 243 times
Re: Making a Hook
Looking at this more at https://github.com/gburton/CE-Phoenix/wiki/Hooks
In my case (a hook to show message on checkout_confirmation) I currently have hook_shop_siteWide_CheckoutConfirmation which works (because I have code that checks $PHP_SELF) but if I understand the above correctly, what would be the correct naming and file location - hook_shop_Page_checkout_confirmation in /hooks/shop/Page/ or hook_shop_Page_checkout_confirmation_whatever in /hooks/shop/Page/checkout_confirmation/ which I presume would negate the need for the $PHP_SELF check.Page
For hooks that should only run on a specific page. These hooks are named based on the page name, which is the file name without the .php at the end. For example, we might talk about index, product_info, create_account, or checkout_shipping hooks.
-
ecartz
- Core Team
- Posts: 3084
- Joined: Tue Nov 05, 2019 6:02 pm
- Phoenix Version:
- Has thanked: 4 times
- Been thanked: 208 times
Re: Making a Hook
hook_shop_checkout_confirmation_Message
templates/override/includes/hooks/shop/checkout_confirmation/Message.php
I changed the hook name just because I find checkout_confirmation_CheckoutConfirmation confusing. If it makes sense to you, it's fine as is.
templates/override/includes/hooks/shop/checkout_confirmation/Message.php
I changed the hook name just because I find checkout_confirmation_CheckoutConfirmation confusing. If it makes sense to you, it's fine as is.
-
heatherbell
- Senior Contributor
- Posts: 2540
- Joined: Mon Oct 07, 2019 4:39 am
- Phoenix Version:
- Has thanked: 35 times
- Been thanked: 243 times
-
heatherbell
- Senior Contributor
- Posts: 2540
- Joined: Mon Oct 07, 2019 4:39 am
- Phoenix Version:
- Has thanked: 35 times
- Been thanked: 243 times
Re: Making a Hook
There are 2 checkout_confirmation.php files in core, one in root and one in /templates/default/includes/pages/
I guess the one in /templates/default/includes/pages/ would be known as the "template" file? Otherwise what would the correct term be?
What would be the correct term for the one in root?
I guess the one in /templates/default/includes/pages/ would be known as the "template" file? Otherwise what would the correct term be?
What would be the correct term for the one in root?