One of the benefits of full site editing [FSE] in WordPress is that you can customize every layout on your site โ navigation, pages, blog posts, and more. It also makes it easier to modify WooCommerce templates, so you can structure product pages to showcase your merchandise in the best possible light. If your product pages are content-heavy, showing a persistent โadd to cartโ area can be useful so that customers can purchase once theyโve read enough to buy. Adding a WooCommerce sticky add to cart area can help keep the โadd to cartโ action visible for users โ in fact, this is exactly why weโve done this on our product pages! (See Discontinued Products for WooCommerce as an example.)
Iโll show you how we created this sticky add to cart header on our site using FSE. You must be using a full site editing theme to follow this guide, such as Twenty Twenty-Four. Hereโs a video guide to creating a WooCommerce sticky add to cart, or you can read on for a step-by-step guide.
Add the WooCommerce sticky add to cart section
The typical WooCommerce product page looks something like this: image left, short description / add to cart right, and then full description and details below. Iโll modify it to add a header bar with a persistent add-to-cart that will stick to the top of the page as we scroll past it:


First, youโll need to visit a product page on your site, then click โEdit siteโ in your admin bar. This will take you to the full site editor for your single product templates. Once weโre editing that template, weโll add a new group block between the โheaderโ and existing โgroupโ block (which has all of the product content).
This will be the โcontainerโ for our sticky add to cart header. Depending on the style of your theme, you may want to style this container to make your section stand out.
Iโll add a pink background to my group, and change its position to become sticky on the page โ this means it will โstickโ to the top of the page once users scroll past it, and remain there as they scroll through the rest of the page.
If a user scrolls back up past the original position, then this block will move back to its original position.

Inside of this group, weโll now create our WooCommerce sticky add to cart header components. Hereโs the structure we want to use for the blocks โ but thereโs an easy way for you now to embed this on your site! If you copy the block code below, then click the โmoreโ icon on the group you just created, you can choose to โpaste stylesโ. This will add the block code youโve just copied to this group.
Of course, you can also choose to emulate the group Iโve created by following my outline below the block code:

<!-- wp:group {"style":{"color":{"background":"#f7559a"},"elements":{"link":{"color":{"text":"var:preset|color|base-2"}}},"position":{"type":"sticky","top":"0px"}},"textColor":"#fff","layout":{"type":"constrained"}} -->
<div class="wp-block-group has-base-2-color has-text-color has-background has-link-color" style="background-color:#f7559a"><!-- wp:group {"align":"wide","layout":{"type":"flex","flexWrap":"nowrap","justifyContent":"space-between"}} -->
<div class="wp-block-group alignwide"><!-- wp:post-title {"level":4,"style":{"elements":{"link":{"color":{"text":"var:preset|color|base-2"}}}},"textColor":"base-2","__woocommerceNamespace":"woocommerce/product-collection/product-title"} /-->
<!-- wp:group {"layout":{"type":"flex","flexWrap":"nowrap","justifyContent":"right"}} -->
<div class="wp-block-group"><!-- wp:woocommerce/product-price {"isDescendentOfSingleProductTemplate":true} /-->
<!-- wp:group {"style":{"spacing":{"margin":{"top":"10px"}}},"layout":{"type":"constrained"}} -->
<div class="wp-block-group" style="margin-top:10px"><!-- wp:woocommerce/add-to-cart-form /--></div>
<!-- /wp:group --></div>
<!-- /wp:group --></div>
<!-- /wp:group --></div>
<!-- /wp:group -->
Here are the modifications Iโve made for each block:
- Group: Container block. I changed the background and text color for this block. This block should also have its position changed to โstickyโ.
- Row: Container for the โcontentโ of the header. I made this wide-width, and changed its justification to use โspace between itemsโ.
- Product title: I added this in the leftmost position of the row, and changed it to an h4 instead of an h2.
- Row: This is the container for the add to cart area. I changed its justification to be right-aligned.
- Product price: I added this to the row with no modifications.
- Group: I added a โgroupโ to contain the add-to-cart form. This is required because I want to add a small margin to the form, but the add-to-cart block has no styling options. I used a group to โwrapโ it, and added a 10px top margin to the group (Wooโs default styles will add a 10px bottom margin, so Iโm just matching it).
- Add to cart: I added the โadd to cartโ block inside this group.
- Row: Container for the โcontentโ of the header. I made this wide-width, and changed its justification to use โspace between itemsโ.
Whew, I know it seems like a lot! Copying and pasting the block code is certainly easier โ you may have to change your colors, but it will give you the right structure.
Style the new sticky section
If you save your product template now, youโll see weโre almost there! We have a sticky header on product pages, with a working add-to-cart form. It just needs a little refinement to strut its stuff.

- We have a small gap between the header and the WooCommerce sticky add to cart group
- The add-to-cart form adds a large bottom margin that makes this look weird
We can fix both of these with a tiny amount of CSS. FSE themes donโt have any built-in โadditional CSSโ area we can add to, so weโll manually add some styles for now to make this easy. Iโll add a โcustom HTMLโ block to my footer with the following styles:

<style>
.woocommerce div.product .is-position-sticky .wc-block-add-to-cart-form form.cart { margin-bottom:0px !important; }
.single-product .wp-site-blocks > div.woocommerce.product { margin-block-start: 0px;}
</style>
And now look at that plumage! Weโve got a WooCommerce sticky add to cart header worthy of a peacock โ it looks great and keeps the add-to-cart action handy as customers read your product copy.

Let us know if you add this to your site! Or if you have a better way to add short CSS snippets to an FSE site, Iโd love to hear other ways to tweak the styling when block settings arenโt quite enough to get there.


Leave a Reply