We’re in the process of developing an addon which will allow tax rates to be updated dynamically from an outside database/api based on the shipping location of the customer, and in working on this addon we’ve hooked into the fn_calculate_cart_items() function using:
We now have a function called fn_dynamictaxes_calculate_cart_items() which (for testing purposes) is doing the following:
function fn_coditaxes_calculate_cart_items(&$cart, &$cart_products, &$auth)
$cart['taxes']['description'] = 'HAHA';
Here’s the question we’ve run into. After looking at all of the included addons, we’ve not found one so far that seems to modify the input code and return it to the core function. They all seem to just process the code and do their own things with it, then return control to the core function without modifying the information. Here’s the real kicker… You’ll notice in the declaration of the addon’s function we’ve used the &$var setup which should make any modifications to the variable carry back to the original, but they don’t.
We’ve tried using:
We’ve also tried not returning anything and simply letting the function end.
Nothing seems to work to return the modified code to the core function. There must be some way of doing it, but we’ve not been able to find any documentation on how to modify/return data to a hooked core function.
There is plenty of documentation about how to hook the function and access it’s data, but nothing about how to return modified data to it, which is what we need to do to modify the processing of the shopping cart and tax information at checkout time.
Any help would be greatly appreciated.
Edit: It seems our signature wasn’t set up, so we’ve edited it. We are running CS-Cart 2.0.8 on LAMP for any who were curious.