'How to change text color of Short Description PHP Code that I applied on Woocommerce Checkout?
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
Solution 1:[1]
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;
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Roby Raju Oommen |
