Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Ranged dropdowns - put this in your functions.php file
- add_action('foxyshop_admin_product_details','my_custom_product_details');
- function my_custom_product_details($post_id) {
- $fieldname = "_dropdown_qty"; //has to start with _
- $fieldescription = "Qty Groups";
- ?>
- <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
- }
- 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('_dropdown_qty');
- foreach ($fieldnames as $fieldname) {
- $fieldvalue = isset($_POST[$fieldname]) ? $_POST[$fieldname] : '';
- foxyshop_save_meta_data($fieldname, $fieldvalue);
- }
- return $post_id;
- }
- function my_foxyshop_qty() {
- global $product;
- $dropdown_qty = get_post_meta($product['id'], '_dropdown_qty', 1);
- if (!$dropdown_qty) {
- foxyshop_quantity();
- return;
- }
- $arr_dropdown = explode(",", $dropdown_qty);
- $quantity_title = apply_filters("foxyshop_quantity_title", "Quantity");
- echo '<label class="foxyshop_quantity" for="quantity_' . $product['id'] . '">' . $quantity_title . '</label>'."\n";
- echo '<select class="foxyshop_quantity" name="quantity">';
- for ($i = 0; $i < count($arr_dropdown); $i++) {
- $val = trim($arr_dropdown[$i]);
- echo '<option value="' . $val . foxyshop_get_verification('quantity',$val) . '">' . $val . '</option>' . "\n";
- }
- echo '</select>'."\n";
- echo '<div class="clr"></div>';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement