Cart Items Condition Not Working When Removing Items From Cart - Bug?

Hi Charlie,

I am not sure if this is a bug, or something which would benefit from refinement.

Having just changed my Cart Off Canvas from using the Cart Off Canvas’s text toggle to bring through dynamic content to bring through the cart_item_count, I have just changed it to the setup in @DoncoMarketing’s latest video.

2024-08-15_17-06-10

I have added a minor refinement to the Cart Item Count div, by setting a condition against that div to hide the item count and its background, if the cart is empty.

To do this, I have set a condition in the div Cart Item Count, which is number and then {{dc:woocommerce:cart_items_raw}} > 0

2024-08-15_16-56-44

On the front end, with the cart empty, if I refresh the page, the condition works correctly and the item count div does not display:

2024-08-15_17-10-19

If I now add an item to the cart, the count successfully displays:

2024-08-15_17-11-14

However, if I remove the item from the cart, the count still displays with 0 as the quantity, even though it should not be shown:

2024-08-15_17-12-48

If I refresh the page with the cart still empty, the item count is not displayed - the behaviour I had hoped for in the previous step.

2024-08-15_17-10-19

It seems that the Cart Off Canvas element allows the condition to act correctly when items are added to the cart, but does not allow the condition to work when the cart is emptied.

Is this a behaviour, which can be rectified in the element, or is it something we need to accept as it is?

Many thanks,
Christopher

Hello, Christopher

Thanks for writing to us.

To help you with your concerns we need to check your settings, I would request please share the admin login details meanwhile I would suggest you troubleshoot a few of the common issues before we investigate your settings. Please share your details in a secure note. Please provide the following details

  • WordPress Login URL
  • Admin-level username and password

You can find the Secure Note button at the bottom of your posts

Thanks

Please see secure note. @charlie

Conditions only run when a page is loaded. So when a cart item is removed through AJAX the page is never reloaded and thus you end up seeing the 0 in your header. I see it as part of a more general new feature “Frontend Show Conditions” or something like that. To accomplish what you are asking it would either be to do that, or prevent AJAX from running when you are removing cart items. Given your cart is inside an off-canvas I’m not sure that would be preferable. Thanks for bringing this up.

Thanks Charlie. Glad it is on your radar.

1 Like

Hi @whitemedia,

You are most welcome.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.