How could I add the link to my cart page to my cart icon in WooCommerce?
<div class="unit unit-spacing-xs-4 align-items-center">
<div class="unit-body">
<a href="<?php// $cart_url = $woocommerce->cart->get_cart_url(); ?>">
<i class="fas fa-shopping-cart fa-2x"> </i>
</a>
</div>
</div>
All the PHP, I add code that I was using, but it doesn't work
I have my cart.php template but I don't know how to make this template.
Can you give me a cable?
in functions.php I have given support for this
add_filter('woo_cart_but', 'woo_cart_but');
function woo_cart_but() {
ob_start();
$cart_count = WC()->cart->cart_contents_count; // Set variable for cart item count
$cart_url = wc_get_cart_url(); // Set Cart URL
?>
<li><a class="menu-item cart-contents" href="<?php echo $cart_url; ?>" title="My Basket">
<?php
if ( $cart_count > 0 ) {
?>
<span class="cart-contents-count"><?php echo $cart_count; ?></span>
<?php
}
?>
</a>
</li>
<?php
return ob_get_clean();
}
I appreciate all help
It is not very well understood what you want to do, the woo_cart_but filter is not from woocommerce.
If you already have the code where you print your icon, I guess in the site header, you just have to print the cart url in the line: