0)
{
$return_string = $product_name . "
";
$return_string .= "";
$return_string .= "| custom_data_1 : " . $values['custom_data_1'] . " |
";
$return_string .= "| custom_data_2 : " . $values['custom_data_2'] . " |
";
$return_string .= "| custom_data_3 : " . $values['custom_data_3'] . " |
";
$return_string .= "| custom_data_4 : " . $values['custom_data_4'] . " |
";
$return_string .= "| custom_data_5 : " . $values['custom_data_5'] . " |
";
$return_string .= "
";
return $return_string;
}
else
{
return $product_name;
}
}
}
// step 5
add_action('woocommerce_add_order_item_meta','wdm_add_values_to_order_item_meta',1,2);
if(!function_exists('wdm_add_values_to_order_item_meta'))
{
function wdm_add_values_to_order_item_meta($item_id, $values)
{
global $woocommerce,$wpdb;
$user_custom_values = $values['wdm_user_custom_data_value'];
if(!empty($user_custom_values))
{
wc_add_order_item_meta($item_id,'wdm_user_custom_data',$user_custom_values);
}
$custom_data_1 = $values['custom_data_1'];
if(!empty($custom_data_1))
{
wc_add_order_item_meta($item_id,'custom_data_1',$custom_data_1);
}
$custom_data_2 = $values['custom_data_2'];
if(!empty($custom_data_2))
{
wc_add_order_item_meta($item_id,'custom_data_2',$custom_data_2);
}
$custom_data_3 = $values['custom_data_3'];
if(!empty($custom_data_3))
{
wc_add_order_item_meta($item_id,'custom_data_3',$custom_data_3);
}
$custom_data_4 = $values['custom_data_4'];
if(!empty($custom_data_4))
{
wc_add_order_item_meta($item_id,'custom_data_4',$custom_data_4);
}
$custom_data_5 = $values['custom_data_5'];
if(!empty($custom_data_5))
{
wc_add_order_item_meta($item_id,'custom_data_5',$custom_data_5);
}
}
}
// step 6
add_action('woocommerce_before_cart_item_quantity_zero','wdm_remove_user_custom_data_options_from_cart',1,1);
if(!function_exists('wdm_remove_user_custom_data_options_from_cart'))
{
function wdm_remove_user_custom_data_options_from_cart($cart_item_key)
{
global $woocommerce;
// Get cart
$cart = $woocommerce->cart->get_cart();
// For each item in cart, if item is upsell of deleted product, delete it
foreach( $cart as $key => $values)
{
if ( $values['wdm_user_custom_data_value'] == $cart_item_key )
unset( $woocommerce->cart->cart_contents[ $key ] );
}
}
}
?>
// I m using following script in my template which is working perfect