# "Keep Shopping" Category Links Below the Cart

> Lists your most popular product categories as buttons below the cart, giving shoppers an easy way to add more before checking out.

- Type: PHP
- Runs: Woocommerce after cart
- Category: [WooCommerce](https://wpide.com/library/category/woocommerce/)
- Requires: WooCommerce
- Tags: woocommerce, cart, categories, upsell
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/woo-cart-top-categories/

## Code

```php
$count = 5; // Number of categories to show.

$terms = get_terms( array(
    'taxonomy'   => 'product_cat',
    'hide_empty' => true,
    'orderby'    => 'count',
    'order'      => 'DESC',
    'number'     => $count,
    'exclude'    => array( (int) get_option( 'default_product_cat' ) ),
) );

if ( $terms && ! is_wp_error( $terms ) ) {
    echo '<div class="wpide-keep-shopping" style="margin-top:32px;"><p style="font-weight:600;">Keep shopping</p><p>';

    foreach ( $terms as $term ) {
        printf( '<a class="button" style="margin:0 8px 8px 0;" href="%1$s">%2$s</a>', esc_url( get_term_link( $term ) ), esc_html( $term->name ) );
    }

    echo '</p></div>';
}
```

## Notes

Change $count to show more or fewer categories. Categories are ordered by number of products.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find ""Keep Shopping" Category Links Below the Cart" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
