Add WooCommerce cart to Genesis navigation

Reader Interactions

Comments

  1. drew says

    Thank you so much for this post. It is exactly what I was looking for. It works great. I have a few questions how this works.

    I thought I would easily be able to adapt the the script to be able to add a conditional link for a WooCommerce “Log In” and “My Account” link next to the cart info.

    It was then I realized your code created a span class of .amount. I’m puzzled by this because I only see a span class of .cart-count. Perhaps an explanation of why this happens will solve my problem.

    My problem:
    When I create a duplicate of your code and remove all the info about cart links for some reason my text in a new div and span still link to the cart. A quick fix I found is to put my add_action and function above you add_cart code. When I do this my text is no longer linked to the code, but the display order is switched on my browser as well.

    This is a bare bones problem, If you have any insight into the conditional statements needed to determine if a user is logged in or not would be icing on the top. I’m pretty new to all this.

    here is my code showing your code on the top, then mine below:
    https://gist.github.com/digitaldesigndrew/e99bbe34ed9fa3264440

    I hope my question makes sense, it seems odd to me.

    Thanks for your wonderful post! It really made my day.

  2. Paul says

    Hi Frank,
    should this tutorial create the cart icon too? All i’m getting are the numbers, no icon.

    Thanks

  3. Aaron J says

    Hi, This is great. Is there a way to make sure it updates when changes are made in the cart? For example removing an item or updating the quantity happens via ajax and so the navigation items don’t update.

    Either force a page refresh or send it ajax updates?

    Thanks!

    • Frank Schrijvers says

      You have to use another hook. Now the WooCommerce cart is add to primary navigation Genesis by the hook genesis_header_right. If you install the Genesis Visual Hook Guide plugin you can see which hook you have to use.

Leave a Reply

Your email address will not be published. Required fields are marked *