Skip to content

Instantly share code, notes, and snippets.

@pmeissner
Created August 27, 2011 20:12
Show Gist options
  • Save pmeissner/1175815 to your computer and use it in GitHub Desktop.
Save pmeissner/1175815 to your computer and use it in GitHub Desktop.
product options
<?
if ($product->extra_options->count):
?>
<div class="extra_options">
<table class="product_attributes">
<? foreach ($product->extra_options as $option):
$control_name = 'product_extra_options['.$option->option_key.']';
$posted_options = post('product_extra_options', array());
$is_checked = isset($posted_options[$option->option_key]);
$options_string = PSInventory_Data::create_option_string(post('options'), $product->id);
$data = PSInventory_Data::create()->where('product_id=? AND options_string=?', $product->id, $options_string)->find();
$extended_sku = $data->extended_sku;
?>
<tr>
<td><input name="<?= $control_name ?>" <?= checkbox_state($is_checked) ?> id="extra_option_<?= $option->id ?>" value="1" type="checkbox"/></td>
<th>
<label for="extra_option_<?= $option->id ?>"><?= h($option->description) ?>:</label>
<? if ($option->price > 0): ?>
<span class="price">+ <?= format_currency($option->get_price($product)) ?></span>
<? else: ?>
<span class="price">free</span>
<? endif ?>
</th>
</tr>
<? endforeach ?>
</table>
</div>
<? endif ?>
<?php echo $extended_sku ?>
<?
if ($product->extra_options->count):
?>
<div class="extra_options">
<table class="product_attributes">
<? foreach ($product->extra_options as $option):
$control_name = 'product_extra_options['.$option->option_key.']';
$posted_options = post('product_extra_options', array());
$is_checked = isset($posted_options[$option->option_key]);
?>
<tr>
<td><input name="<?= $control_name ?>" <?= checkbox_state($is_checked) ?> id="extra_option_<?= $option->id ?>" value="1" type="checkbox"/></td>
<th>
<label for="extra_option_<?= $option->id ?>"><?= h($option->description) ?>:</label>
<? if ($option->price > 0): ?>
<span class="price">+ <?= format_currency($option->get_price($product)) ?></span>
<? else: ?>
<span class="price">free</span>
<? endif ?>
</th>
</tr>
<? endforeach ?>
</table>
</div>
<? endif ?>
<? $options_string = PSInventory_Data::create_option_string(post('options'), $product->id);
$data = PSInventory_Data::create()->where('product_id=? AND options_string=?', $product->id, $options_string)->find();
$extended_sku = $data->extended_sku;
?>
<?php echo $extended_sku ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment