Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

data-ajax-cart-bind="item_count" not working #94

Closed
edoardolunardi opened this issue Mar 22, 2024 · 2 comments
Closed

data-ajax-cart-bind="item_count" not working #94

edoardolunardi opened this issue Mar 22, 2024 · 2 comments

Comments

@edoardolunardi
Copy link

edoardolunardi commented Mar 22, 2024

Hey, I'm having issue displaying the number of items in the cart in my header.
The number of items is correctly displayed upon page reload (that is liquid doing), but looks like data-ajax-cart-bind="item_count is ignored/doing nothing.

Below the snipper responsible of rendering what's in the screenshot.

Note: the lib was setup following the official docs (almost everything else works, "almost" since I'm having another couple of issues, but I will open separate issues for the rest)

Thank you!

      <div class="flex items-center gap-16 lg:ml-auto">
        <button class="hidden lg:block">
          {% render 'icon-search', class: 'w-24' %}
        </button>
        <div class="hidden lg:block">
          {% render 'icon-heart', class: 'w-24' %}
        </div>
        {%- if shop.customer_accounts_enabled -%}
          <a
            class="hidden lg:block"
            href="{%- if customer -%}{{ routes.account_url }}{%- else -%}{{ routes.account_login_url }}{%- endif -%}"
          >
            {% render 'icon-account', class: 'w-24' %}
          </a>
        {%- endif -%}
        <button
          onclick="
            document.documentElement.classList.add('js-show-cart-drawer');
            Components.BodyScrollLock.disableBodyScroll();
          "
          class="relative"
        >
          {% render 'icon-bag', class: 'w-24' %}
          <span class="sr-only">Open cart</span>
          <div
            class="absolute right-0 top-0 flex h-12 w-12 items-center justify-center rounded-full bg-purple-75 text-[8px] font-semibold text-white"
          >
            <span data-ajax-cart-bind="item_count">{{ cart.item_count }}</span>
          </div>
        </button>
      </div>
Screenshot 2024-03-22 at 17 55 29
@edoardolunardi
Copy link
Author

Related to #95

@edoardolunardi
Copy link
Author

Closing as I went with a custom ajax cart.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant