Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save codehooligans/b23d67d3b9298355637b to your computer and use it in GitHub Desktop.
Save codehooligans/b23d67d3b9298355637b to your computer and use it in GitHub Desktop.
Codehooligans.com: Product Packages Edit Form Fields
<?php
add_action( 'product_packages_edit_form_fields', 'edit_product_packages', 10, 2);
function edit_product_packages($tag, $taxonomy)
{
$product_package_active = get_metadata($tag->taxonomy, $tag->term_id, 'product_package_active', true);
// Check/Set the default value
if (!$product_package_active)
$product_package_active = "Yes";
$product_package_unit_price = get_metadata($tag->taxonomy, $tag->term_id, 'product_package_unit_price', true);
$product_package_ship_price = get_metadata($tag->taxonomy, $tag->term_id, 'product_package_ship_price', true);
// Check/Set the default value
$product_package_ship_unit = get_metadata($tag->taxonomy, $tag->term_id, 'product_package_ship_unit', true);
if (!$product_package_ship_unit)
$product_package_ship_unit = 1;
?>
<tr class="form-field">
<th scope="row" valign="top"><label for="product_package_active">Package Active?</label></th>
<td>
<select name="product_package_active" id="product_package_active">
<option value="Yes" selected="selected">Yes</option>
<option value="No" <?php
if ($product_package_active == "No") echo ' selected="selected";'; ?>>No</option>
</select>
<p class="description">Marking a Package to 'No' will hide all items in that package.</p>
</td>
</tr>
<tr class="form-field">
<th scope="row" valign="top"><label for="product_package_unit_price">Package Unit Price?</label></th>
<td>
<input type="text" name="product_package_unit_price" id="product_package_unit_price"
value="<?php echo $product_package_unit_price; ?>"/><br />
<p class="description">This is the unit price for the items in this 'package'.</p>
</td>
</tr>
<tr class="form-field">
<th scope="row" valign="top"><label for="product_package_ship_price">Package Shipping Price?</label></th>
<td>
<input type="text" name="product_package_ship_price" id="product_package_ship_price"
value="<?php echo $product_package_ship_price; ?>"/><br />
<p class="description">This is the cost per unit to ship the products in this package.</p>
</td>
</tr>
<tr class="form-field">
<th scope="row" valign="top"><label for="product_package_ship_price">Package Shipping Unit</label></th>
<td>
<input type="text" name="product_package_ship_unit" id="product_package_ship_unit"
value="<?php echo $product_package_ship_unit; ?>"/><br />
<p class="description">This is the quantity of product items. Normally this will be 1. For cards this number may be 6 or 8.</p>
</td>
</tr>
<?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment