Skip to content
IvaSure add-ons and services for SureCart storesJoin the POD waitlist

Building with Etch loops

4 min read
Published

The starter layouts are a shortcut. The real capability underneath is that an Etch loop can iterate SureCart products and bind their fields, which means your product cards can be entirely your own design.

Five steps

  1. Add a loop in Etch. Open a page in Etch, add a Loop, then choose SureCart Products in the loop’s Select Query list. It lists published products.
  2. Turn on Product dynamic data on the Settings tab, so product fields fill in inside loops and on product pages.
  3. Show product fields. Inside the loop write {item.surecart.name} or any field below - item is your loop item id. On a single product template use {post.surecart.*}.
  4. Add IvaSure Filters if you want filtering that keeps your card design.
  5. Publish the page. Etch’s Save keeps it a draft; publish from Pages in WordPress, or from the Layouts tab if it is a starter.
A card to start from, typed into Etch's HTML pane
<a href="{item.surecart.permalink}"><img src="{item.surecart.featured_image}" alt=""><h3>{item.surecart.name}</h3><p>{item.surecart.display_amount}</p></a>

Loop parameters

The loop’s parameters decide what the query returns. All five are optional and every one of them has a working default.

ParameterWhat it doesExample
$limitHow many products the loop returns. Defaults to 12.24
$orderbyWhich field decides the order. Defaults to date."title"
$orderWhich direction that order runs. Defaults to descending."ASC"
$popularSet to 1 to rank the most-saved products first. Needs the Wishlist add-on.1
$productA post ID, to show one chosen product. This is what the spotlight uses.123
Write $popular and $product as numbers
{"$product": 123}, never "123". The builder drops quoted values, so a quoted number is the same as not setting it at all.

That is also why $popular exists as a number rather than a word: $orderby and $order are text, and the builder canvas drops text parameters while it previews. They still apply on the published page - if the canvas shows a different order from the storefront, that is the reason.

Leave ivasure_sc_etch_loop alone
The loop’s query preview lists it beside the parameters. It marks the loop as IvaSure-managed rather than being an option to set.

The fields you can bind

Twenty-seven product fields are available. The list is locked by a unit test against what the build actually produces, so it cannot drift from what resolves on the page.

GroupFields
Identityname, slug, sku, permalink, checkout_permalink
Pricedisplay_amount, range_display_amount, scratch_display_amount, amount, currency, is_on_sale
Stockin_stock, available_stock, stock_enabled
Mediafeatured_image, has_image
Reviewsaverage_stars, total_reviews, rating_stars, rating_summary, review_url
Otheris_published, featured, has_variants, trial_text, billing_interval_text, collections

Gallery images come from the same field Etch gives WooCommerce products, so a gallery built for either store works for both: {item.gallery_images.0.url} and {item.gallery_images.0.alt}.

IvaSure has its own two fields
{item.ivasure.is_gift_card} and {item.ivasure.wishlist_count}. Both are always present with a safe default, so a binding does not break when the add-on that supplies it is inactive.

Products without a photo

A product with no image used to leave a hole in the grid. Now {item.surecart.featured_image} falls back to SureCart’s own placeholder image, and {item.surecart.has_image} is true only when the product has a photo of its own - so a condition can hide the image, swap it for something else, or leave the placeholder in place.

A condition built on an empty image needs changing
featured_image is no longer empty when SureCart can supply its placeholder, so a condition that tested it for an empty string now behaves the other way round. Test has_image instead.

Filtering your own grid

IvaSure Filters applies to SureCart product loops automatically on page load. For filtering that updates without a reload and keeps your card markup, point the filter at your loop wrapper.

Filter a grid the filter did not create
[ivasure ajax="true" results_target=".your-grid-class" results_fetch_mode="document"]

results_fetch_mode="document" is the part that matters: it fetches the filtered page and swaps your grid out of it, rather than rendering generic markup the filter would have to invent. Merchandising pins rank pinned products first here too.

Shop with filters is this, pre-wired
If you want the arrangement rather than the exercise, create Shop with filters from the Layouts tab and restyle its cards.

Save to list