Advertisement
BakerMan

Shopp Variation Radio Buttons

Dec 6th, 2011
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.68 KB | None | 0 0
  1. /**
  2. * This snippet is intended for use in a product.php template
  3. * in the context of Shopp 1.1.9.
  4. *
  5. * Creates radio buttons to allow product variations to be
  6. * selected. Pricing information per-variation is deliberately
  7. * omitted.
  8. */
  9.  
  10. $i = 1;
  11.  
  12. while (shopp('product', 'variations'))
  13. {
  14.     // Form the radio button name
  15.     $id = shopp('product', 'id', 'return=true');
  16.     $name = "products[$id][options][]";
  17.    
  18.     // The first field should be selected by default
  19.     $selected = ($i == 1) ? 'checked="checked"' : '';
  20.    
  21.     // Echo to screen
  22.     echo '<input type="radio" name="'.$name.'" value="'.$i.'" '.$selected.' />';
  23.     shopp('product', 'variation', 'label');
  24.    
  25.     // Increment
  26.     $i++;
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement