Skip to content
dadaniels edited this page Nov 11, 2014 · 7 revisions

addToCartButton

Generates an "Add to Cart" button for the current product. This will respond intelligently according to inventory, options, and bundled products.

USAGE

Remember that you must supply a FULL URL if you want to use images for your "soldout" or "submit" buttons, so if you are referencing a local image, you'll want to use the assets_url System Setting with the full URL scheme:

[[addToCartButton? &submit=`[[++assets_url? &scheme=`full`]]images/purchase.png`]]
  • &product_id integer (defaults to current product)
  • &submit string text/image to show as the submit button. If an image, a full URL with http:// must be specified. (default: Add to Cart)
  • &backorderSubmit string text/image to show when you're in backorder territory: inventory qty is below zero, but within your backorder threshold. If an image, a full URL with http:// must be specified. (defaults to the $submit argument)
  • &soldout string text/image to show when product purchase is not possible due to inventory tracking being disabled or the inventory qty is below the backorder max threshold. If an image, a full URL with http:// must be specified. (default: Sold Out)
  • &cssClassSoldout string optional class for the soldout image
  • &cssClassSubmit string optional class for the submit
  • &cssClassOptionLabel string optional class for the label around the option label
  • &cssClassOptionSelect string optional class for the option selects
  • &tpl string name of formatting chunk. (default: BuyButton)
  • &selectTpl formatting string used for opening <select>. For speed, this uses str_replace and not the MODX PARSER! Available placeholders are [[+slug]], [[+cssClassOptionLabel]], [[+cssClassOptionSelect]]. Default: <label for="[[+opt.slug]]" class="[[+cssClassOptionLabel]]">[[+opt.name]]</label><select id="[[+opt.slug]]" name="[[+opt.name]]" onchange="javascript:onchange_price(this);" class="cart-default-select [[+cssClassOptionSelect]]">[[+opt.content]]</select>
  • &optionTpl formatting string used for <option>. For speed, this uses str_replace and not the MODX PARSER! Available placeholders: [[+slug]], [[+modifiers]], [[+name]]. Default: <option value="[[+opt.slug]][[+opt.modifiers]]">[[+opt.name]]</option>
  • &log_level integer -- you can set the logging level in your snippet to (temporarily) override the system default.

Clone this wiki locally