Missing Data After Recalculate Amount In Cart

Hi there,

I am almost done with my project. Well, so I thought. A nasty, tiny bug is holding me back. And I can't find it. :-(

I made an addon for my client, which has to do with delivery time and surtax. All goes well. All data is calculated fine until the end. But when I am in the cart and want to change the amount, my data is lost. Why?

What function is being called at that time?

And what happens with my data?

Did I store it in a wrong way?

http://testserver-nulvijf.nl/cart/

I believe something is going wrong here, because entering the cart it gives the data were I want it. But after changing amount it is gone.

function fn_shipping_options_lvo_pre_add_to_cart(&$product_data, $cart, $auth, $update)
{
foreach ($product_data as $key => $data) {

if( isset($data['shipping_options']['modifier_type']) ) {
$product_data[$key]['extra']['ship_lvo']['ship_opt_modifier'] = $data['shipping_options']['modifier'];
$product_data[$key]['extra']['ship_lvo']['ship_opt_modifier_type'] = $data['shipping_options']['modifier_type'];
$product_data[$key]['extra']['ship_lvo']['ship_opt_days'] = $data['shipping_options']['days'];
}
}
}

Please help.

Best regards, Lianne

UPDATE:

Ended up changing the function a bit. It works, but don't know if it is the right way. (Feels like a bit of a hack)

function fn_shipping_options_lvo_pre_add_to_cart(&$product_data, &$cart, $auth, $update)
{
foreach ($product_data as $key => $data) {

if( isset($data['shipping_options']['modifier_type']) ) {
$product_data[$key]['extra']['ship_lvo']['ship_opt_modifier'] = $data['shipping_options']['modifier'];
$product_data[$key]['extra']['ship_lvo']['ship_opt_modifier_type'] = $data['shipping_options']['modifier_type'];
$product_data[$key]['extra']['ship_lvo']['ship_opt_days'] = $data['shipping_options']['days'];

$cart['products'][$key]['extra']['ship_lvo']['ship_opt_modifier'] = $data['shipping_options']['modifier'];
$cart['products'][$key]['extra']['ship_lvo']['ship_opt_modifier_type'] = $data['shipping_options']['modifier_type'];
$cart['products'][$key]['extra']['ship_lvo']['ship_opt_days'] = $data['shipping_options']['days'];
}
}

foreach ($product_data as $k => $v) {
if (isset($cart['products'][$k]['extra']['ship_lvo'])) {
$product_data[$k]['extra']['ship_lvo'] = $cart['products'][$k]['extra']['ship_lvo'];
}
}
}

x-cart1.JPG

x-cart2.JPG