shopp('checkout.order-data')

Displays a custom text field for collecting any number of custom fields with the order.

shopp('checkout', 'order-data', '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, order data input when return option is used

Alternative Forms

shopp('checkout.order-data', 'options');

Description

Displays an order data checkout input into the checkout form.

If the checkout form has been submitted with one of these order-data inputs, the order will have a value associated with the user-specified name of the input, and the value will be retained.

Universal Options

All Theme API calls have these options.

  • return: when set to true, 1, or on, this option forces the tag to return the value instead of displaying/echoing the value to the page. Alternatively, prefix the tag parameter with get to get the same effect. All theme api tags that return a boolean value will return by default.
  • echo: when set to false, 0, or off, this option forces the tag to display the value to the page. This is the default for all non-boolean tags.
  • is: when set to true, 1, or on, this option will evaluate the return of the theme api call as a boolean true or false value. See how values are converted to boolean.

Options

The following options are valid options:

  • name: (required) Specifies the name of the field to be tracked with the order.
  • type: Specifies the type of field (default hidden). Accepts text,password,checkbox,radio,hidden (Note: Name is required with type.)
  • mode: Default is (not set). Displays an input of the specified type when not set. Set this option to value to display the value of the field instead of rendering an input element. This is useful for showing the currently entered value to the user to confirm their information.
  • value: Specifies the default value of the input. For the menu type, this should be one of the values in the options option, see below. Can only be used for text, hidden, password, textarea, and menu types.

Textarea Options

The following options are valid for type=textarea order data inputs:

  • title: Specify the title attribute of the input. name option is used if not set.
  • cols: Number of columns to use for the input. Default 30.
  • rows: Number of rows to use for the input. Default 3.
  • accesskey: option for the accesskey input attribute. The option’s value is output as the attribute.
  • tabindex: option for the tabindex input attribute. The option’s value is output as the attribute.
  • class: option for the class input attribute. The option’s value added to the class attribute.
  • disabled: option for the disabled input attribute. Outputs a ‘disabled’ class and attribute if option is set to ‘true’,’on’,’1′.
  • required: option for the required input attribute. Output a ‘required’ class if option is set to ‘true’,’on’,’1′.

Menu Options

The following options are valid for type=menu order data inputs:

  • options: Comma separated list of values (if options are in string notation), or an associative array of value => label options to use for menu.
  • title: Specify the title attribute of the input. name option is used if not set.
  • required: option for the required input attribute. Output a ‘required’ class if option is set to ‘true’,’on’,’1′.
  • class: option for the class input attribute. The option’s value added to the class attribute.
  • disabled: option for the disabled input attribute. Outputs a ‘disabled’ class and attribute if option is set to ‘true’,’on’,’1′.
  • size: option for the size input attribute. The option’s value is output as the attribute.
  • tabindex: option for the tabindex input attribute. The option’s value is output as the attribute.
  • accesskey: option for the accesskey input attribute. The option’s value is output as the attribute.

The below options can be used for all inputs of type text, hidden, password, checkbox, and radio:

Default Form Input Options

These options are used on theme api calls that output form input tags, to specify attributes.

  • class: option for the class input attribute. The option’s value added to the class attribute.
  • format: option for the format input attribute. The option’s value is output as the attribute.
  • disabled: option for the disabled input attribute. Outputs a ‘disabled’ class and attribute if option is set to ‘true’,’on’,’1′.
  • minlength: option for the minlength input attribute. The option’s numeric value is output a class. (ie. min1)
  • maxlength: option for the maxlength input attribute. The option’s numeric value is output a class. (ie. max1)
  • readonly: option for the readonly input attribute. Outputs a ‘readonly’ class and attribute if option is set to ‘true’,’on’,’1′.
  • required: option for the required input attribute. Output a ‘required’ class if option is set to ‘true’,’on’,’1′.
  • autocomplete: option for the autocomplete input attribute. The option’s value is output as the attribute.
  • accesskey: option for the accesskey input attribute. The option’s value is output as the attribute.
  • alt: option for the alt input attribute. The option’s value is output as the attribute.
  • checked: option for the checked input attribute. Output if option is set to ‘true’,’on’,’1′.
  • size: option for the size input attribute. The option’s value is output as the attribute.
  • src: option for the src input attribute. The option’s value is output as the attribute.
  • tabindex: option for the tabindex input attribute. The option’s value is output as the attribute.
  • cols: option for the cols input attribute. The option’s value is output as the attribute.
  • rows: option for the rows input attribute. The option’s value is output as the attribute.
  • title: option for the title input attribute. The option’s value is output as the attribute.
  • value: option for the value input attribute. The option’s value is output as the attribute.
  • label: option for the label input attribute. Can be used instead of value for the value attribute as well.

Examples

Display an order data textarea with the name “Special Instructions”.

<?php shopp('checkout','order-data','name=Special Instructions&type=textarea'); ?>

Display a menu of order data menu options for email preferences.

<?php
// Order data menu options array
// form of value => Label 
$menu = array(
    'none' => 'Do not email me',
    'all' => 'Email me all news.',
    'release' => 'Email when new release is available',
    'security' => 'Email only for security releases'
);

shopp('checkout.order-data', array(
    'name' => 'Notifications',
    'type' => 'menu',
    'options' => $menu, // use the above menu
    'required' => 'on',
    'title' => 'Notification Settings',
    'class' => 'notifications settings menu'
));
?>

Display a radio list of order data menu options for email preferences.

<?php
<ul><?php
// Order data menu options array
// form of value => Label 
$menu = array(
    'none' => 'Do not email me',
    'all' => 'Email me all news.',
    'release' => 'Email when new release is available',
    'security' => 'Email only for security releases'
);

foreach ($menu as $value => $label ) :

    $checked = '';
    if ( shopp(checkout.get-order-data','mode=value&name=Notifications) == $value )
        $checked = '&checked=on';
        
?><li><label><?php
    shopp('checkout.order-data',"name=Notifications&type=radio&value=$value".$checked);
    echo " $label";
?></label></li>
<?php endforeach; ?>
</ul>

See Also

You must be logged in to post a comment.

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

Skip to toolbar