Woocommerce中的自定义排序产品选项

时间:2019-09-25 16:17:21

标签: sorting woocommerce

我有此代码段,将Woocommerce中的默认产品排序选项更改为列表视图,并且需要向单击的当前列表项中添加一些标记(带有JS的html类?)。

<div class="wrapper-ordering">
    <ul class="nav m-4">

    <?php
    global $wp;

    $catalog_orderby = apply_filters( 'woocommerce_catalog_orderby', array(
        'menu_order' => __( 'Akcie na dnes' ),

        'popularity' => __( 'Najpredávanejšie' ),

        'rating'     => __( 'Doporučujeme' ),

        'date'       => __( 'Novinky' )//,

    //  'price'      => __( 'Sort by price: low to high', 'woocommerce' ),

    //  'price-desc' => __( 'Sort by price: high to low', 'woocommerce' )
    ) );

    if ( get_option( 'woocommerce_enable_review_rating' ) == 'no' )
        unset( $catalog_orderby['rating'] );

    foreach ( $catalog_orderby as $id => $name )
        echo '<li class="nav-item nav-link order-item"><a href="' . home_url( $wp->request ) . '?orderby=' . $id . '" class="text-decoration-none text-secondary text-uppercase" style="border-bottom: 1px solid #6c757d; font-weight: bold;">' . esc_attr( $name ) . '</a></li>';
    ?>

    </ul>
</div>

0 个答案:

没有答案