I am not sure why but i am trying to unset session after to add Custom data to Woo Commerce cat but its not working. Here is my code what i am trying.
add_filter('woocommerce_add_cart_item_data','wdm_add_item_data',11,2);
if(!function_exists('wdm_add_item_data')){
function wdm_add_item_data($cart_item_data,$product_id){
global $woocommerce;
session_start();
if (isset($_SESSION['custom_user_data'])) {
$option = $_SESSION['custom_user_data'];
$new_value = array('wdm_user_custom_data_value' => $option);
}
if(empty($option)){
return $cart_item_data;
}else{
if(empty($cart_item_data)){
return $new_value;
}else{
return array_merge($cart_item_data,$new_value);
}
}
unset($_SESSION['custom_user_data']);
}
}
But unset session is not working here. Anybody help me?? Thanks