WC_Shortcodes::products()public staticWC 1.0

List multiple products shortcode.

Method of the class: WC_Shortcodes{}

No Hooks.

Return

String.

Usage

$result = WC_Shortcodes::products( $atts );
$atts(array) (required)
Attributes.

WC_Shortcodes::products() code WC 8.6.1

public static function products( $atts ) {
	$atts = (array) $atts;
	$type = 'products';

	// Allow list product based on specific cases.
	if ( isset( $atts['on_sale'] ) && wc_string_to_bool( $atts['on_sale'] ) ) {
		$type = 'sale_products';
	} elseif ( isset( $atts['best_selling'] ) && wc_string_to_bool( $atts['best_selling'] ) ) {
		$type = 'best_selling_products';
	} elseif ( isset( $atts['top_rated'] ) && wc_string_to_bool( $atts['top_rated'] ) ) {
		$type = 'top_rated_products';
	}

	$shortcode = new WC_Shortcode_Products( $atts, $type );

	return $shortcode->get_content();
}