Automattic\WooCommerce\Admin\API

MarketingCampaignTypes::get_items()publicWC 1.0

Returns an aggregated array of marketing campaigns for all active marketing channels.

Method of the class: MarketingCampaignTypes{}

No Hooks.

Return

WP_Error|WP_REST_Response.

Usage

$MarketingCampaignTypes = new MarketingCampaignTypes();
$MarketingCampaignTypes->get_items( $request );
$request(WP_REST_Request) (required)
Request data.

MarketingCampaignTypes::get_items() code WC 8.9.0

public function get_items( $request ) {
	/**
	 * MarketingChannels class.
	 *
	 * @var MarketingChannelsService $marketing_channels_service
	 */
	$marketing_channels_service = wc_get_container()->get( MarketingChannelsService::class );

	// Aggregate the supported campaign types from all registered marketing channels.
	$responses = [];
	foreach ( $marketing_channels_service->get_registered_channels() as $channel ) {
		foreach ( $channel->get_supported_campaign_types() as $campaign_type ) {
			$response    = $this->prepare_item_for_response( $campaign_type, $request );
			$responses[] = $this->prepare_response_for_collection( $response );
		}
	}

	return rest_ensure_response( $responses );
}