L
L
ligisayan2018-10-19 15:45:36
WordPress
ligisayan, 2018-10-19 15:45:36

How to attach a drop-down list with products to a mini-cart?

Hello! There is an online store on wordpress + woocommerce. At the top of the site in the header, I brought out a mini-basket with goods like this.
functions.php

if ( defined( 'WC_VERSION' ) && version_compare( WC_VERSION, '2.3', '>=' ) ) { 
  add_filter( 'woocommerce_add_to_cart_fragments', 'header_add_to_cart_fragment' );
} else { 
  add_filter( 'add_to_cart_fragments', 'header_add_to_cart_fragment' );
}

function header_add_to_cart_fragment( $fragments ) {
    global $woocommerce;
    ob_start();
    ?>
    <span class="basket-btn__counter">(<?php echo sprintf($woocommerce->cart->cart_contents_count); ?>)</span>
    <?php
    $fragments['.basket-btn__counter'] = ob_get_clean();
    return $fragments;
}

registered in header.php
<div class="s-header__basket-wr woocommerce">
    <?php
    global $woocommerce; ?>
    <a href="<?php echo $woocommerce->cart->get_cart_url() ?>" class="basket-btn basket-btn_fixed-xs">
        <span class="basket-btn__label">Корзина</span>
        <span class="basket-btn__counter">(<?php echo sprintf($woocommerce->cart->cart_contents_count); ?>)</span>
    </a>
</div>

The cart is displayed, everything is fine. Now I'm interested in how to make a drop-down list of the contents of the basket like this. Should I install the Woocommerce Dropdown Cart plugin and attach its widget or how?
hdWsZ.jpg

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question