Snipcart markup output for SnipWire

SnipWire comes with the preinstalled module MarkupSnipWire. The module is loaded automatically and provides the custom API variable $snipwire which can be used in your ProcessWire templates like any other API variables.

All of the following MarkupSnipWire methods will only work when used within a defined SnipCart product template!

MarkupSnipWire Methods

Name Return Summary
anchor(Page $product, $options = array()) string Renders a Snipcart anchor (buy button or link).
getCurrency() string Get current cart and catalogue currency (ISO 4217 currency code).
getProductName(Page $product) string Returns the product name using the selected product name field from SnipWire module config (fallback to $page->title field).
getProductUrl(Page $product) string Returns the full product page url depending on SnipWire module config.
getProductPrice(Page $product, $currencySelected = '', $formatted = false) string

Returns the product price, raw or formatted by currency property from SnipWire module config.

  • if formatted = false and multiple currencies are configured, this will return a JSON encoded array: {"usd":20,"cad":25}.
  • if formatted = true, this will return the price formatted by the selected (or first) currency: € 19,99
getProductPriceFormatted(Page $product, $currencySelected = '') string Returns the product price formatted by currency property from SnipWire module config.
getProductThumb(Page $product) Pageimage, null Generates a Thumbnail from first image of product page-image field and returns it.
getProductCategories(Page $product, $array = true) array, string, null Returns product categories as array or comma seperated string (if any).
getProductCategoriesString(Page $product) string Returns product categories as comma seperated string (if any).
getProductTemplates($objects = true) array, WireArray Get an array of SnipWire product templates (defined in module settings).
isProductTemplate($template) bool Check if this is a SnipWire product template.
getProductTemplateFields($defaultFieldName, $allowedFieldTypes = array(), $excludeFieldNames = array()) WireArray Get a selection of fields from a SnipWire product template.