//Code to Allow Featured Product Checkbox or Other Special Custom Fields in Product Details
//Place this in your functions.php file
//Edit the field names and descriptions in the first function
//Then put your field names in the array in the second function
//Show New Field in Admin
add_action('foxyshop_admin_product_details','my_custom_product_details');
function my_custom_product_details($post_id) {
//Checkbox Example
$fieldname = "_is_featured"; //has to start with _
$fieldescription = "Featured Product";
?>
<div style="clear:both"></div>
<div class="foxyshop_field_control">
<input type="checkbox" name="<?php echo $fieldname; ?>" id="<?php echo $fieldname; ?>" style="float: left; margin: 5px 0 0 10px;"<?php echo checked(get_post_meta($post_id, $fieldname, 1),"on"); ?> />
<label style="width: 210px; margin-top: 4px;" for="<?php echo $fieldname; ?>"><?php echo htmlspecialchars($fieldescription); ?></label>
</div>
<div style="clear:both"></div>
<?php
//Text Entry Example
$fieldname = "_special_price"; //has to start with _
$fieldescription = "Special Price";
?>
<div style="clear:both"></div>
<div class="foxyshop_field_control">
<label for="<?php echo $fieldname; ?>"><?php echo htmlspecialchars($fieldescription); ?></label>
<input type="text" name="<?php echo $fieldname; ?>" id="<?php echo $fieldname; ?>" value="<?php echo htmlspecialchars(get_post_meta($post_id, $fieldname, 1)); ?>" />
</div>
<div style="clear:both"></div>
<?php
}
//Save New Field
add_action('foxyshop_save_product','my_save_custom_product_details');
function my_save_custom_product_details($post_id) {
//Enter All of Your Field Names in an array
$fieldnames = array('_is_featured', '_special_price');
foreach ($fieldnames as $fieldname) {
$fieldvalue = isset($_POST[$fieldname]) ? $_POST[$fieldname] : '';
foxyshop_save_meta_data($fieldname, $fieldvalue);
}
return $post_id;
}