Skip to main content

Add to Cart

Add to Cart

The add-to-cart form with a quantity stepper. It adds over REST — no page reload — and still works as a plain form without JavaScript.

It knows what it is looking at: a grouped product gets a "View products" link, an external one gets its own button, and a variable product without a picker beside it links to its page instead of pretending it can be added.

Its options​

Every component is configured from Etch's properties panel. Add to Cart is the one with the most to say:

The Add to Cart properties panel in Etch

Notice the Colors group: each one reads a shop token — var(--fe-woo-accent, #1f2937) — so a component you never touch already follows the palette you set under Fancy Etch → Design.

Props

PropTypeDefaultWhat it does
Button labeltext{this.fecommerce.single_add_to_cart_text}Leave the binding to use WooCommerce's own wording, already translated. It says "Add to cart" even for a variable product, because the picker is right here — "Select options" is for listings that have none.
Quantity labeltextQuantity
Show the quantity labelon / offonTurn it off in a product card, where the word above a − 1 + control costs a whole line and says nothing the control does not. It is hidden from sight only: the label stays tied to the field, so the number keeps its accessible name.
Decrease button labeltextDecrease quantity
Increase button labeltextIncrease quantity
Size presetchoice: full, compactfullCompact makes the quantity picker and the button a size smaller — what a catalogue card wants. A grouped product shows a button to its page instead of its list: three quantity pickers are too much for a card, and its page is where they are chosen. Whether the picker shows at all is the switch below.
Show the quantity pickeron / offonOff leaves just the button. The quantity is still sent — one — with or without JavaScript.
Colors → Backgroundtextvar(--fe-woo-accent, #1f2937)
Colors → Texttextvar(--fe-woo-accent-color, #ffffff)
Colors → Hover backgroundtextvar(--fe-woo-accent-hover, color-mix(in srgb, var(--fe-woo-accent, #1f2937) 85%, var(--fe-woo-accent-color, #ffffff)))
Colors → Button text on hovertextvar(--fe-woo-accent-color-hover, var(--fe-woo-atc-color, #ffffff))
Colors → Borderstextvar(--fe-woo-border, #e8ebef)The lines between the rows of a grouped product, and the outline of a row you have to open to choose.
Size → Corner radiustextvar(--fe-woo-control-radius, 0.5rem)
Size → Horizontal paddingtext1.25rem
Size → Control heighttext2.75remApplies to the button and the quantity stepper alike.
Product idtext{this.fecommerce.id}Comes from the product being shown. Inside a loop it follows each product by itself when the loop’s item is called «this»; with any other name, bind it to that name.
Product nametext{this.fecommerce.name}Comes from the product being shown. Inside a loop it follows each product by itself when the loop’s item is called «this»; with any other name, bind it to that name.
Product URLtext{this.fecommerce.permalink}Comes from the product being shown. Inside a loop it follows each product by itself when the loop’s item is called «this»; with any other name, bind it to that name.
Minimum quantitytext{this.fecommerce.min_quantity}Comes from the product being shown. Inside a loop it follows each product by itself when the loop’s item is called «this»; with any other name, bind it to that name.
Maximum quantitytext{this.fecommerce.max_quantity_attr}Comes from the product being shown. Inside a loop it follows each product by itself when the loop’s item is called «this»; with any other name, bind it to that name.
Product buyabletext{this.fecommerce.buyable}Whether this product can go in the cart with nothing but an id and a quantity. A grouped or external product cannot, and then this shows a link to where it can be bought instead of a form that would only fail.
Product buy urltext{this.fecommerce.add_to_cart_url}Where the link goes when the product cannot be bought here.
Unavailable labeltext{this.fecommerce.add_to_cart_text}What that link says: «View products», «Buy on…», «Read more».
Product kindtext{this.fecommerce.type}WooCommerce’s product type. A grouped product is not bought: its children are, one quantity each — so this switches the form for that list.

Variables of its own

VariableDefaultWhat it controls
--fe-woo-atc-bgvar(--fe-woo-accent, #1f2937)The button's background.
--fe-woo-atc-hover-bgvar(--fe-woo-accent-hover, color-mix(in srgb, var(--fe-woo-atc-bg, #1f2937) 85%, var(--fe-woo-atc-color, #ffffff)))The background under the pointer. Worked out from the accent unless you set it.
--fe-woo-atc-hover-colorvar(--fe-woo-accent-color-hover, var(--fe-woo-atc-color, #ffffff))Its text — the pair travels together, so a lighter hover can carry darker text.
--fe-woo-atc-padding-inline1.25remHow wide the button is around its label. The height comes from the control size.
--fe-woo-atc-font-weightvar(--fe-woo-button-weight, 500)The weight of the label.
--fe-woo-atc-min-sizevar(--fe-woo-control-size, 2.75rem)The button's height. Change it only to misalign it from the stepper on purpose.
--fe-woo-atc-status-colorvar(--fe-woo-success, #15803d)«Added to cart».
--fe-woo-atc-error-colorvar(--fe-woo-danger, #b91c1c)Whatever went wrong instead.
--fe-woo-atc-feedback-sizevar(--fe-woo-text-l, 0.94rem)The size of both messages.