Automattic\WooCommerce\Blocks\BlockTypes

CouponCode::wrap_for_emailprivateWC 1.0

Wrap coupon HTML in an email-compatible table structure.

Method of the class: CouponCode{}

No Hooks.

Returns

String.

Usage

// private - for code of main (parent) class only
$result = $this->wrap_for_email( $coupon_html, $parsed_block ): string;
$coupon_html(string) (required)
Coupon HTML content.
$parsed_block(array) (required)
Parsed block data.

CouponCode::wrap_for_email() code WC 10.8.1

private function wrap_for_email( string $coupon_html, array $parsed_block ): string {
	$align = $this->get_alignment( $parsed_block );

	$table_attrs = array(
		'style' => \WP_Style_Engine::compile_css(
			array(
				'border-collapse' => 'collapse',
				'width'           => '100%',
			),
			''
		),
		'width' => '100%',
	);

	$cell_attrs = array(
		'class' => 'email-coupon-code-cell',
		'style' => \WP_Style_Engine::compile_css(
			array(
				'padding'    => '10px 0',
				'text-align' => $align,
			),
			''
		),
		'align' => $align,
	);

	return Table_Wrapper_Helper::render_table_wrapper( $coupon_html, $table_attrs, $cell_attrs );
}