Store Hugs Developers

Products

The published catalog, as the shop's own storefront lists it: search, filter and sort products, and read one in full.

Reach them through $storefront->products. A publishable or a secret key reads them.

List products

$storefront->products->list(array $query = []): array

One numbered page of the products the storefront lists, filtered and sorted as its own catalog is. 20 per page by default, at most 50.

taxonomy takes term ids from any classifications, from taxonomies->terms(). Within a classification any chosen term matches, and every classification chosen must match.

Parameters

Parameter Type
$query array The query fields below, by name.

Query fields

ParameterTypeDescription
searchstringAt most 200 characters.
taxonomy[]array of integerTerm ids from any classifications (from /api/v1/taxonomies/{taxonomy}/terms), at most 20. A product matches when it has any of the chosen terms within each classification, in every classification chosen (brand A or B, and red). At most 20 items.
minPricenumberAt least 0.
maxPricenumberAt least 0.
inStockboolean
featuredboolean
sortstringOne of newest, price_asc, price_desc, name_asc, featured.
pageintegerAt least 1.
perPageintegerAt least 1. At most 50. Default 20.
localestringOne of the shop's languages. Else Accept-Language, else the shop's default language.

Returns

An array with data (a list of ProductSummary), links and meta:

FieldTypeDescription
linksobject
links.firststring (uri)
links.laststring (uri)
links.prevstring (uri) or null
links.nextstring (uri) or null
metaobject
meta.currentPageinteger
meta.frominteger or null
meta.lastPageinteger
meta.linksarray of object
meta.links[].urlstring (uri) or null
meta.links[].labelstring
meta.links[].pageinteger or null
meta.links[].activeboolean
meta.pathstring (uri)
meta.perPageinteger
meta.tointeger or null
meta.totalinteger
dataarray of ProductSummary
data[].idinteger
data[].slugstring
data[].titlestring or null
data[].skustring or null
data[].priceMoneyFields: amount, currency, formatted.
data[].regularPriceMoneyFields: amount, currency, formatted.
data[].onSaleboolean
data[].inStockboolean
data[].ratingRating or null
data[].rating.averagenumber
data[].rating.countinteger
data[].imagestring (uri) or null

Errors

StatusWhen
401invalid_api_key: no active Storefront key of this shop, or invalid_customer_token: a bearer token not valid for this shop.
402The shop is suspended (message only).
403origin_not_allowed (publishable key from an unlisted site), secret_key_in_browser, or the shop is not live (message only).
404Not found, or the shop's plan has no Integration API.
422Validation errors ({ message, errors }), or an idempotency refusal(idempotency_key_reused, idempotency_key_invalid).
429Rate limited.

Example

$page = $storefront->products->list([
    'taxonomy' => [4],
    'inStock' => true,
    'sort' => 'price_asc',
    'page' => 2,
]);

foreach ($page['data'] as $product) {
    echo $product['name'], PHP_EOL;
}

Get a product

$storefront->products->get(string $slug): array

One published product in full, by its slug: its description, images, stock, categories, specifications, reviews and variants.

Parameters

Parameter Type
$slug string The product's slug.

Returns

A ProductDetail array:

FieldTypeDescription
idinteger
slugstring
titlestring or null
skustring or null
priceMoneyFields: amount, currency, formatted.
regularPriceMoneyFields: amount, currency, formatted.
onSaleboolean
inStockboolean
ratingRating or null
rating.averagenumber
rating.countinteger
imagestring (uri) or null
descriptionstring or nullPurified HTML.
shortDescriptionstring or nullPurified HTML.
partNumberstring or null
unitstring or null
stockQuantityinteger or nullNull when the product doesn't track stock.
imagesarray of string (uri)
categoriesarray of object
categories[].idinteger
categories[].slugstring
categories[].namestring or null
categories[].typestring or null
specificationsarray of object
specifications[].groupstring or null
specifications[].rowsarray of object
specifications[].rows[].namestring
specifications[].rows[].valuestring
specifications[].rows[].unitstring or null
reviewsobject or nullNull when the shop has reviews off.
reviews.averageRatingnumber
reviews.totalReviewsinteger
reviews.distributionobjectReview counts by star rating.
reviews.distribution.5integer
reviews.distribution.4integer
reviews.distribution.3integer
reviews.distribution.2integer
reviews.distribution.1integer
variantsarray of objectThe product's siblings in its variable product group that this storefront sells, this product included.
variants[].productIdinteger
variants[].slugstring
variants[].isThisProductboolean
variants[].optionsarray of object
variants[].options[].typestring or null
variants[].options[].valuestring or null
variants[].priceMoneyFields: amount, currency, formatted.
variants[].inStockboolean

Errors

StatusWhen
401invalid_api_key: no active Storefront key of this shop, or invalid_customer_token: a bearer token not valid for this shop.
402The shop is suspended (message only).
403origin_not_allowed (publishable key from an unlisted site), secret_key_in_browser, or the shop is not live (message only).
404product_not_found, or the shop's plan has no Integration API.
429Rate limited.

Example

$product = $storefront->products->get('ceramic-mug');