问题
I would like to edit the text in the header mini cart in Storefront theme: 'X items' to just : 'X' http://demo.woothemes.com/storefront/
Where can I access this? Can't find it anywhere in storefront or woocommerce files. I can see hook in header.php: storefront_header_cart but can't find any function for this in other files?
I would like to remove the dropdown when you hover over it too. Where can I change this?
回答1:
that functionality is handled by storefront_cart_link
function...
you can override the function... open functions.php... look for require get_template_directory() . '/inc/init.php';
right above it, paste this code...
if ( ! function_exists( 'storefront_cart_link' ) ) {
function storefront_cart_link() {
?>
<a class="cart-contents" href="<?php echo esc_url( WC()->cart->get_cart_url() ); ?>" title="<?php _e( 'View your shopping cart', 'storefront' ); ?>">
<?php echo wp_kses_data( WC()->cart->get_cart_subtotal() ); ?> <span class="count"><?php echo wp_kses_data( sprintf( '%d', WC()->cart->get_cart_contents_count() ) );?></span>
</a>
<?php
}
}
storefront_cart_link
is loaded with this call require get_template_directory() . '/inc/init.php';
. So above will load first, making it not create that function anymore with the call of require get_template_directory() . '/inc/init.php';
.
This will do the trick.. but better use child theme... you can just paste directly the function above on the child theme's functions.php. functions.php on a child theme will load first than that of the parent, so making your function exist first.
来源:https://stackoverflow.com/questions/35443379/changing-header-cart-text-in-storefront