Product_Price
extends Abstract_Product_Block_Renderer
in package
Renders a WooCommerce product price 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 price block content for email.
- apply_email_wrapper() : string
- Apply email-compatible table wrapper.
- build_grouped_product_price() : string
- Build price HTML for grouped products.
- build_price_from_scratch() : string
- Build price HTML completely from scratch based on product type.
- build_simple_product_price() : string
- Build price HTML for simple products.
- build_variable_product_price() : string
- Build price HTML for variable products.
- generate_price_html() : string
- Generate clean price HTML from product data.
Methods
render()
Render the block.
public
render(string $block_content, array<string|int, mixed> $parsed_block, Rendering_Context $rendering_context) : string
Parameters
- $block_content : string
-
The block content.
- $parsed_block : array<string|int, mixed>
-
The parsed block.
- $rendering_context : Rendering_Context
-
The rendering context.
Return values
string —add_spacer()
Add a spacer around the block.
protected
add_spacer(string $content, array<string|int, mixed> $email_attrs) : string
Parameters
- $content : string
-
The block content.
- $email_attrs : array<string|int, mixed>
-
The email attributes.
Return values
string —compile_css()
Compile objects containing CSS properties to a string.
protected
compile_css(array<string|int, mixed> ...$styles) : string
Parameters
- $styles : array<string|int, mixed>
-
Style arrays to compile.
Return values
string —get_product_from_context()
Get product from block context.
protected
get_product_from_context(array<string|int, mixed> $parsed_block) : WC_Product|null
Parameters
- $parsed_block : array<string|int, mixed>
-
Parsed block.
Return values
WC_Product|null —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> —render_content()
Render the product price block content for email.
protected
render_content(string $block_content, array<string|int, mixed> $parsed_block, Rendering_Context $rendering_context) : string
Parameters
- $block_content : string
-
Block content.
- $parsed_block : array<string|int, mixed>
-
Parsed block.
- $rendering_context : Rendering_Context
-
Rendering context.
Return values
string —apply_email_wrapper()
Apply email-compatible table wrapper.
private
apply_email_wrapper(string $price_html, array<string|int, mixed> $parsed_block) : string
Parameters
- $price_html : string
-
Price HTML.
- $parsed_block : array<string|int, mixed>
-
Parsed block.
Return values
string —build_grouped_product_price()
Build price HTML for grouped products.
private
build_grouped_product_price(WC_Product_Grouped $product) : string
Parameters
- $product : WC_Product_Grouped
-
Grouped product object.
Return values
string —build_price_from_scratch()
Build price HTML completely from scratch based on product type.
private
build_price_from_scratch(WC_Product $product) : string
Parameters
- $product : WC_Product
-
Product object.
Return values
string —build_simple_product_price()
Build price HTML for simple products.
private
build_simple_product_price(WC_Product $product) : string
Parameters
- $product : WC_Product
-
Product object.
Return values
string —build_variable_product_price()
Build price HTML for variable products.
private
build_variable_product_price(WC_Product_Variable $product) : string
Uses the same logic as the editor: get_variation_price() methods.
Parameters
- $product : WC_Product_Variable
-
Variable product object.
Return values
string —generate_price_html()
Generate clean price HTML from product data.
private
generate_price_html(WC_Product $product, array<string|int, mixed> $attributes, Rendering_Context $rendering_context) : string
Parameters
- $product : WC_Product
-
Product object.
- $attributes : array<string|int, mixed>
-
Block attributes.
- $rendering_context : Rendering_Context
-
Rendering context.
