Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Hello Remi, thank you for great tutorial. I've got one question. I've set up my own code:
- inside woo_add_custom_general_fields is
- ----------------------------------------------------------------------------------------------------------
- echo '<div class="options_group">';
- ?>
- <p class="form-field select_multiple_for_woocommerce">
- <label for="select_multiple_for_woocommerce">My Select Field</label><select id="select_multiple_for_woocommerce" name="select_multiple_for_woocommerce[]" multiple="multiple" class="select short">
- <option value="">Please select</option>
- <?php global $product; $args = array(
- 'post_type' => 'product',
- 'meta_key' =>'_featured'
- ); $productPosts = new WP_Query( $args ); ?>
- <?php foreach ($productPosts->posts as $product): ?>
- <option value="<?php echo $product->ID?>"
- ><?php echo $product->post_title;?></option>
- <?php endforeach; ?></select> </p>
- <?php
- echo '</div>';
- ----------------------------------------------------------------------------------------------------------
- And function for save:
- ----------------------------------------------------------------------------------------------------------
- function multiple_select_woo_add_backend_save( $post_id ){
- $select_multiple_for_woocommerce = $_POST['select_multiple_for_woocommerce'];
- update_post_meta( $post_id, 'select_multiple_for_woocommerce', $select_multiple_for_woocommerce );}
- ----------------------------------------------------------------------------------------------------------
- Products are rendering good. However data is not being saved. Could you please take a look? Thank you :)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement