Building with Etch loops
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
- 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.
- Turn on Product dynamic data on the Settings tab, so product fields fill in inside loops and on product pages.
- 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.*}. - Add IvaSure Filters if you want filtering that keeps your card design.
- 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 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.
| Parameter | What it does | Example |
|---|---|---|
$limit | How many products the loop returns. Defaults to 12. | 24 |
$orderby | Which field decides the order. Defaults to date. | "title" |
$order | Which direction that order runs. Defaults to descending. | "ASC" |
$popular | Set to 1 to rank the most-saved products first. Needs the Wishlist add-on. | 1 |
$product | A post ID, to show one chosen product. This is what the spotlight uses. | 123 |
{"$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.
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.
| Group | Fields |
|---|---|
| Identity | name, slug, sku, permalink, checkout_permalink |
| Price | display_amount, range_display_amount, scratch_display_amount, amount, currency, is_on_sale |
| Stock | in_stock, available_stock, stock_enabled |
| Media | featured_image, has_image |
| Reviews | average_stars, total_reviews, rating_stars, rating_summary, review_url |
| Other | is_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}.
{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.
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.
[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.
Was this page helpful?