Wc_Tokens::get_woo_product_ids_from_items( WC_Order $order,  $value_to_match )


Parameters Parameters

$order

(WC_Order) (Required)

$value_to_match

(Required)


Top ↑

Return Return

(string)


Source Source

File: src/integrations/woocommerce/tokens/wc-tokens.php

	public function get_woo_product_ids_from_items( WC_Order $order, $value_to_match ) {
		$items       = $order->get_items();
		$product_ids = array();
		if ( $items ) {
			/** @var WC_Order_Item_Product $item */
			foreach ( $items as $item ) {
				if ( absint( $value_to_match ) === absint( $item->get_product_id() ) || absint( '-1' ) === absint( $value_to_match ) ) {
					$product_ids[] = $item->get_product_id();
				}
			}
		}

		return join( ', ', $product_ids );
	}