Beispiel #1
0
 /**
  * Displays the currently selected product variation for the item or a drop-down menu to change the selection
  *
  * @api `shopp('cartitem.options')`
  * @since 1.1
  *
  * @param string        $result  The output
  * @param array         $options The options
  * - **before**: ` ` Markup to add before the options
  * - **after**: ` ` Markup to add after the options
  * - **show**: (selected) Set to `selected` to provide the currently selected option label @see `shopp('cartitem.option-label')`
  * - **class**: The class attribute specifies one or more class-names for the menu element
  * @param ShoppCartItem $O       The working object
  * @return string The options markup
  **/
 public static function options($result, $options, $O)
 {
     $class = "";
     if (!isset($options['before'])) {
         $options['before'] = '';
     }
     if (!isset($options['after'])) {
         $options['after'] = '';
     }
     if (isset($options['show']) && strtolower($options['show']) == "selected") {
         return !empty($O->option->label) ? $options['before'] . $O->option->label . $options['after'] : '';
     }
     if (isset($options['class'])) {
         $class = ' class="' . $options['class'] . '" ';
     }
     if (count($O->variants) > 1) {
         $result .= $options['before'];
         $result .= '<input type="hidden" name="items[' . $O->_id . '][product]" value="' . $O->product . '"/>';
         $result .= ' <select name="items[' . $O->_id . '][price]" id="items-' . $O->_id . '-price"' . $class . '>';
         $result .= $O->options($O->priceline);
         $result .= '</select>';
         $result .= $options['after'];
     }
     return $result;
 }