Used template: Hello Elementor
I applied PHP code in Functions.php and it works great. However I want to be able to customize color of Short Description that appeared thanks to the PHP code I found on StackOverFlow.
// add this filter in functions.php file
add_filter( 'woocommerce_get_item_data', 'wc_checkout_description_so_15127954', 10, 2 );
function wc_checkout_description_so_15127954( $other_data, $cart_item )
{
$post_data = get_post( $cart_item['product_id'] );
$other_data[] = array(
'key' => 'Details',
'display' => $post_data->post_excerpt );
return $other_data;
}
Details: [ETH] Random
Is example of the text I want color to be changed
CodePudding user response:
Please try this:
// add this filter in functions.php file
add_filter( 'woocommerce_get_item_data', 'wc_checkout_description_so_15127954', 10, 2 );
function wc_checkout_description_so_15127954( $other_data, $cart_item )
{
$post_data = get_post( $cart_item['product_id'] );
$description = '<span style="color:red">'.$post_data->post_excerpt.'</span>';
$other_data[] = array(
'key' => 'Details',
'display' => $description );
return $other_data;
}