woocommerce_cross_sell_display()
Output the cart cross-sells.
Хуки из функции
Возвращает
null
. Ничего (null).
Использование
woocommerce_cross_sell_display( $limit, $columns, $orderby, $order );
- $limit(int)
- -
По умолчанию: 2) - $columns(int)
- -
По умолчанию: 2) - $orderby(строка)
- .
По умолчанию: 'rand' - $order(строка)
- .
По умолчанию: 'desc'
Код woocommerce_cross_sell_display() woocommerce cross sell display WC 9.4.2
function woocommerce_cross_sell_display( $limit = 2, $columns = 2, $orderby = 'rand', $order = 'desc' ) { if ( is_checkout() ) { return; } // Get visible cross sells then sort them at random. $cross_sells = array_filter( array_map( 'wc_get_product', WC()->cart->get_cross_sells() ), 'wc_products_array_filter_visible' ); wc_set_loop_prop( 'name', 'cross-sells' ); wc_set_loop_prop( 'columns', apply_filters( 'woocommerce_cross_sells_columns', $columns ) ); // Handle orderby and limit results. $orderby = apply_filters( 'woocommerce_cross_sells_orderby', $orderby ); $order = apply_filters( 'woocommerce_cross_sells_order', $order ); $cross_sells = wc_products_array_orderby( $cross_sells, $orderby, $order ); /** * Filter the number of cross sell products should on the product page. * * @param int $limit number of cross sell products. * @since 3.0.0 */ $limit = intval( apply_filters( 'woocommerce_cross_sells_total', $limit ) ); $cross_sells = $limit > 0 ? array_slice( $cross_sells, 0, $limit ) : $cross_sells; wc_get_template( 'cart/cross-sells.php', array( 'cross_sells' => $cross_sells, // Not used now, but used in previous version of up-sells.php. 'posts_per_page' => $limit, 'orderby' => $orderby, 'columns' => $columns, ) ); }