应用woocommerce orderby功能将“类别产品”标题更改为“商店”标题

时间:2019-12-04 18:49:51

标签: php wordpress woocommerce

我已经创建了一个在线商店。我现在对woocommerce orderby函数有问题。排序工作正常,因为一旦应用了排序功能,页面标题就会从“类别产品-文具系列”更改为“商店-BBazaar产品”。

说明问题的GIF: http://shop.bbazaar.org.hk/wp-content/uploads/2019/12/woocommerce-orderby-issue.gif

我想在应用不同的排序方法时保持页面标题(产品猫文具系列)不变,但是我不知道哪个php文件(包括/wc-template-functions.php或模板/loop/orderby.php)对此问题负责。

我的网站:http://shop.bbazaar.org.hk

与php编码相关

if ( ! function_exists( 'woocommerce_catalog_ordering' ) ) {

    /**
     * Output the product sorting options.
     */
    function woocommerce_catalog_ordering() {
        if ( ! wc_get_loop_prop( 'is_paginated' ) || ! woocommerce_products_will_display() ) {
            return;
        }
        $show_default_orderby    = 'menu_order' === apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby', 'menu_order' ) );
        $catalog_orderby_options = apply_filters(
            'woocommerce_catalog_orderby',
            array(
                'menu_order' => __( 'Default sorting', 'woocommerce' ),
                'popularity' => __( 'Sort by popularity', 'woocommerce'),
                'rating'     => __( 'Sort by average rating', 'woocommerce' ),
                'date'       => __( 'Sort by latest', 'woocommerce' ),
                'price'      => __( 'Sort by price: low to high', 'woocommerce' ),
                'price-desc' => __( 'Sort by price: high to low', 'woocommerce' ),
            )
        );

        $default_orderby = wc_get_loop_prop( 'is_search' ) ? 'relevance' : apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby', '' ) );
        $orderby         = isset( $_GET['orderby'] ) ? wc_clean( wp_unslash( $_GET['orderby'] ) ) : $default_orderby; // WPCS: sanitization ok, input var ok, CSRF ok.

        if ( wc_get_loop_prop( 'is_search' ) ) {
            $catalog_orderby_options = array_merge( array( 'relevance' => __( 'Relevance', 'woocommerce' ) ), $catalog_orderby_options );

            unset( $catalog_orderby_options['menu_order'] );
        }

        if ( ! $show_default_orderby ) {
            unset( $catalog_orderby_options['menu_order'] );
        }

        if ( ! wc_review_ratings_enabled() ) {
            unset( $catalog_orderby_options['rating'] );
        }

        if ( ! array_key_exists( $orderby, $catalog_orderby_options ) ) {
            $orderby = current( array_keys( $catalog_orderby_options ) );
        }

        wc_get_template(
            'loop/orderby.php',
            array(
                'catalog_orderby_options' => $catalog_orderby_options,
                'orderby'                 => $orderby,
                'show_default_orderby'    => $show_default_orderby,
            )
        );
    }
}

0 个答案:

没有答案