Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.
Closed 4 years ago.
Improve this questionI'd like to add the short product description to the e-mail that is sent to the customer when a new order is confirmed.
I've added the following via a code snippets plug-in:
add_filter( 'woocommerce_order_item_name', 'add_single_excerpt_to_order_item', 10, 3 );
function add_single_excerpt_to_order_item( $item_name, $item, $is_visible ){
$product_id = $item->get_product_id(); // Get the product Id
$excerpt = get_the_excerpt( $product_id ); // Get the short description
return $item_name . '<br><p class="item-description">' . $excerpt ; '</p>';
}
It is working correctly by adding the short description but now I would like to change the font type and size to match the rest of the e-mail.
Can you assist, please?
Closed. This question is off-topic. It is not currently accepting answers.Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.
Closed 4 years ago.
Improve this questionI'd like to add the short product description to the e-mail that is sent to the customer when a new order is confirmed.
I've added the following via a code snippets plug-in:
add_filter( 'woocommerce_order_item_name', 'add_single_excerpt_to_order_item', 10, 3 );
function add_single_excerpt_to_order_item( $item_name, $item, $is_visible ){
$product_id = $item->get_product_id(); // Get the product Id
$excerpt = get_the_excerpt( $product_id ); // Get the short description
return $item_name . '<br><p class="item-description">' . $excerpt ; '</p>';
}
It is working correctly by adding the short description but now I would like to change the font type and size to match the rest of the e-mail.
Can you assist, please?
Share Improve this question edited May 14, 2020 at 21:52 Tony Djukic 2,2774 gold badges19 silver badges34 bronze badges asked May 14, 2020 at 16:02 Renier DavilaRenier Davila 31 bronze badge1 Answer
Reset to default 0I don't know what the font is for the rest of the email but if you can discern that by examining one of the emails sent you'll want to copy the style rule to this element:
return $item_name . '<br><p class="item-description">' . $excerpt ; '</p>';
As this is an email you'll have to rely on fonts available to the user, so check the email and locate what fonts are being assigned and then add them like this:
return $item_name . '<br><p class="item-description" style="font-family:WHATEVERTHEFONTIS,Arial,Helvetica,sans-serif;font-size:XXpx;font-weight:XXpx;">' . $excerpt ; '</p>';
In earnest though, you'd be better off overriding the email templates using standard WooCommerce (I'm assuming this is for WooCommerce.) template overrides in your theme/child theme.
https://docs.woocommerce/document/template-structure/
That will give you full control over the templates and rather than inline styling will allow you to update the actual <style>
at the start of the email.