WooCommerce Code Reference

Product_Collection extends Abstract_Product_Block_Renderer
in package

Renders a product collection block for email.

Table of Contents

render()  : string
Render the block.
add_spacer()  : string
Add a spacer around the block.
compile_css()  : string
Compile objects containing CSS properties to a string.
get_product_from_context()  : WC_Product|null
Get product from block context.
get_styles_from_block()  : array<string|int, mixed>
Wrapper for wp_style_engine_get_styles which ensures all values are returned.
render_content()  : string
Render the product collection block content for email.
build_attribute_query()  : array<string|int, mixed>
Build attribute query from woocommerceAttributes block attributes.
build_tax_query()  : array<string|int, mixed>
Build tax query from taxQuery block attributes.
get_collection_specific_product_ids()  : array<string|int, mixed>
Get specific product IDs for collection types that need them (upsell, cross-sell, related).
get_cross_sell_product_ids()  : array<string|int, mixed>
Get cross-sell product IDs.
get_product_references_for_collection()  : array<string|int, mixed>
Get product references for collections (handles different contexts).
get_related_product_ids()  : array<string|int, mixed>
Get related product IDs.
get_upsell_product_ids()  : array<string|int, mixed>
Get upsell product IDs.
is_all_stock_statuses()  : bool
Check if all stock statuses are selected (meaning no filtering needed).
prepare_and_execute_query()  : WP_Query
Prepare and execute a query for the Product Collection block using the original QueryBuilder.
render_no_results_message()  : string
Render a no results message.
render_product_content()  : string
Render default product content when no inner blocks are present.
render_product_grid()  : string
Render product grid using HTML table structure for email compatibility.
render_product_template()  : string
Render the product template block.

Methods

get_styles_from_block()

Wrapper for wp_style_engine_get_styles which ensures all values are returned.

protected get_styles_from_block(array<string|int, mixed> $block_styles[, bool $skip_convert_vars = false ]) : array<string|int, mixed>
Parameters
$block_styles : array<string|int, mixed>

Array of block styles.

$skip_convert_vars : bool = false

If true, --wp_preset--spacing--x type values will be left in the original var:preset:spacing:x format.

Return values
array<string|int, mixed>

get_collection_specific_product_ids()

Get specific product IDs for collection types that need them (upsell, cross-sell, related).

private get_collection_specific_product_ids(string $collection, array<string|int, mixed> $parsed_block) : array<string|int, mixed>
Parameters
$collection : string

Collection type.

$parsed_block : array<string|int, mixed>

Parsed block data.

Return values
array<string|int, mixed>Array of product IDs or empty array.

get_product_references_for_collection()

Get product references for collections (handles different contexts).

private get_product_references_for_collection(array<string|int, mixed> $parsed_block) : array<string|int, mixed>
Parameters
$parsed_block : array<string|int, mixed>

Parsed block data.

Return values
array<string|int, mixed>Array of product IDs or empty array.