What is the best way to capture catalog actions in a hook?

Open to all! Ask other shopowners for help.
Post Reply
frankl
Builder
Posts: 159
Joined: Tue Feb 23, 2021 8:39 pm
Phoenix Version: v1.1.0.4
Has thanked: 17 times
Been thanked: 25 times

What is the best way to capture catalog actions in a hook?

Post by frankl »

For instance

includes/actions/add_product.php
includes/actions/update_product.php
includes/actions/notify.php

etc


Join The Code Co-op to get access to your library in the Code Co-op Forum
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: What is the best way to capture catalog actions in a hook?

Post by ecartz »

https://github.com/CE-PhoenixCart/Phoen ... .sql#L1213

That's the hook that parses the actions and invokes the appropriate handler.

If you want to add a new action, you can just add a file to includes/actions, using the same format as the existing ones.

If you want to modify the behavior of an action, you can create a system hook that runs before that one (they're sorted by name, so something that sorts earlier than _23_parse_actions like _23_my_action_handling). If you want to block the core handling, unset($_GET['action'])
frankl
Builder
Posts: 159
Joined: Tue Feb 23, 2021 8:39 pm
Phoenix Version: v1.1.0.4
Has thanked: 17 times
Been thanked: 25 times

Re: What is the best way to capture catalog actions in a hook?

Post by frankl »

Thank you that's great Matt, and it works.

I gather there is no post action hook? I'm setting $_SESSION['cart_changed'] then on the next page load running another hook that looks for the session variable, does it's thing, then unloads the session variable.
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: What is the best way to capture catalog actions in a hook?

Post by ecartz »

Not anything that runs after the action is processed but before the redirect.


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply