StarterCart 1.0 Beta Documentation: Add Product Fields

Add Product Fields

As the built-in products come with only the bare minimum fields by default, it is essential that it be easy to add more fields to the products.

It is important to note that StarterCart.cfc extends ProgramManager.cfc. The functionality demonstrated below is just a subset of what is provided for by ProgramManager.cfc.

To add fields to the products table, first create an extended version of StarterCart. For example, create StarterCart_Example.cfc. Then make sure to point the path to the new file in components.cfm.

So, to create a field to take an image (with a maximum width and height of 400 pixels, you would have the following StarterCart_Example.cfc:

<cfcomponent extends="StarterCart">

<cffunction name="customxml">
<tables>
	<table name="prodProducts">
		<field
			name="ProductImageLarge"
			label="Image"
			type="image"
			folder="images"
			MaxWidth="400"
			MaxHeight="400"
		/>
	</table>
</tables>
</cffunction>

</cfcomponent>

If you wanted to add thumbnail of that field, you could add the following field element:

<field name="ProductThumb" type="thumb" original="ProductImageLarge" folder="thumbs" MaxWidth="80" MaxHeight="80" />

Once you refresh StarterCart, the new fields will be available in any queries (in this case, along with fields indicating the full file path and browser path of the images) as well as in the add/edit form.

Then again, you may rather just use an external source for products...