Need to show Shopping Cart Total in Navbar

Open to all! Ask other shopowners for help.
Post Reply
Tanya
Member
Posts: 19
Joined: Tue Mar 09, 2021 3:16 pm
Phoenix Version:
Has thanked: 9 times

Need to show Shopping Cart Total in Navbar

Post by Tanya »

I would like to change the default display of shopping cart in Navbar from show the cart-count to show the cart-value with currency.

How can I do this?
You do not have the required permissions to view the files attached to this post.


Join The Code Co-op to get access to your library in the Code Co-op Forum
User avatar
burt
Core Team
Posts: 4551
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 252 times
Been thanked: 412 times

Re: Need to show Shopping Cart Total in Navbar

Post by burt »

Drop a copy of

/includes/modules/navbar/templates/tpl_nb_shopping_cart.php

into (assuming you are using "override" template);

/templates/override/includes/modules/navbar/tpl_nb_shopping_cart.php

You have now over-ridden the output of the module.

In that new file, change this line:

Code: Select all

<?php printf(MODULE_NAVBAR_SHOPPING_CART_CONTENTS, $_SESSION['cart']->count_contents()); ?>
To

Code: Select all

<?php printf(MODULE_NAVBAR_SHOPPING_CART_CONTENTS, $GLOBALS['currencies']->format($_SESSION['cart']->show_total())); ?>
In the language file;

/includes/languages/english/modules/navbar/templates/nb_shopping_cart.php

change this line appropriately;

Code: Select all

const MODULE_NAVBAR_SHOPPING_CART_CONTENTS = '<i title="Shopping Cart" class="fas fa-shopping-cart fa-fw"></i><span class="d-inline d-sm-none d-md-inline"> <span class="cart-count">%1$s</span> item(s)</span> <span class="caret"></span>';
Eg to:

Code: Select all

const MODULE_NAVBAR_SHOPPING_CART_CONTENTS = '<i title="Shopping Cart" class="fas fa-shopping-cart fa-fw"></i><span class="d-inline d-sm-none d-md-inline"> <span class="cart-count">%1$s</span> </span> <span class="caret"></span>';
--

This type of indepth help is not usually available from the Core Coders, only within the Supporters VIP lounge. Please consider becoming a Supporter of this Project, to keep the project moving forwards we need as many users of Phoenix as possible to step up and support. Thank You.
I am not here to build for you.
I am here to build with you. Let's help each other.
Tanya
Member
Posts: 19
Joined: Tue Mar 09, 2021 3:16 pm
Phoenix Version:
Has thanked: 9 times

Re: Need to show Shopping Cart Total in Navbar

Post by Tanya »

Thank you @burt

I have sent you PM about Go Pro.
admin
Contributor
Posts: 217
Joined: Wed Oct 30, 2019 1:34 pm
Phoenix Version:
Has thanked: 20 times
Been thanked: 22 times

Re: Need to show Shopping Cart Total in Navbar

Post by admin »

Tanya wrote: Sun Jan 02, 2022 9:37 am Thank you @burt

I have sent you PM about Go Pro.
Any queries about GO PRO should go to @admin


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply