Site logo

Archived topic

Display cart panel on add to cart to stay on Mobile

7 replies · Started by Liana on February 23, 2021

Viewing posts 1–8 of 8

Hi Support,

Is it possible to have the "Display cart panel on add to cart" feature stay on Mobile. At the moment, the user clicks the add to cart button and the panel appears but then disappears a few seconds later. Is it possible for it to stay sticky on the mobile view?

Thanks in advance,
Liana

Hi there,

Just to confirm - do you want it to always display if items are in the cart?

Hi Tom, yes that would be fab. Is this possible?

Not exactly what it was built to do, but you could try this:

add_action( 'wp_head', function() {
    global $woocommerce;
    $items = $woocommerce->cart->get_cart();

    if ( count( $items ) > 0 ) {
        echo '<style>@media (max-width: 768px) {.add-to-cart-panel {opacity: 1;pointer-events: auto;}}</style>';
    }
} );

Hi Tom,

Thank you so much. It worked except it now appears on all the other pages on the website. Any way on making it just show for the Shop page?

Hi there,

change this line in Toms code:

if ( count( $items ) > 0 ) {

to:

if ( is_shop() && count( $items ) > 0 ) {

Amazing thank you so much guys!

Glad we could be of help

This archived topic is closed to new replies.