I'm trying to do this in a completely new plugin, but, I can't seem to get any data back in any of my tests, not any of them! I've tried to uninstall/reinstall the plugin, I've tried a simple hook like "add to cart", nothing appears on the page or in the network tab. Can anyone suggest what I am doing wrong here?
Thanks in advance
Here's my addon.xml:
testaddon
1.0
Test Addon
test addon
100500
active
init.php
if (!defined(‘BOOTSTRAP’)) { die(‘Access denied’); }
These are ajax requests so you won’t see anything on screen. But you should see it in the response section of your browser inspector if you didn’t have the die().
I've removed the die, though unfortunately that did not reveal anything in the browser's inspector network tab.
On the add to cart function I have looking in the network table, the add to cart returns a POST request, which contains the markup for the entire webpage, but, my var_dump does not exists!
On the update order I look in the network tab, and, all I get is a POST request which contains JSON data:
The way cs-cart does AJAX requests is that the whole page is re-rendered and resent. JS on the client side looks for the ID of the "result_ids" and requires a closing
Verify your addon is in fact installed and enabled and then I'd so a quick die("Got here") at the end of your func.php to quickly assess that your addon is being invoked.
If the contents you list above are correct then you should see your vardump in the response. But as Ecom states, it is easier if you disable the ajax request for the cart.
Yes, change_order_status is probably the most widely used hook in the system since you can fire off events from this related to almost all order activities.
Facing a related problem: in CsCart 4.2.2, it seems that neither the hook update_option_combination_pre nor update_option_combination_post is ever triggered when updating inventories of product options from the backend. While in the source code of fn.catalog.php, none of these hooks is listed in CsCart hook base https://helpdesk.cs-cart.com/index.phpfor this version, as well there seems to be some issue with duplicate hooks which has been resolved in v 4.3.
To make this work, is there a central source code file registering hooks declared in the code by fn_set_hook('hook_name", $params)? Where can I find it to manually fix the potential bug on my end?
Not aware of any bug regarding duplicate hooks. If you are saying the the fn_set_hook('update_option_combination_pre',....) is not in your source base then this hook was added at a later version and is not supported in your version.
You can (in code) look at (I think but might be different) $registered_hooks = Registry::get('hooks'); This will tell you what hooks have been registered and what function (addon) they are registered to.