最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

woocommerce offtopic - How to add (and change the font of) the short product description to order page and customer's ne

programmeradmin0浏览0评论
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 question

I'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 question

I'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 badge
Add a comment  | 

1 Answer 1

Reset to default 0

I 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.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论