WooCommerce Code Reference

WC_Structured_Data
in package

Structured data class.

Table of Contents

$_data  : array<string|int, mixed>
Stores the structured data.
__construct()  : mixed
Constructor.
generate_breadcrumblist_data()  : mixed
Generates BreadcrumbList structured data.
generate_order_data()  : mixed
Generates Order structured data.
generate_product_data()  : mixed
Generates Product structured data.
generate_review_data()  : mixed
Generates Review structured data.
generate_website_data()  : mixed
Generates WebSite structured data.
get_data()  : array<string|int, mixed>
Gets data.
get_structured_data()  : array<string|int, mixed>
Structures and returns data.
output_email_structured_data()  : mixed
Makes sure email structured data only outputs on non-plain text versions.
output_structured_data()  : mixed
Sanitizes, encodes and outputs structured data.
set_data()  : bool
Sets data.
get_data_type_for_page()  : array<string|int, mixed>
Get data types for pages.

Properties

Methods

generate_breadcrumblist_data()

Generates BreadcrumbList structured data.

public generate_breadcrumblist_data(WC_Breadcrumb $breadcrumbs) : mixed

Hooked into woocommerce_breadcrumb action hook.

Parameters
$breadcrumbs : WC_Breadcrumb

Breadcrumb data.

Return values
mixed

generate_order_data()

Generates Order structured data.

public generate_order_data(WP_Order $order[, bool $sent_to_admin = false ][, bool $plain_text = false ]) : mixed

Hooked into woocommerce_email_order_details action hook.

Parameters
$order : WP_Order

Order data.

$sent_to_admin : bool = false

Send to admin (default: false).

$plain_text : bool = false

Plain text email (default: false).

Return values
mixed

generate_product_data()

Generates Product structured data.

public generate_product_data([WC_Product $product = null ]) : mixed

Hooked into woocommerce_single_product_summary action hook.

Parameters
$product : WC_Product = null

Product data (default: null).

Return values
mixed

generate_review_data()

Generates Review structured data.

public generate_review_data(WP_Comment $comment) : mixed

Hooked into woocommerce_review_meta action hook.

Parameters
$comment : WP_Comment

Comment data.

Return values
mixed

generate_website_data()

Generates WebSite structured data.

public generate_website_data() : mixed

Hooked into woocommerce_before_main_content action hook.

Return values
mixed

get_structured_data()

Structures and returns data.

public get_structured_data(array<string|int, mixed> $types) : array<string|int, mixed>

List of types available by default for specific request:

'product', 'review', 'breadcrumblist', 'website', 'order',

Parameters
$types : array<string|int, mixed>

Structured data types.

Return values
array<string|int, mixed>

output_email_structured_data()

Makes sure email structured data only outputs on non-plain text versions.

public output_email_structured_data(WP_Order $order[, bool $sent_to_admin = false ][, bool $plain_text = false ]) : mixed
Parameters
$order : WP_Order

Order data.

$sent_to_admin : bool = false

Send to admin (default: false).

$plain_text : bool = false

Plain text email (default: false).

Return values
mixed

output_structured_data()

Sanitizes, encodes and outputs structured data.

public output_structured_data() : mixed

Hooked into wp_footer action hook. Hooked into woocommerce_email_order_details action hook.

Return values
mixed

set_data()

Sets data.

public set_data(array<string|int, mixed> $data[, bool $reset = false ]) : bool
Parameters
$data : array<string|int, mixed>

Structured data.

$reset : bool = false

Unset data (default: false).

Return values
bool

get_data_type_for_page()

Get data types for pages.

protected get_data_type_for_page() : array<string|int, mixed>
Return values
array<string|int, mixed>