W motywie potomnym w pliku functions.php możesz sobie wrzucić:
function et_show_cart_total( $args = array() ) {
if ( ! class_exists( 'woocommerce' ) || ! WC()->cart ) {
return;
}
$defaults = array(
'no_text' => true,
);
$args = wp_parse_args( $args, $defaults );
$items_number = WC()->cart->get_cart_contents_count();
$url = function_exists( 'wc_get_cart_url' ) ? wc_get_cart_url() : WC()->cart->get_cart_url();
printf(
'<a href="%1$s" class="et-cart-info">
<span>%2$s</span>
</a>',
esc_url( $url ),
( ! $args['no_text']
? esc_html( sprintf(
_nx( '%1$s Item', '%1$s Items', $items_number, 'WooCommerce items number', 'Divi' ),
number_format_i18n( $items_number )
) )
: ''
)
);
}
Dzięki serdeczne, wszystko fajnie.
Tylko jest jeden problem, chciałem zostawić cyfrę z ilością a wykasować sam tekst „element” z teraz nie pokazuje też cyfry. Będę wdzięczny za odpowiedź 🙂
no to możesz tak
function et_show_cart_total( $args = array() ) {
if ( ! class_exists( 'woocommerce' ) || ! WC()->cart ) {
return;
}
$defaults = array(
'no_text' => true,
);
$args = wp_parse_args( $args, $defaults );
$items_number = WC()->cart->get_cart_contents_count();
$url = function_exists( 'wc_get_cart_url' ) ? wc_get_cart_url() : WC()->cart->get_cart_url();
printf(
'<a href="%1$s" class="et-cart-info">
<span>%2$s</span>
</a>',
esc_url( $url ),
( ! $args['no_text']
? esc_html( sprintf(
_nx( '%1$s Item', '%1$s Items', $items_number, 'WooCommerce items number', 'Divi' ),
number_format_i18n( $items_number )
) )
: esc_html( sprintf( $items_number, number_format_i18n( $items_number )))
)
);
}
Wielkie dzięki za pomoc!
Wszystko śmiga fajnie 🙂