Shortcodes
Place a cart launcher anywhere with the launcher shortcode, and choose its icon, count and total.
CartPops registers one shortcode, in two spellings. It shows a cart button with an item count that opens the cart drawer. Use it in your header, a page, a widget or a theme template. It is similar to the cart icon many themes show in the menu, with more control.
The two spellings do the same thing:
[cartpops_launcher]is the current name.[cartpops_cart_launcher]is the name CartPops V1 used. It still works, so your existing shortcodes keep working after you upgrade.
Basic use
[cartpops_launcher]
This shows a shopping cart icon, a count badge and the cart total. It sits in the flow of the page, unlike the floating launcher.
You can use it:
- In a Shortcode block in the Site Editor or the block editor.
- In a Custom HTML or text widget that supports shortcodes.
- In a theme template, with PHP:
<?php echo do_shortcode( '[cartpops_launcher indicator="none"]' ); ?>
Options
| Option | Values | Default | What it does |
|---|---|---|---|
icon |
cart, bag, basket |
cart |
The icon shown on the button. |
indicator |
none, bubble, plain |
bubble |
How the item count appears. none hides it, bubble puts it in a badge and plain shows the number without a badge. |
subtotal |
true, false |
true |
Show or hide the cart total. |
indicator_hide_empty |
true, false |
false |
Hide the count while the cart is empty. |
hide_empty |
true, false |
false |
Hide the whole launcher while the cart is empty. |
Yes/no options also accept yes, no, on, off, 1 and 0. An invalid value falls back to the default.
Icons from V1
V1 used icon names that start with cpops-icon-. Those still work, but V2 has three icons, so each one maps to the nearest match. The V1 shopping cart names become cart. The V1 shopping bag and handbag names become bag. A name CartPops does not recognize falls back to cart.
V1 also let you pass your own icon name and style it with CSS. That no longer works. A custom icon name shows the default cart icon.
Examples you can copy
Default launcher:
[cartpops_launcher]
A bag icon with no count and no total:
[cartpops_launcher icon="bag" indicator="none" subtotal="false"]
A cart with a plain count and no total:
[cartpops_launcher indicator="plain" subtotal="false"]
Hide the launcher until the cart has items:
[cartpops_launcher hide_empty="true"]
Colors
A shortcode launcher uses the colors under Inline launcher appearance on the Launcher page (WooCommerce > CartPops > Launcher): Inline Background, Inline Text, Inline Badge Background and Inline Badge Text. They apply to every inline launcher on the site. You can’t set colors per shortcode.
For anything beyond that, add CSS in Advanced > General > Custom CSS. The launcher button has the classes cpops-launcher and cpops-launcher--inline.
Good to know
- The shortcode renders nothing when CartPops is turned off (Advanced > General > Enable CartPops) or when WooCommerce has no cart available.
- Hide launcher on pages doesn’t apply to shortcode launchers. It only hides the floating launcher.
- A page can hold several shortcode launchers. They all open the same drawer.