Advertisement
Guest User

adding acf fields to woocommerce product variations

a guest
Dec 14th, 2014
723
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.37 KB | None | 0 0
  1.  
  2. function woocommerce_variation_options_acf_form($loop, $variation_data, $variation) {
  3.  
  4.   $variation_id = $variation->ID;
  5.   ?>
  6.   <tr><td colspan="2">
  7.   <style>
  8.   table.data_table td #poststuff { padding: 0; min-width: 1em;}
  9.   table.data_table td .postbox { min-width: 1em;}
  10.   table.data_table td div.acf_postbox div.field_type-true_false p.label { display: inline; }
  11.   table.data_table td div.acf_postbox div.field_type-true_false ul {display: inline-block;}
  12.   #variable_product_options .woocommerce_variation table td input[type='checkbox'] { min-width: 1em!important;}
  13.   </style>
  14.   <?php
  15.   acf_form(array(
  16.       'post_id' => $variation_id,
  17.       'form' => false,
  18.       'label_placement' => 'top',
  19.       'instruction_placement' => 'label',
  20.       'return' => add_query_arg( array( 'post_id' => $post_id, 'updated' => 'true'), get_permalink() ),
  21.       ));
  22.  
  23.       ?>
  24.       <script type="text/javascript">
  25. (function($) {
  26.   // setup fields
  27.   acf.do_action('append', $('#popup-id'));
  28. })(jQuery);
  29. </script>
  30. </td></tr>
  31. <?php
  32.  
  33. }
  34. add_action('woocommerce_product_after_variable_attributes','woocommerce_variation_options_acf_form',19,3);
  35.  
  36. add_action('admin_head','acf_form_head',20);
  37.  
  38. /**
  39. In WooCommerce : includes/admin/meta-boxes/views/html-variation-admin.php
  40. <?php do_action( 'woocommerce_product_after_variable_attributes', $loop, $variation_data, $variation ); ?>
  41. **/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement