WC_Shortcodes::product_category()public staticWC 1.0

List products in a category shortcode.

Method of the class: WC_Shortcodes{}

No Hooks.

Return

String.

Usage

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

WC_Shortcodes::product_category() code WC 8.6.1

public static function product_category( $atts ) {
	if ( empty( $atts['category'] ) ) {
		return '';
	}

	$atts = array_merge(
		array(
			'limit'        => '12',
			'columns'      => '4',
			'orderby'      => 'menu_order title',
			'order'        => 'ASC',
			'category'     => '',
			'cat_operator' => 'IN',
		),
		(array) $atts
	);

	$shortcode = new WC_Shortcode_Products( $atts, 'product_category' );

	return $shortcode->get_content();
}