Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #276199

    Hey there!

    I’ve just purchased the Enfold theme (which is fantastic)
    I’m using the theme as an e-commerce site mainly, so I’d love to be able to have a cart in the menu so it’s visible to the user (like on the Replete theme)

    Thanks :)

    #276208

    Hey SomeBloke!

    You could add a cart page link to the menu (Appearance > Menus). If you want to display an icon instead of the word “cart” insert this code into the menu title field:

    
    <span aria-hidden="true" data-av_icon="" data-av_iconfont="entypo-fontello"></span>
    

    Cheers!
    Peter

    #276774

    Awesome, that worked just great, thank you very much! Am just wondering if there’s any way to display the amount spent next to that, so shoppers can keep track of spending?

    #277047

    Hey!

    You could register a new shortcode which outputs the cart total. Insert this code into the child theme functions.php file or enfold/functions.php:

    
    function avia_total_cart_ammount_shortcode() {
         global $woocommerce; $output = '';
         if(!empty($woocommerce->cart->get_cart_total())) $output = $woocommerce->cart->get_cart_total();
         return $output;
    }
    add_shortcode('av_total_cart', 'avia_total_cart_ammount_shortcode');
    

    and use this code as menu item title:

    
    <span aria-hidden="true" data-av_icon="" data-av_iconfont="entypo-fontello"></span> [av_total_cart]
    

    However the main problem is that it won’t update if the user clicks the “Add to cart” button on the shop page and imo this will irritate many users. Our cart icon opens the default woocommerce ajax cart widget which updates the amount automatically (via ajax) if the user adds a new item to the cart but the solution I provided above does not support such a feature.

    Cheers!
    Peter

    #777555

    Sorry, don’t mean to bring up an old thread but I want something very similar to this. Instead of getting the cart total, could I instead have the total amount of items in the cart?

    Here is a very small image of what I mean… So basically instead of an icon it would say CART and then instead of the shortcode pulling the $ amount, it would pull the quantity amount – Just like how it does inherently in enfold. The reason why I’m pursuing this is because I want it in the menu.

    http://testing.curlyhost.com/wp-content/uploads/2017/04/Cart-w-number-in-menu.jpg

    #778948

    Hi,


    @bitojoe
    I replied to your thread here – https://kriesi.at/support/topic/woocommerce-cart-shortcode/. Let us continue there :)

    Best regards,
    Yigit

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Cart in menu’ is closed to new replies.