BakerMan

Shopp Variation Radio Buttons

Dec 6th, 2011
227
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×