Skip to main content

Show cart module only when it has something in

More
13 years 7 months ago #87370 by Xavier
I think that a solution could be to add some Javascript in the view "product / cart".
Try to use the following Javascript if there is no products in the cart:
Code:
<script type="text/javascript"> var cart_module = document.getElementById('hikashop_cart_module'); var parent = cart_module.getParent(); parent.style.display='none'; </script>

Please Log in or Create an account to join the conversation.

More
13 years 7 months ago #87389 by erik_jung
The script does get rid of the empty cart but it also removes it when there's an item in it. So not quite there.

Please Log in or Create an account to join the conversation.

More
13 years 7 months ago #87469 by Xavier

if there is no products in the cart:


You can add the previous code in the php check like:
Code:
<?php if(empty($this->rows)){ ?> <script type="text/javascript"> var cart_module = document.getElementById('hikashop_cart_module'); var parent = cart_module.getParent(); parent.style.display='none'; </script> <?php } ?>

Please Log in or Create an account to join the conversation.

More
13 years 7 months ago #88425 by erik_jung
Silly me. I understand now and it works great. Just one last thing, is it possible to show the module title only when there's an item in it?

Please Log in or Create an account to join the conversation.

More
13 years 7 months ago #88556 by Xavier
This code should hide the module title too when empty cart.

You can try to add a suffix to the module in the Joomla option, set something like "-cart".
Then use the code:
Code:
<?php if(empty($this->rows)){ ?> <script type="text/javascript"> var cart_module = document.getElementById('moduletable-cart'); cart_module.style.display='none'; </script> <?php } ?>

Replace "moduletable-cart" by the class of your module, you can find it with, for example, firebug.

Please Log in or Create an account to join the conversation.

More
13 years 7 months ago #88573 by erik_jung
Still no luck. I've attached the code for cart.php. Maybe I'm doing something wrong.
This attachment is hidden for guests.
Please log in or register to see it.

Please Log in or Create an account to join the conversation.

More
13 years 7 months ago #88632 by Xavier
You don't use the good id.
Could you give me a backend access via mp ?

Please Log in or Create an account to join the conversation.

More
13 years 6 months ago #92472 by gili
hello
i m trying to do the same thing and i have the same problem
could you help please ?

Please Log in or Create an account to join the conversation.

More
13 years 6 months ago #92706 by nicolas
Hi,

Well the solution is the same. You shoudl be able to do it with AMM. Otherwise, the code modification proposed by Xavier is also a solution. Just do as explained in the previous messages.
The following user(s) said Thank You: gili

Please Log in or Create an account to join the conversation.

More
13 years 6 months ago #92762 by gili
hello
i tried to use xaviers code but it does not hide the title of module

Please Log in or Create an account to join the conversation.

More
13 years 6 months ago #92867 by Xavier
Could you give us a link to your website ?
The following user(s) said Thank You: gili

Please Log in or Create an account to join the conversation.

More
13 years 6 months ago #93057 by Xavier
Solved.

The way to do that is:
- In the Joomla cart module options, at the end of the "Module Class Suffix" option add :
Code:
" id="cart_module"
- At the end of the view "product / cart" add the code:
Code:
<?php if(empty($this->rows)){ ?> <script type="text/javascript"> var cart_module = document.getElementById('cart_module'); cart_module.style.display='none'; </script> <?php } ?>
The following user(s) said Thank You: gili

Please Log in or Create an account to join the conversation.

More
13 years 6 months ago #93660 by gili
hello
after this script
when i click on the categories (Κατηγορίες) on one of the subcategories the module disappears and only the title remains
helppp !!!! :)

Please Log in or Create an account to join the conversation.

More
13 years 6 months ago #93857 by Xavier
Hi,

The problem don't come from the script.
It's due to the parameters of the module "Κατηγορίες", it display content depending on the category displayed.
If the category have no sub categories so it's empty.

Please Log in or Create an account to join the conversation.

More
13 years 6 months ago #93870 by gili
hello
i m not sure i understood that. could u please tell me the steps to fix it ????
regards

Please Log in or Create an account to join the conversation.

More
13 years 6 months ago #94032 by nicolas
The solution of Xavier won't hide the title of the module.
If you don't want that, you should use the solution with AMM.

Please Log in or Create an account to join the conversation.

More
13 years 6 months ago #94113 by gili
hello
what xavier did and said to me worked perfectly to the module i wanted
the problem is to another module so i asked whats wrong with the other one and how to fix it !
regards

Please Log in or Create an account to join the conversation.

More
13 years 6 months ago #94456 by nicolas
Ah ok, I had read too fast.
That's because you have the "Synchronize with currently displayed item when possible" turned on in the hikashop options of your module. You should turn off that option.

Please Log in or Create an account to join the conversation.

More
13 years 5 months ago #97117 by erik_jung
Hello Xavier,

I have tried your last solution with the Module Class Suffix and Product/Cart and it does hide the cart when empty. However the problem is that when you add an item to the cart, the cart doesn't show up. It only shows up once you've refreshed the page.

Can you help?

Thanks
Erik

Please Log in or Create an account to join the conversation.

More
13 years 5 months ago #97307 by Xavier
Hi,

Do you have the latest version of HikaShop ?
Can you try to change the value for the option "Use AJAX when possible for add to cart buttons", option in Config > Main > Advanced settings.

Please Log in or Create an account to join the conversation.

Time to create page: 0.290 seconds
Powered by Kunena Forum