Syed Abdullah
Syed Abdullah

Reputation: 36

How to add custom text before the price in the header cart in Storefront theme woocommerce

i want to add the text "Your Cart: " before the pricing in the header cart of storefront theme, i tried editing and adding it in inc/woocommerce/storefront-woocommerce-template-functions.php line 72 in

 <?php
function storefront_cart_link() {
<span class="amount">ADDED HERE<?php echo "AND HERE ALSO" . wp_kses_data( WC()->cart->get_cart_subtotal() ); ?></span> 
}?>

though it appears on the frontend until site loads, when loading completes, the text just vanishes. please suggest how to do it.

running WP v4.6

Upvotes: 1

Views: 1534

Answers (1)

Jatin Rathod
Jatin Rathod

Reputation: 109

it will display Your Cart Text if you add it outside anchor tag like below.

function storefront_cart_link() {
        ?>
            <span style="float:left;">Your Cart :</span> 
            <a class="cart-contents" href="<?php echo esc_url( WC()->cart->get_cart_url() ); ?>" title="<?php esc_attr_e( 'View your shopping cart', 'storefront' ); ?>">
                <span class="amount"><?php echo wp_kses_data( WC()->cart->get_cart_subtotal() ); ?></span> <span class="count"><?php echo wp_kses_data( sprintf( _n( '%d item', '%d items', WC()->cart->get_cart_contents_count(), 'storefront' ), WC()->cart->get_cart_contents_count() ) );?></span>
            </a>
        <?php
    }

Upvotes: 2

Related Questions