当购物车为空时,隐藏具有“ checkout”类的按钮-Woocommerce

时间:2020-07-26 12:24:58

标签: wordpress woocommerce

当购物车为空时,具有隐藏类“ checkout”的按钮有问题,我无法使用。

这是我目前正在尝试的代码:

if (!function_exists('et_show_cart_total')) {

    function et_show_cart_total($args = array()) {

        if (!class_exists('woocommerce')) {
            return;
        }

        $defaults = array(
            'no_text' => false,
        );

        $args = wp_parse_args($args, $defaults);

        $items_number = WC() - > cart - > get_cart_contents_count();

        if ($items_number):
            printf(
                '<a href="%1$s" class="et-cart-info"> <
                span > % 2 $s < /span> <
                /a>',
                esc_url(WC() - > cart - > get_cart_url()),
                (!$args['no_text'] ?
                    esc_html(sprintf(
                        _nx('1 Item', '%1$s Items', $items_number, 'WooCommerce items number', 'Divi'),
                        number_format_i18n($items_number)
                    )) :
                    ''
                )
            );
        endif;
    }
}

任何帮助将不胜感激。而且我正在使用Divi WordPress!

0 个答案:

没有答案