Skip to content
Everett Griffiths edited this page Jul 3, 2014 · 1 revision

Custom Fields

Custom fields allow you to add extra fields to your product inside the manager, and the values entered in these fields can be displayed in your Product Template. They are intended to store singular values (no multi-selects).

Supported Custom Field Types

  • Text
  • Textarea
  • Dropdown
  • Checkbox
  • Asset (Image)

Creating and Editing

To define a new custom field, log into the MODX manager and head to Components --> Moxycart, then click on the "Custom Fields" link. The screen there should list any custom fields that you have defined.

  • Slug: This is the unique identifier for this field. It should be lowercase and contain only alphanumeric characters, underscores, and dashes. The slug you choose corresponds directly to the placeholders available in your product template.
  • Label: The label is the human-friendly version of your slug.
  • Field Type: choose what type of input the field should be.
  • Description:
  • Configuration:
  • Group:

Adding to a Product

Once you have defined a custom field, you can add it to a product. Create or edit a product, click on the "Custom Fields" tab, then click on the "Show/Hide Fields" button. From that dialog box, you can choose which fields should be included on your product page.

HOT TIP: if you are adding the same fields to multiple products over and over again, you should set them as defaults in the parent store.


Field Types

Text

Textarea

Dropdown

These fields require configuration to define the options. Configuration can be a simple JSON array:

["Apple","Banana","Orange"]

Or if you need distinct key/value pairs, use a hash:

{"apple":"Red Apple","banana":"Banana","orange":"Orange"}

The custom field functionality is powered by the Formbuilder library, so many of the options are similar.

Checkbox

Checkboxes are useful when you need to store a boolean value, usually 1 (checked) or 0 (unchecked).

Asset (Image)

This allows you to single out any of the product's assets and store its asset_id. You will likely use the Asset Snippet to format the raw ID into something useful, e.g. an image tag or download link.

The dimensions of the visible thumbnail are controlled by the System Settings moxycart.thumbnail_width and moxycart.thumbnail_height

Clone this wiki locally