Configuration
Cartdock is configured on one screen: WooCommerce > Cartdock. The bar shows only on single product pages, and the screen has two bar controls plus an Ecosystem integrations card. The two bar controls live in the array option anchor_settings, and both are sanitised and clamped on save by a manage_woocommerce-gated form (so shop managers can save, not only administrators).
Enable the bar
Section titled “Enable the bar”The master toggle, stored as enabled (default true). When on, the bar renders on single product pages. When off, the bar never renders and its CSS and JS are not enqueued, there is no orphaned markup and no front-end weight. A fresh install seeds this on, so the bar works immediately.
Scroll threshold
Section titled “Scroll threshold”Stored as scroll_threshold (default 300), an integer in pixels. It is the distance past the native add-to-cart form the shopper must scroll before the bar reveals:
- Range is 0 to 5000, in steps of 10. Values outside the range are clamped on save (negative becomes 0, over 5000 becomes 5000).
- A lower value shows the bar sooner; a higher value keeps it hidden longer.
- The value is passed to the front-end script as
anchorConfig.scrollThresholdand used as the IntersectionObserver’s positive top root margin, so the bar appears once the bottom of the main form is that many pixels above the top of the viewport, and hides again when the form scrolls back into view. Browsers without IntersectionObserver fall back to a throttled scroll check.
What is fixed by design
Section titled “What is fixed by design”These are deliberately not settings, because they keep the bar correct and slim:
- Position is always the bottom edge. The bar is
position: fixed; bottom: 0. There is no top option. - No per-device toggle. The bar runs on every viewport where it is enabled. (A
max-width: 768pxrule only tightens spacing on small screens; it does not hide the bar.) - The bar shows the product image, title, price and button. The image appears when the product has one (the
woocommerce_gallery_thumbnailsize, lazy-loaded) and is not a setting. There is no quantity field: the bar sends the quantity the shopper set in the main product form, clamped to that input’s min, max and step, or 1 when the form has no quantity input. On variable products a Choose options button stands in for the button until a variation is selected. - It renders on
woocommerce_after_single_product(priority 20), so the markup sits after the native form in source order; CSS then fixes it to the viewport. There is no shortcode and no manual placement, the bar is automatic.
When the bar does not render
Section titled “When the bar does not render”The bar quietly renders nothing (rather than a broken control) when:
- the plugin is disabled, or WooCommerce is inactive, or the page is not a single product page;
- the product cannot be loaded as a
WC_Product; - the product is not purchasable and is not a variable product, for example an external/affiliate product without a price. Variable products always render so the shopper can still reach the selectors.
For a simple product that is out of stock or otherwise not purchasable but still a valid product, the bar shows a link button using WooCommerce’s own add-to-cart text (for example Read more) instead of a submit button.
Variation behaviour (automatic)
Section titled “Variation behaviour (automatic)”On variable products the bar is variation-aware with no setting. The front-end script listens to WooCommerce’s native found_variation, reset_data and hide_variation jQuery events. When a variation is found it copies that variation’s price_html into the bar, sets the resolved variation_id on the bar’s hidden form, and enables the add button only if the variation is purchasable and in stock. Cartdock adds no jQuery of its own, it uses the copy WooCommerce already loads, and if that copy is absent the bar simply stays in its safe Choose options state.
Theming with CSS
Section titled “Theming with CSS”The bar’s styles are built on --anchor-* custom properties, surface and ink colours, the brass accent, radius, gap and padding, so a theme can re-skin Cartdock without overriding selectors. The surface and text colours fall back to your theme’s --wp--preset--color--contrast and --wp--preset--color--base where they exist, and the whole palette switches under prefers-color-scheme: light. There is no template override path: the markup is rendered from the plugin’s bundled templates/sticky-bar.php and is not loaded from the theme, so restyle with CSS rather than copying a template.
Storage and cleanup
Section titled “Storage and cleanup”Cartdock stores exactly two options in your own database and contacts no external service:
anchor_settings, the array above (enabled,scroll_threshold, plusenable_swift_integrationfrom the Ecosystem integrations card).anchor_db_version, the schema marker used by the on-boot migrator to seed defaults once.
There is no per-product data and no custom table. Deleting the plugin runs uninstall.php, which removes anchor_db_version and the anchor_pro_banner_dismissed user meta. It removes anchor_settings too, unless Cartdock Pro is still installed: Pro keeps its own settings in the same option, so whichever plugin is deleted last removes it. On multisite this runs on every site.
Developer hooks
Section titled “Developer hooks”Two extension points let an add-on render its own fields into the same settings screen and option, plus a storefront visibility filter. (These are the merchant/developer-facing hooks; the plugin’s internal boot wiring is not part of the public surface.)
anchor_admin_settings_after_cards, an action fired inside the settings form, after the core card and before the submit button. Receives the resolved settings array and the option name.
add_action( 'anchor_admin_settings_after_cards', function ( array $settings, string $option ) { ?> <div class="anchor-card"> <h2><?php esc_html_e( 'My add-on', 'my-addon' ); ?></h2> <label> <input type="checkbox" name="<?php echo esc_attr( $option ); ?>[my_flag]" value="1" <?php checked( ! empty( $settings['my_flag'] ) ); ?> /> <?php esc_html_e( 'Enable my feature', 'my-addon' ); ?> </label> </div> <?php}, 10, 2 );anchor_sanitize_settings, a filter applied to the sanitised settings before save. The core sanitiser keeps only enabled, scroll_threshold and enable_swift_integration, so an add-on must re-attach its own keys here or they are dropped.
add_filter( 'anchor_sanitize_settings', function ( array $clean, array $raw ) { $clean['my_flag'] = ! empty( $raw['my_flag'] ); return $clean;}, 10, 2 );anchor/bar_visible, a filter evaluated in StickyBar::shouldRender() after the enable toggle and is_product() checks. Return false to skip enqueuing assets and printing the bar on the current product page. Receives the resolved settings array and the current WC_Product (may be null before the global is set).
add_filter( 'anchor/bar_visible', function ( bool $visible, array $settings, ?WC_Product $product ): bool { if ( ! $visible || ! $product instanceof WC_Product ) { return $visible; }
// Example: hide on products in the "clearance" category (term ID 42). if ( in_array( 42, $product->get_category_ids(), true ) ) { return false; }
return $visible;}, 10, 3 );Two storefront actions fire from the bar itself. anchor/bar_rendered (WC_Product $product, array $settings) runs after the bar markup is printed. anchor_after_add_to_cart_button (WC_Product $product, array $settings) runs right after the add-to-cart form on purchasable, in-stock simple products, outside the form so a control printed there can be a form of its own; Cartdock’s Swift integration uses it.
Ecosystem integrations
Section titled “Ecosystem integrations”Swift (Buy Now). While Swift is active, this card shows the checkbox Show the Swift Buy Now button in the sticky bar (enable_swift_integration, on by default). With it ticked, the sticky bar shows Swift’s Buy Now button next to Add to cart on simple products. Variable products do not get it. The button is Swift’s own form, printed after the bar’s add-to-cart form, not inside it, so Add to cart in the bar still only adds to the cart. Saving the screen while Swift is inactive keeps the stored value. When Swift is not installed, the row names it, Swift - Buy Now Button for WooCommerce, and links to a search for it on Plugins > Add New.