woocommerce_email_editor_rendering_email_context
Filter the email-specific context data passed to block renderers.
This allows email sending systems to provide context data such as user ID, email address, order information, etc., that can be used by blocks during rendering.
Blocks that need cart product information can derive it from the user_id or recipient_email using CartCheckoutUtils::get_cart_product_ids_for_user().
Использование
add_filter( 'woocommerce_email_editor_rendering_email_context', 'wp_kama_woocommerce_email_editor_rendering_context_filter' );
/**
* Function for `woocommerce_email_editor_rendering_email_context` filter-hook.
*
* @param array $email_context Email-specific context data.
*
* @return array
*/
function wp_kama_woocommerce_email_editor_rendering_context_filter( $email_context ){
// filter...
return $email_context;
}
- $email_context(массив)
Email-specific context data.
-
user_id(int)
The ID of the user receiving the email. -
recipient_email(строка)
The recipient's email address. -
order_id(int)
The order ID (for order-related emails). - email_type(строка)
The type of email being rendered.
-
Список изменений
| С версии 1.9.0 | Введена. |
Где вызывается хук
woocommerce_email_editor_rendering_email_context
woocommerce/packages/email-editor/src/Engine/Renderer/ContentRenderer/class-content-renderer.php 370
$email_context = apply_filters( 'woocommerce_email_editor_rendering_email_context', array() );
Где используется хук в WooCommerce
woocommerce/packages/email-editor/src/Engine/class-send-preview-email.php 100
remove_filter( 'woocommerce_email_editor_rendering_email_context', array( $this, 'add_preview_context' ) );
woocommerce/packages/email-editor/src/Engine/class-send-preview-email.php 90
add_filter( 'woocommerce_email_editor_rendering_email_context', array( $this, 'add_preview_context' ) );
woocommerce/src/Internal/EmailEditor/BlockEmailRenderer.php 106
remove_filter( 'woocommerce_email_editor_rendering_email_context', $filter_callback );
woocommerce/src/Internal/EmailEditor/BlockEmailRenderer.php 114
remove_filter( 'woocommerce_email_editor_rendering_email_context', $filter_callback );
woocommerce/src/Internal/EmailEditor/BlockEmailRenderer.php 97
add_filter( 'woocommerce_email_editor_rendering_email_context', $filter_callback, 10, 1 );