WC_Emails::fulfillment_meta
Add fulfillment meta to email templates.
Method of the class: WC_Emails{}
Hooks from the method
Returns
null. Nothing (null).
Usage
$WC_Emails = new WC_Emails(); $WC_Emails->fulfillment_meta( $order, $fulfillment, $sent_to_admin, $plain_text );
- $order(WC_Order) (required)
- Order instance.
- $fulfillment(Fulfillment) (required)
- Fulfillment instance.
- $sent_to_admin(true|false)
- If should sent to admin.
Default:false - $plain_text(true|false)
- If is plain text email.
Default:false
WC_Emails::fulfillment_meta() WC Emails::fulfillment meta code WC 10.4.3
public function fulfillment_meta( $order, $fulfillment, $sent_to_admin = false, $plain_text = false ) {
$fields = $fulfillment->get_meta_data();
$public_fields = array_filter(
$fields,
function ( $field ) {
return ! str_starts_with( $field->key, '_' );
}
);
if ( 0 < count( $public_fields ) ) {
foreach ( $public_fields as $field ) {
if ( isset( $field->key ) && isset( $field->value ) && $field->value ) {
/**
* Allows developers to translate the fulfillment meta key for display in emails.
*
* @since 10.1.0
*/
$meta_key_translation = apply_filters( 'woocommerce_fulfillment_translate_meta_key', $field->key );
if ( $plain_text ) {
echo esc_attr( $meta_key_translation ) . ': ' . esc_attr( $field->value ) . PHP_EOL;
} else {
echo '<p><strong>' . esc_attr( $meta_key_translation ) . ':</strong> ' . esc_attr( $field->value ) . '</p>';
}
}
}
}
}