funcs[$name]) ? call_user_func_array($this->funcs[$name], $args) : ''; } // during the first creation of this object register some hooks protected function __construct() { $this->api = ACF_Woo_API::get_instance(); // once all plugins are loaded, figure out if we need to stub any functions add_action('plugins_loaded', array(&$this, 'initialize_functions')); add_action('acf/render_field_settings', array(&$this, 'add_field_display_label_pro')); add_action('acf/create_field_options', array(&$this, 'add_field_display_label')); add_action('woocommerce_admin_order_data_after_billing_address', array(&$this, 'acf_woocommerce_add_fields_to_order')); } // determind which functions to use, based on what is available public function initialize_functions() { } // NON-PRO ONLY: add a field to the admin interface, that decides whether this field's label gets displayed on the frontend or not public function add_field_display_label($field) { ?> 'checkbox', 'name' => 'fields[' . $field['name'] . '][show_fields_options]', 'value' => isset($field['show_fields_options']) ? $field['show_fields_options'] : 1, 'choices' => array( 'order' => 'Order field', 'email' => 'Email field', ), 'layout' => 'horizontal', )); ?> 'Display on', 'type' => 'checkbox', 'name' => 'show_fields_options', 'prefix' => $field['prefix'], 'value' => isset($field['show_fields_options']) ? $field['show_fields_options'] : 1, 'choices' => array( 'order' => 'Order field', 'email' => 'Email field', ), 'layout' => 'horizontal', 'class' => 'field-display_location' ), 'tr'); } /** * */ public function acf_woocommerce_add_fields_to_order() { $api = ACF_Woo_API::get_instance(); $group_keys = wp_list_pluck($api->get_field_groups(), $api->acf_id_case_sensitive()); foreach ($group_keys as $group_key => $key) { $fields = $api->get_field_group_fields($key); foreach ($fields as $field => $value) { $field_label = $value['label']; $raw_meta = base64_decode(get_post_meta(get_the_ID(), $value['key'], true)); $meta = unserialize($raw_meta); if (is_array($meta)) { //handle repeater, flexible content if (is_array(reset($meta))) { echo ''; foreach ($meta as $row) { echo ''; foreach ($row as $column) { echo ""; } echo ''; } echo '
$column
'; } //handle choice and select else { echo '

' . $field_label . ': ' . implode('; ', $meta) . '

'; } } else { $meta = stripcslashes($meta); echo '

' . $field_label . ': ' . $meta . '

'; } } } } } ACF_Woo_Display::get_instance();