Skip to main content
The Methods filter block lets customers filter a collection page by the dates they want, or by method. It works with Shopify’s Search & Discovery app, using Supercycle’s metafields and the browser’s session storage to decide which products show. For the merchant setup, see Availability search.

How it works

The Methods filter block writes its state to session storage and re-renders the collection section from it. Your own code can read and write the same keys, so a date picker anywhere on the site can drive the filter. The search uses the calendar days in scaf-dates and returns the matching products. The Methods filter block’s date picker lists the rental lengths from enabled calendar methods, for example Rent for 4, 8, 16, or 30 days, and only those lengths can be selected. The collection URL stores those product IDs in one filter.p.m.scf.avf value, separated by commas. The dates and the method stay when the customer opens another collection, and when the theme’s Clear all removes other filters.

Session storage keys

string | null
The active filter. One of "calendar", "membership", "subscription", or "resale". Set it to null to clear every filter and show all products.
object | null
The selected date range for calendar mode. Only read when filterMode is "calendar".

Write filter state from your own code

Values are stored as JSON strings. Use this helper to write a key and notify the Methods filter block. You can inspect the current values in your browser’s developer tools under Application > Session Storage.
Set filter state

Set a date range

Calendar mode reads the range from scaf-dates:
Set a date range
Call setFilterState again to change the dates or the method. The collection runs a new search and follows.

Read the current state

Read filter state

JavaScript hooks

function
Called each time the collection section re-renders after a filter is applied. Use it to re-initialize third-party scripts or sync a custom UI to the current state. Define it before the Methods filter block initializes.
After each render

Metafields the filter reads

Supercycle sets these metafields automatically. You can inspect them under Custom data in the Shopify admin.
  • supercycle.methods. The product’s methods: Calendar, Membership, Subscription, or Resale. Filters products by method.
  • supercycle.uncommitted_inventory. Set when a variant has stock not committed to an active rental. Used by the membership, subscription, and resale filters.
  • supercycle.future_availability_inventory. Set when a variant has availability on future dates. Used by the calendar filter.

Drive the filter from a home page date picker

A date picker in a home page hero that sends customers to the collection page with calendar mode already active. The Methods filter block on the collection page reads the saved session storage on load and applies the filter.
Home page hero

Search availability from your own code

To build your own listing or filter instead of using the Methods filter block, call the search the block uses. Both calls go through the Shopify app proxy at /apps/supercycle on your store’s own domain, so send them from your storefront. Shopify signs them, and you never send an API key.
Rental lengths and earliest start
string
The first day a rental can start, as YYYY-MM-DD.
integer[]
The rental lengths your enabled calendar methods offer, in nights, in no particular order. A length in nights is one less than in days, so a 4-day rental is 3.

Search a date range

Search
Send a JSON body.
object
required
integer[]
The products available for every day of the range, as product numbers in ascending order. Each is the product’s scf.avf metafield, the value the filter.p.m.scf.avf collection filter matches. [-1] when no products are available.
Show the available products on a collection
The collection link only filters once the Rental availability filter is set up in Search & Discovery.
A search returns up to 1,200 products in one response, the first 1,200 by product number. That keeps a collection link carrying them under Shopify’s maximum URL length.
Send dates as YYYY-MM-DD. A full timestamp is read as its UTC date, which can be the day before the one the customer picked.

Add the filter to a custom or legacy theme

If your theme doesn’t support app blocks on collection pages, add the filter to the collection template.
1

Open the collection template

On Themes, open your theme’s … > Edit code menu, then open the file your theme uses for collections: sections/main-collection.liquid, sections/collection-template.liquid, or templates/collection.liquid.
2

Paste the filter component

Add the snippet wherever you want the filter to appear, usually above the product grid.
Collection template
3

Set the collection section ID

Paste your collection section’s ID into collections_section_id. It lets the filter re-render the product grid without a full page reload. See Filter by availability for how to find it.
4

Turn off methods you don't offer (optional)

Set any of enable_calendar, enable_membership, enable_subscription, or enable_resale to false to hide that filter.
5

Save and test

Save, then preview a collection that contains products with methods turned on to confirm the filter appears and filters the grid.