Need to show Shopping Cart Total in Navbar

Ask the community for help and support.
Post Reply
Tanya
Posts: 19
Joined: Tue Mar 09, 2021 3:16 pm
Has thanked: 8 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.
burt
Lead Developer
Lead Developer
Posts: 2423
Joined: Tue Oct 29, 2019 9:37 am
Has thanked: 49 times
Been thanked: 137 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.
Gamechanger Addon: Queued Emails, try before you buy.
Tanya
Posts: 19
Joined: Tue Mar 09, 2021 3:16 pm
Has thanked: 8 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
Site Admin
Site Admin
Posts: 139
Joined: Wed Oct 30, 2019 1:34 pm
Has thanked: 20 times
Been thanked: 21 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
Post Reply