Home › Forums › General Issues › WooCommerce ACF field in email template › Reply To: WooCommerce ACF field in email template
To display your custom field in the email template next to the quantity, you can modify the code to hook into the appropriate filter for the email template. Here’s an adjusted version of your code:
`function email_custom_field($item_quantity, $cart_item, $cart_item_key, $order){
$price = get_field(‘price_for’, $cart_item[‘product_id’]);
return ($price) ?
$item_quantity . ‘ / ‘ . $price
:
$item_quantity;
}
add_filter(‘woocommerce_order_item_quantity_html’, ’email_custom_field’, 999, 4);
This code will display your custom field next to the quantity in DGCustomerFirst the email template. Ensure to place this code in your theme’s functions.php file or in a custom plugin.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.