Displays an input element to allow customer input for a product before adding it to the cart.

shopp('product.input', 'options')

@param string $object the object or object.tag combination, if object.tag is used, the tag parameter can be omitted
@param string $tag the tag, can be hyphenated or not. Prefix with 'get' as shorthand for the return=true option
@param mixed $options associative array, or url-style name=value pairs separated by ampersands (&). Each pair is passed to the theme api tag as an option.
@returns void by default, input markup when return option is used.

Generates HTML markup for custom product inputs.


  • type: Default is text. Can be set to display the input element as a text,password,hidden,checkbox,radio field, a textarea, or a menu of options.
  • name: No default set. Sets the name of the field to track for the product in the cart and finally in the order.
  • options: No default set. When the type option is set to menu this option specifies the options in the menu separated by commas (,). To specify an option that uses apostrophes (‘) can be surrounded by quotes (“”).
  • cols: No default set. When the type option is set to textarea this option specifies the cols attribute for the <textarea> element.
  • rows: No default set. When the type option is set to textarea this option specifies the rows attribute for the <textarea> element.
  • size: No default set. When the type option is set to text or password this option specifies the size of the input in number of characters.
  • class: No default set. Specify the a custom CSS class for the input element.
  • required: Default is unset. When set to any true value, selection is required. When this option is specified, the title option must also be set to allow for correct error display.
  • value: No default set. Specifies the default value for the input element. For text and textarea type inputs, the value option is displayed in the field. For menu type inputs, the value specifies the default selected option out of the options setting.
  • HTML Field Attributes: Supports specifying other standard xHTML/HTML field attributes including: accesskey,alt,checked,disabled,maxlength,readonly,tabindex,title


<?php shopp('product', 'input'); ?>

Custom Engraving Field

<p><label>Engraving: </label><br />
<?php shopp('product','input', 'type=textarea&name=Engraving&cols=20&rows=3'); ?></p>

Custom Color Field

<p><label>Color: </label><br />
<?php shopp('product', 'input', 'type=menu&name=Color&options=green, blue, red'); ?></p>

Custom Color Field using variables

<?php $my_fieldname = 'Color'; ?>
<?php $my_options   = 'green, blue, red'; ?>

<p><label>Color: </label><br />
//Use double quotes
<?php shopp('product', 'input', "type=menu&name=$my_fieldname&options=$my_options"); ?></p>

Custom menu with user interaction required

// Notice the first option which is empty, this will make user interaction required.

<p><label>Beverage: </label><br />
<?php shopp('product.input', "type=menu&name=Beverage&options=,coffe,tea&required=true"); ?></p>

See Also

  1. Just a note if you are using the required option, you will also need to use the title option or the error messages displayed will not be able to correctly identify the missing field.

    July 10th   #

  2. Useful! Just added that to the options, thanks!

    January 13th   #

You must be logged in to post a comment.

© Ingenesis Limited. Shopp™ is a registered trademark of Ingenesis Limited.