How to add shopping cart icon in Wordpress?

BartJr

Free Member
Feb 12, 2015
248
10
Hi all,

I've created a website with the Wordpress and also installed e-commerce plugin (woo commerce). However I can't figure out how to add the shopping cart icon to the footer.

Your advice will be much appreciated :)

Thank you,
Bart
 

delxyyy

Free Member
Feb 18, 2014
27
5
40
add this to your footer.php
<?php
global $woocommerce;

// get cart quantity
$qty = $woocommerce->cart->get_cart_contents_count();

// get cart total
$total = $woocommerce->cart->get_cart_total();

// get cart url
$cart_url = $woocommerce->cart->get_cart_url();

// if multiple products in cart
if($qty>1)
echo '<a href="'.$cart_url.'">'.$qty.' products | '.$total.'</a>';

// if single product in cart
if($qty==1)
echo '<a href="'.$cart_url.'">1 product | '.$total.'</a>';

?>
 
  • Like
Reactions: DesignerNick
Upvote 0

BartJr

Free Member
Feb 12, 2015
248
10
Woocommerce integrates with WP so there should be no need to add any icons anywhere, just link to the shopping area in the navigation.
Yes I got that, but there is still no icon :<

add this to your footer.php
<?php
global $woocommerce;

// get cart quantity
$qty = $woocommerce->cart->get_cart_contents_count();

// get cart total
$total = $woocommerce->cart->get_cart_total();

// get cart url
$cart_url = $woocommerce->cart->get_cart_url();

// if multiple products in cart
if($qty>1)
echo '<a href="'.$cart_url.'">'.$qty.' products | '.$total.'</a>';

// if single product in cart
if($qty==1)
echo '<a href="'.$cart_url.'">1 product | '.$total.'</a>';

?>
I've added that but still no joy
 
Upvote 0

BartJr

Free Member
Feb 12, 2015
248
10
Here is the code from footer (incl. what has Delxyy said) could there be a mistake?

<?php
/**
* The template for displaying the footer.
*
* Contains the closing of the #content div and all content after
*
* @package Tesseract
*/
?>

</div><!-- #content -->

<footer id="colophon" class="site-footer" role="contentinfo">

<?php $additional = get_theme_mod('tesseract_tfo_footer_additional_content') ? true : false;

$menuClass = 'only-menu';
if ( $additional ) $menuClass = 'is-additional';

$menuEnable = get_theme_mod('tesseract_tfo_footer_content_enable');
$menuSelect = get_theme_mod('tesseract_tfo_footer_content_select');
$addcontent_hml = get_theme_mod('tesseract_tfo_footer_additional_content');
$addcontent_hml = $addcontent_hml ? $addcontent_hml : 'notset';
?>

<div id="footer-banner" class="cf<?php echo ' menu-' . $menuClass; ?>">

<div id="horizontal-menu-wrap" class="<?php echo $menuClass . ' ' . $addcontent_hml; ?>">

<?php // SHOUDLD some additional content added before the menu?
if ( ( $addcontent_hml !== 'nothing' ) && ( $addcontent_hml !== 'notset' ) ) : ?>

<div id="horizontal-menu-before" class="switch thm-left-left<?php if ( ( $menuEnable && ( $menuEnable == 1 ) ) || !$menuEnable ) echo ' is-menu'; ?>"><?php tesseract_horizontal_footer_menu_additional_content( $addcontent_hml ); ?></div>

<?php endif; //EOF left menu - IS before content ?>

<?php if ( ( $menuEnable && ( $menuEnable == 1 ) ) || !$menuEnable ) : ?>

<section id="footer-horizontal-menu"<?php if ( $addcontent_hml && ( $addcontent_hml !== 'nothing' ) && ( $addcontent_hml !== 'notset' ) ) echo ' class="is-before"'; ?>>
<div>

<?php $anyMenu = get_terms( 'nav_menu' ) ? true : false;

if ( $anyMenu ) :

if ( $menuSelect !== 'none' ) :
wp_nav_menu( array( 'menu' => $menuSelect, 'container_class' => 'footer-menu', 'depth' => 1 ) );
elseif ( ( $menuSelect == 'none' ) || !$menuSelect || !$menuEnable ) :
$menu = get_terms( 'nav_menu' );
$menu_id = $menu[0]->term_id;
wp_nav_menu( array( 'menu_id' => $menu_id ) );
endif; ?>

<?php else :

wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu', 'depth' => 1 ) );

endif; ?>

</div>

</section>

<?php endif; ?>

</div><!-- EOF horizontal-menu-wrap -->

<div id="designer">
<?php printf( __( 'Theme by %s', 'tesseract' ), '<a href="http://tyler.com">Tyler Moore</a>' ); ?>
</div>

</div>

</footer><!-- #colophon -->
</div><!-- #page -->

<?php wp_footer(); ?>

