Automattic\WooCommerce\EmailEditor\Integrations\WooCommerce\Renderer\Blocks

Product_Collection::get_collection_specific_product_idsprivateWC 1.0

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

Method of the class: Product_Collection{}

No Hooks.

Returns

Array. Array of product IDs or empty array.

Usage

// private - for code of main (parent) class only
$result = $this->get_collection_specific_product_ids( $collection, $parsed_block, $rendering_context ): array;
$collection(string) (required)
Collection type.
$parsed_block(array) (required)
Parsed block data.
$rendering_context(Rendering_Context) (required)
Rendering context.

Product_Collection::get_collection_specific_product_ids() code WC 10.4.3

private function get_collection_specific_product_ids( string $collection, array $parsed_block, Rendering_Context $rendering_context ): array {
	switch ( $collection ) {
		case 'woocommerce/product-collection/upsells':
			return $this->get_upsell_product_ids( $parsed_block );

		case 'woocommerce/product-collection/cross-sells':
			return $this->get_cross_sell_product_ids( $parsed_block );

		case 'woocommerce/product-collection/related':
			return $this->get_related_product_ids( $parsed_block );

		case 'woocommerce/product-collection/cart-contents':
			return $this->get_cart_contents_product_ids( $parsed_block, $rendering_context );

		default:
			return array();
	}
}