I have a woocommerce_after_cart_totals hook action being done to output a specific JSON object to the cart page. It works as expected on page load, however when someone changes qty and hits Update Cart button, the JSON variable disappears and a new one is not recreated.
add_action('woocommerce_after_cart_totals','custom_json_var_output',10,2);
function custom_json_var_output(){
//build the variable to $output
//............
echo "<script>jsonCartData=".json_encode($output).";</script>";
}
So on cart page load i see jsonCartData=*********** script tag below cart_totals div, but when Update Cart is clicked, my tag disappears entirely.
I need to know why this is the case, and what additional action I need to trigger to get the new output after the cart_totals div when Update Cart is done. Why would an update cart action not include retriggering the woocommerce_after_cart_totals hook?