SHARE
TWEET

For Remi-Thank you

a guest May 15th, 2014 432 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Hello Remi, thank you for great tutorial. I've got one question. I've set up my own code:
  2. inside woo_add_custom_general_fields is
  3. ----------------------------------------------------------------------------------------------------------
  4. echo '<div class="options_group">';
  5. ?>
  6. <p class="form-field select_multiple_for_woocommerce">
  7. <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">
  8. <option value="">Please select</option>
  9.                         <?php global $product; $args = array(
  10.           'post_type' => 'product',
  11. 'meta_key' =>'_featured'
  12.         ); $productPosts = new WP_Query( $args ); ?>
  13.        
  14.                         <?php foreach ($productPosts->posts as $product): ?>
  15.                             <option value="<?php echo $product->ID?>"
  16.                                 ><?php echo $product->post_title;?></option>
  17.                         <?php endforeach; ?></select> </p>
  18. <?php
  19. echo '</div>';
  20. ----------------------------------------------------------------------------------------------------------
  21. And function for save:
  22. ----------------------------------------------------------------------------------------------------------
  23. function multiple_select_woo_add_backend_save( $post_id ){
  24. $select_multiple_for_woocommerce =  $_POST['select_multiple_for_woocommerce'];
  25.         update_post_meta( $post_id, 'select_multiple_for_woocommerce', $select_multiple_for_woocommerce );}
  26. ----------------------------------------------------------------------------------------------------------
  27. Products are rendering good. However data is not being saved. Could you please take a look? Thank you :)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top