Post by waitz » Thu Apr 11, 2019 11:12 pm

Is there a way in OC 3 to empty the cart in the header when the cart is empty?

Opencart: 3.0.2.1 | Inside Mijoshop 4.0.8 in Joomla 3.9.5


New member

Posts

Joined
Tue Jan 10, 2012 12:22 am

Post by letxobnav » Thu Apr 11, 2019 11:50 pm

You mean a setting or via code?

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by waitz » Fri Apr 12, 2019 12:27 am

Any... I haven't found a setting so I was looking for an extension, or code if not possible

Opencart: 3.0.2.1 | Inside Mijoshop 4.0.8 in Joomla 3.9.5


New member

Posts

Joined
Tue Jan 10, 2012 12:22 am

Post by letxobnav » Fri Apr 12, 2019 1:51 am

file: catalog/controller/common/header.php
add:

Code: Select all

$data['cart_count'] = $this->cart->countProducts();
file: catalog/view/theme/default/template/common/header.twig
change:

Code: Select all

<li><a href="{{ shopping_cart }}" title="{{ text_shopping_cart }}"><i class="fa fa-shopping-cart"></i> <span class="hidden-xs hidden-sm hidden-md">{{ text_shopping_cart }}</span></a></li>
to:

Code: Select all

{% if cart_count > 0 %}
<li><a href="{{ shopping_cart }}" title="{{ text_shopping_cart }}"><i class="fa fa-shopping-cart"></i> <span class="hidden-xs hidden-sm hidden-md">{{ text_shopping_cart }}</span></a></li>
{% endif %}
This will not show the cart in the header if empty.

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by waitz » Mon Apr 15, 2019 1:36 am

Thank you :-)

Opencart: 3.0.2.1 | Inside Mijoshop 4.0.8 in Joomla 3.9.5


New member

Posts

Joined
Tue Jan 10, 2012 12:22 am

Post by straightlight » Mon Apr 15, 2019 5:17 am

Since this is about a true / false validation, there's no need for:

Code: Select all

{% if cart_count > 0 %}
It could be changed to:

Code: Select all

{% if cart_count %}

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by letxobnav » Mon Apr 15, 2019 10:12 am

true.

and you might consider hiding that icon dynamically when you are in the cart and empty it but that then has to be done with javascript in common.js.

I'll leave that to the jQuery experts.

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by straightlight » Mon Apr 15, 2019 10:23 am

It can also be done via CSS.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by letxobnav » Mon Apr 15, 2019 11:02 am

I did not know that, how does css determine if the cart is empty?

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by straightlight » Mon Apr 15, 2019 6:16 pm

letxobnav wrote:
Mon Apr 15, 2019 11:02 am
I did not know that, how does css determine if the cart is empty?
By using the forum search. While this suggestion has been posted for the products total from the header: viewtopic.php?f=202&t=210505&p=749185#p749146 , this CSS suggestion then came across: viewtopic.php?f=202&t=210505&p=749185#p749185

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by letxobnav » Mon Apr 15, 2019 6:33 pm

yes, but that css trick hides the header icon regardless of whether there is content in the cart right?
I thought the idea was to hide it if empty but show it otherwise.

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by straightlight » Tue Apr 16, 2019 5:04 am

The CSS condition can be extended. It's just that the provided example shows the first portion but not the 2nd portion as you describe.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: Baidu [Spider] and 22 guests