</body>
</html>

<?php
global $woocommerce;

// get cart quantity
$qty = $woocommerce->cart->get_cart_contents_count();

// get cart total
$total = $woocommerce->cart->get_cart_total();

// get cart url
$cart_url = $woocommerce->cart->get_cart_url();

// if multiple products in cart
if($qty>1)
echo '<a href="'.$cart_url.'">'.$qty.' products | '.$total.'</a>';

// if single product in cart
if($qty==1)
echo '<a href="'.$cart_url.'">1 product | '.$total.'</a>';

?>
 
Upvote 0

delxyyy

Free Member
Feb 18, 2014
27
5
40
<?php
/**
* The template for displaying the footer.
*
* Contains the closing of the #content div and all content after
*
* @package Tesseract
*/
?>

</div><!-- #content -->

<footer id="colophon" class="site-footer" role="contentinfo">

<?php $additional = get_theme_mod('tesseract_tfo_footer_additional_content') ? true : false;

$menuClass = 'only-menu';
if ( $additional ) $menuClass = 'is-additional';

$menuEnable = get_theme_mod('tesseract_tfo_footer_content_enable');
$menuSelect = get_theme_mod('tesseract_tfo_footer_content_select');
$addcontent_hml = get_theme_mod('tesseract_tfo_footer_additional_content');
$addcontent_hml = $addcontent_hml ? $addcontent_hml : 'notset';
?>

<div id="footer-banner" class="cf<?php echo ' menu-' . $menuClass; ?>">

<div id="horizontal-menu-wrap" class="<?php echo $menuClass . ' ' . $addcontent_hml; ?>">

<?php // SHOUDLD some additional content added before the menu?
if ( ( $addcontent_hml !== 'nothing' ) && ( $addcontent_hml !== 'notset' ) ) : ?>

<div id="horizontal-menu-before" class="switch thm-left-left<?php if ( ( $menuEnable && ( $menuEnable == 1 ) ) || !$menuEnable ) echo ' is-menu'; ?>"><?php tesseract_horizontal_footer_menu_additional_content( $addcontent_hml ); ?></div>

<?php endif; //EOF left menu - IS before content ?>

<?php if ( ( $menuEnable && ( $menuEnable == 1 ) ) || !$menuEnable ) : ?>

<section id="footer-horizontal-menu"<?php if ( $addcontent_hml && ( $addcontent_hml !== 'nothing' ) && ( $addcontent_hml !== 'notset' ) ) echo ' class="is-before"'; ?>>
<div>

<?php $anyMenu = get_terms( 'nav_menu' ) ? true : false;

if ( $anyMenu ) :

if ( $menuSelect !== 'none' ) :
wp_nav_menu( array( 'menu' => $menuSelect, 'container_class' => 'footer-menu', 'depth' => 1 ) );
elseif ( ( $menuSelect == 'none' ) || !$menuSelect || !$menuEnable ) :
$menu = get_terms( 'nav_menu' );
$menu_id = $menu[0]->term_id;
wp_nav_menu( array( 'menu_id' => $menu_id ) );
endif; ?>

<?php else :

wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu', 'depth' => 1 ) );

endif; ?>

</div>

</section>

<?php endif; ?>

</div><!-- EOF horizontal-menu-wrap -->

<div id="designer">
<?php printf( __( 'Theme by %s', 'tesseract' ), '<a href="">Tyler Moore</a>' ); ?>
</div>

</div>
<?php
global $woocommerce;

// get cart quantity
$qty = $woocommerce->cart->get_cart_contents_count();

// get cart total
$total = $woocommerce->cart->get_cart_total();

// get cart url
$cart_url = $woocommerce->cart->get_cart_url();

// if multiple products in cart
if($qty>1)
echo '<a href="'.$cart_url.'">'.$qty.' products | '.$total.'</a>';

// if single product in cart
if($qty==1)
echo '<a href="'.$cart_url.'">1 product | '.$total.'</a>';

?>


</footer><!-- #colophon -->
</div><!-- #page -->

<?php wp_footer(); ?>

</body>
</html>
 
Upvote 0

BartJr

Free Member
Feb 12, 2015
248
10
Thanks Delxyyy, I've made those changes but it still does not appear on the footer, nor have option to add it in.
Screen%20Shot%202015-07-20%20at%2016.16.34_zpszeuxgilw.png.html
 
Upvote 0

delxyyy

Free Member
Feb 18, 2014
27
5
40
Hah, okay i just installed fresh WP with this theme and woocommerce. For the cart to appear as icon, you need install a plugin called "WooCommerce Menu Cart", then from the settings of the plugin just :
Select the menu(s) in which you want to display the Menu Cart : Main Menu
Select Always display cart, even if it's empty
Display shopping cart icon.
 
Upvote 0

Latest Articles

Join UK Business Forums for free business advice