Home > other >  How to change text color of Short Description PHP Code that I applied on Woocommerce Checkout?
How to change text color of Short Description PHP Code that I applied on Woocommerce Checkout?

Time:02-10

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;
}

Image

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;
}
  •  Tags:  
  • Related