perch_shop_product()
Return a single product with the function perch_shop_product().
Requires
- Perch Shop installed
Parameters
| Type | Description |
|---|---|
| String | Slug of the item to show |
| Array | Options array, see table below |
| Boolean | Set to true to have the value returned instead of echoed. |
Options array
| Name | Value |
|---|---|
| variants | True or false. Set to true to enable the perch:variants tags in the template. Default is false. |
| template | The name of a template to use to display the content. |
| skip-template | True or false. Bypass template processing and return the content in an associative array. |
| return-html | True or false. For use with skip-template. Adds the HTML onto the end of the returned array with key html. |
| raw | True or false. Returns unprocessed content, for use alongside skip-template. |
Usage examples
Simple example displaying the product with a slug of my-product and the default template shop/products/product.html.
perch_shop_product('my-product');
This function accepts an array of options to control what is returned. It can be used as follows.
perch_shop_product('my-product', [
'template' => 'my-template.html'
]);