Remove prices from Variation drop-downs in Shopp WordPress plugin
Problem: In Shopp (1.1.9) the default variations drop-down list shows prices. This isn’t always desired. This is the default usage:
<ul class="variations"> <?php shopp('product', 'variations', 'mode=multiple&label=true&defaults=Select an option&before_menu=<li>&after_menu=</li>'); ?> </ul>
And this outputs a list that shows options as “Option Label (price)”.
Fix: The code above can be replaced with this code to manually create the same thing, giving complete control over output:
<ul class="variations">
<li>
<label for="options-1">Quantity</label>
<select name="products[<?php shopp('product', 'id'); ?>][options][]" class="category-catalog product<?php shopp('product', 'id'); ?> options" id="options-1">
<option value="">Select an option</option>
<?php
$i=1;
while (shopp('product', 'variations')): ?>
<option value="<?php echo $i;$i++; ?>"><?php shopp('product', 'variation', 'label'); ?></option>
<?php endwhile; ?>
</select>
</li>
</ul>The $i;$i++ was a bit of a work-around as I couldn’t get it to work with variation ID, so if you know a better way, please tell us below!
Minor point, but the label “Quantity” doesn’t really belong there. Nice work though!
Also .. plagiarising a bit here but you could do something similar and create sans-price radio buttons (as opposed to a dropdown):
$i = 1;
while (shopp('product', 'variations'))
{
// Form the radio button name
$id = shopp('product', 'id', 'return=true');
$name = "products[$id][options][]";
// The first field should be selected by default
$selected = ($i == 1) ? 'checked="checked"' : '';
// Echo to screen
echo '';
shopp('product', 'variation', 'label');
// Increment
$i++;
}
Ah yes, I was lazy copy-pasting from the template
Formatting didn’t quite work there. Here’s a Paste Bin link instead:
http://pastebin.com/Y41iJGkA