woocommerce_upsell_display()WC 1.0

Output product up sells.

Возвращает

null. Ничего (null).

Использование

woocommerce_upsell_display( $limit, $columns, $orderby, $order );
$limit(int)
-
По умолчанию: -1)
$columns(int)
-
По умолчанию: 4)
$orderby(строка)
Supported values - rand, title, ID, date, modified, menu_order, price.
По умолчанию: 'rand'
$order(строка)
Sort direction.
По умолчанию: 'desc'

Код woocommerce_upsell_display() WC 8.7.0

function woocommerce_upsell_display( $limit = '-1', $columns = 4, $orderby = 'rand', $order = 'desc' ) {
	global $product;

	if ( ! $product ) {
		return;
	}

	// Handle the legacy filter which controlled posts per page etc.
	$args = apply_filters(
		'woocommerce_upsell_display_args',
		array(
			'posts_per_page' => $limit,
			'orderby'        => $orderby,
			'order'          => $order,
			'columns'        => $columns,
		)
	);
	wc_set_loop_prop( 'name', 'up-sells' );
	wc_set_loop_prop( 'columns', apply_filters( 'woocommerce_upsells_columns', isset( $args['columns'] ) ? $args['columns'] : $columns ) );

	$orderby = apply_filters( 'woocommerce_upsells_orderby', isset( $args['orderby'] ) ? $args['orderby'] : $orderby );
	$order   = apply_filters( 'woocommerce_upsells_order', isset( $args['order'] ) ? $args['order'] : $order );
	/**
	 * Filter the number of upsell products should on the product page.
	 *
	 * @param int $limit number of upsell products.
	 * @since 3.0.0
	 */
	$limit = intval( apply_filters( 'woocommerce_upsells_total', $args['posts_per_page'] ?? $limit ) );

	// Get visible upsells then sort them at random, then limit result set.
	$upsells = wc_products_array_orderby( array_filter( array_map( 'wc_get_product', $product->get_upsell_ids() ), 'wc_products_array_filter_visible' ), $orderby, $order );
	$upsells = $limit > 0 ? array_slice( $upsells, 0, $limit ) : $upsells;

	wc_get_template(
		'single-product/up-sells.php',
		array(
			'upsells'        => $upsells,

			// Not used now, but used in previous version of up-sells.php.
			'posts_per_page' => $limit,
			'orderby'        => $orderby,
			'columns'        => $columns,
		)
	);
}