WooCommerce Code Reference

Rendering_Context
in package

Class Rendering_Context

Table of Contents

$email_context  : array<string|int, mixed>
Email-specific context data.
$theme_json  : WP_Theme_JSON
Instance of the WP Theme.
__construct()  : mixed
Rendering_Context constructor.
get()  : mixed
Get a specific value from the email context.
get_email_context()  : array<string, mixed>
Get the email-specific context data.
get_layout_width_without_padding()  : string
Returns the width of the layout without padding.
get_recipient_email()  : string|null
Get the recipient email address from the email context.
get_theme_json()  : WP_Theme_JSON
Returns WP_Theme_JSON instance that should be used during the email rendering.
get_theme_settings()  : array<string|int, mixed>
Get settings from the theme.
get_theme_styles()  : array{spacing: array{blockGap: string, padding: array{bottom: string, left: string, right: string, top: string}}, color: array{background: string, text: string}, typography: array{fontFamily: string}}
Get the email theme styles.
get_user_id()  : int|null
Get the user ID from the email context.
translate_slug_to_color()  : string
Translate color slug to color.

Properties

$email_context

Email-specific context data.

private array<string|int, mixed> $email_context

This array contains email-specific information that can be used during rendering, such as:

  • 'user_id': The ID of the user receiving the email
  • 'recipient_email': The recipient's email address
  • Additional context can be added by extensions using the generic get() method

Methods

get()

Get a specific value from the email context.

public get(string $key[, mixed $default_value = null ]) : mixed

This method allows extensions to access custom context data that may be specific to their implementation (e.g., order IDs, email types, etc.).

Parameters
$key : string

The context key.

$default_value : mixed = null

Default value if key is not found.

Return values
mixedThe context value or default.

get_theme_styles()

Get the email theme styles.

public get_theme_styles() : array{spacing: array{blockGap: string, padding: array{bottom: string, left: string, right: string, top: string}}, color: array{background: string, text: string}, typography: array{fontFamily: string}}
Return values
array{spacing: array{blockGap: string, padding: array{bottom: string, left: string, right: string, top: string}}, color: array{background: string, text: string}, typography: array{fontFamily: string}}