IF HikaShop MiniCart was Empty or not

  • Posts: 129
  • Thank you received: 0
7 years 4 months ago #273071

-- HikaShop version -- : 3.1.1

Hi,
I need to change a class of div that begins and end before HikaShop mini cart div begins based on the mini cart is empty or not.

for example, if HikaShop Mini Cart has items inside the class of the div above toggle to "EmptyCart"!

can i get the if condition code or any hint to link it to change the class of the above div?

Thanks

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

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
7 years 4 months ago #273083

Hi,

You'll want to add your code in the file "cart" of the view "product" via the menu Display>Views.
The code to check if the cart is empty or not is quite easy:

<?php if(empty($this->rows)) echo 'EmptyCart'; ?>

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

  • Posts: 129
  • Thank you received: 0
7 years 4 months ago #273150

the problem is that i have to change the class of a div that is started and ended before hika shop cart module div started.
is it even possible with js ?

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

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
7 years 4 months ago #273152

Hello,

What do you want to do with javascript exactly ?
I'm sorry but I'm not following you.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

  • Posts: 129
  • Thank you received: 0
7 years 4 months ago #273417

hi,
This is my HTML strustion:

<div>
          <div>Cart icon </div>
          <div class="ContentWrapper">
                    <div>HikaShop Module in listing style</div>
                    <div>Some Menu Module</div>
          </div>
</div>
when i click on cart icon the content wrapper appears now, i want to change the class of cart icon div when hikashop cart has item inside and when its empty !

Last edit: 7 years 4 months ago by nic7071.

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

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
7 years 4 months ago #273447

Hi,

Then you want to load the cart in your code and do the check on it.
It's really easy...
Or developer documentation already explains how to load the cart products:
www.hikashop.com/support/documentation/6...umentation.html#code

If you want to load the current cart data, you can use the code :

$cartClass = hikashop_get('class.cart');

$cart = $cartClass->loadFullCart();

The products in the cart will be available in the attribute as an array of product objects:

$cart->products

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

Time to create page: 0.064 seconds
Powered by Kunena Forum