WC_Emails::order_meta( WC_Order $order, bool $sent_to_admin = false, bool $plain_text = false )
Add order meta to email templates.
Description Description
Parameters Parameters
- $order
-
(Required) Order instance.
- $sent_to_admin
-
(Optional) If should sent to admin.
Default value: false
- $plain_text
-
(Optional) If is plain text email.
Default value: false
Source Source
File: includes/class-wc-emails.php
public function order_meta( $order, $sent_to_admin = false, $plain_text = false ) { $fields = apply_filters( 'woocommerce_email_order_meta_fields', array(), $sent_to_admin, $order ); /** * Deprecated woocommerce_email_order_meta_keys filter. * * @since 2.3.0 */ $_fields = apply_filters( 'woocommerce_email_order_meta_keys', array(), $sent_to_admin ); if ( $_fields ) { foreach ( $_fields as $key => $field ) { if ( is_numeric( $key ) ) { $key = $field; } $fields[ $key ] = array( 'label' => wptexturize( $key ), 'value' => wptexturize( get_post_meta( $order->get_id(), $field, true ) ), ); } } if ( $fields ) { if ( $plain_text ) { foreach ( $fields as $field ) { if ( isset( $field['label'] ) && isset( $field['value'] ) && $field['value'] ) { echo $field['label'] . ': ' . $field['value'] . "\n"; // WPCS: XSS ok. } } } else { foreach ( $fields as $field ) { if ( isset( $field['label'] ) && isset( $field['value'] ) && $field['value'] ) { echo '<p><strong>' . $field['label'] . ':</strong> ' . $field['value'] . '</p>'; // WPCS: XSS ok. } } } } }