Как добавить дополнительные самые продаваемые продукты в тему Storefront Woocommerce? - PullRequest
0 голосов
/ 03 мая 2018

Я новичок в woocommerce. Как я могу расширить самый продаваемый раздел Standart Storefront с 4x1 до 4x4, 16 продуктов на главной странице? Когда я попытался вручную изменить функцию storefront_best_selling_products, ничего не получилось.

Ответы [ 2 ]

0 голосов
/ 09 апреля 2019
// "Best Sellers" Home products section
add_filter( 'storefront_best_selling_products_args', 'filter_storefront_best_selling_products_args', 10, 1 ); 
function filter_storefront_best_selling_products_args( $args ) {
    $args['orderby'] = 'rand'; // Random
    $args['limit'] = 16; // Quantity in total
    $args['columns'] = 4;

    return $args;
}

Вставьте приведенный выше код в нижнюю часть файла functions.php дочерней темы и измените количество столбцов limit и соответственно.

Источник: Настройка отображаемых продуктов на домашней странице Woocommerce Storefront

0 голосов
/ 03 мая 2018

Добавьте следующий код в ваши functions.php:

function storefront_best_selling_products( $args ) {

if ( storefront_is_woocommerce_activated() ) {
$args = apply_filters( ‘storefront_best_selling_products_args’, array(
‘limit’   => 5,
‘columns’ => 5,
‘title’      => esc_attr__( ‘Best Sellers’, ‘storefront’ ),
) );
echo ‘<section class=”storefront-product-section storefront-best-selling-products” aria-label=”Best Selling Products”>’;
do_action( ‘storefront_homepage_before_best_selling_products’ );
do_action( ‘storefront_homepage_after_best_selling_products_title’ );
echo storefront_do_shortcode( ‘best_selling_products’, array(
‘per_page’ => intval( $args[‘limit’] ),
‘columns’  => intval( $args[‘columns’] ),
) );
do_action( ‘storefront_homepage_after_best_selling_products’ );
echo ‘</section>’;
}
}

Сокращенный

add_shortcode( ‘best_sellers’, ‘storefront_best_selling_products’ );

используйте шорткод "best_sellers", как этот

do_shortcode('[best_sellers]');

Надеюсь, это работает для вас.

...