The Tiles SDK provides methods for interacting with the widget's tiles, including searching, fetching, and managing tile states.
Tiles are an essential part of the UGC platform, you will likely spend most of your time manipulating tiles and retrieving tile data with the Tiles API.
// Get shopspots for a tile constshopspots = sdk.getShopspotsFromTile('tile-123');
getTile
getTile:()=>Tile|undefined
Remarks
Get the current selected tile (expanded)
Example
// Get the currently expanded tile constexpanded = sdk.getTile();
getTileById
getTileById:(id:string)=>Tile|undefined
Remarks
Get a tile by its id
Example
// Get a tile by id consttile = sdk.getTileById('tile-123');
getTiles
getTiles:()=>Tile[]
Type Declaration
():Tile[]
Returns Tile[]
Tile[]
Remarks
Get all tiles
Example
// Get all tiles and log their ids sdk.getTiles().forEach(tile=>console.log(tile.id));
hasMoreTiles
hasMoreTiles:()=>boolean
Remarks
Check if more tiles are available
Example
// Check if there are more tiles to load if (sdk.hasMoreTiles()) { // load more }
hideTileById
hideTileById:(tileId:string)=>Promise<void>
Remarks
Hide a tile by id
Example
// Hide a tile with a specific id awaitsdk.hideTileById('tile-123');
hideTilesAfterNth
hideTilesAfterNth:(nth:number)=>void
Remarks
Hides every tile at or after the nth position (0-based) without changing the per-page
visible-tile count used for fetching. Use this when a widget needs to control how many
tiles are shown independently of how many it loads per page - e.g. masonry's "rows" mode,
where the number of visible rows grows with the load-more page but the fetch size stays
constant. Tiles hidden this way are revealed again automatically on the next load-more.
Example
// Show only the first 8 tiles, keep the rest loaded but hidden sdk.hideTilesAfterNth(8);
loadTilesUntilVisibleTilesCount
loadTilesUntilVisibleTilesCount:()=>Promise<void>
Remarks
Load tiles until visible tile count
Example
// Ensure enough tiles are loaded to meet the visible count awaitsdk.loadTilesUntilVisibleTilesCount();
openExpandedTiles
openExpandedTiles:(tileId:string)=>void
Remarks
Open the expanded tile
This is helpful when you want to open the expanded tile programmatically
Example
// Open the expanded tile for a specific tile id sdk.openExpandedTiles('tile-123');
Registers a widget-specific formula for how many tiles are needed to fill N rows, used
when custom_tile_per_page_type is "rows". Must be called synchronously from the
widget's own extension script, before its first tiles fetch (i.e. before EVENT_JS_RENDERED).
Example
sdk.setRowsPerLoadCalculator(({ rowsPerPage, gap }) =>myTilesPerRowFormula(rowsPerPage, gap))
setSelectedProductId
setSelectedProductId:(productId:string)=>void
Remarks
Set selected product in state
setTile
setTile:(tile:Tile)=>void
Remarks
Set the selected tile (expanded)
Example
// Set a tile as the currently expanded tile sdk.setTile(tile);
Remarks
The Tiles SDK provides methods for interacting with the widget's tiles, including searching, fetching, and managing tile states. Tiles are an essential part of the UGC platform, you will likely spend most of your time manipulating tiles and retrieving tile data with the Tiles API.