additional->get_fields(); if ( count( $fields ) ) { $order = wc_get_order( $order_id ); foreach ( $fields as $field_id => $field ) { $key = sprintf( '_%s', $field['key'] ); if ( ! empty( $data[ $field['key'] ] ) ) { $value = $data[ $field['key'] ]; if ( 'textarea' == $field['type'] ) { $order->update_meta_data( $key, wp_kses( $value, false ) ); } elseif ( is_array( $value ) ) { $order->update_meta_data( $key, implode( ',', array_map( 'sanitize_text_field', $value ) ) ); } else { $order->update_meta_data( $key, sanitize_text_field( $value ) ); } } } $order->save(); } } public function save_settings() { global $current_section; if ( 'additional' == $current_section ) { woocommerce_update_options( $this->get_settings() ); } } public function get_settings() { return array( array( 'desc_tip' => esc_html__( 'Select the position of the additional fields.', 'woocommerce-checkout-manager' ), 'id' => 'wooccm_additional_position', 'type' => 'select', // 'class' => 'chosen_select', 'options' => array( 'before_billing_form' => esc_html__( 'Before billing form', 'woocommerce-checkout-manager' ), 'after_billing_form' => esc_html__( 'After billing form', 'woocommerce-checkout-manager' ), 'before_order_notes' => esc_html__( 'Before order notes', 'woocommerce-checkout-manager' ), 'after_order_notes' => esc_html__( 'After order notes', 'woocommerce-checkout-manager' ), ), 'default' => 'before_order_notes', ), ); } // Admin Order // --------------------------------------------------------------------------- public function add_order_data( $order ) { Fields_Handler::instance(); $fields = Plugin::instance()->additional->get_fields(); if ( $fields ) { $template = Plugin::instance()->additional->get_template_types(); $options = Plugin::instance()->additional->get_option_types(); $multiple = Plugin::instance()->additional->get_multiple_types(); ?>

$field ) { $key = sprintf( '_%s', $field['key'] ); $value = $order->get_meta( $key, true ); if ( ! $value ) { $value = maybe_unserialize( $order->get_meta( sprintf( '%s', $field['name'] ), true ) ); if ( is_array( $value ) ) { $value = implode( ',', $value ); } $order->update_meta_data( $key, $value ); $order->delete_meta_data( sprintf( '%s', $field['name'] ) ); } if ( $value ) { ?>

save(); ?>
$field ) { if ( in_array( $field['type'], $template ) ) { continue; } $key = sprintf( '_%s', $field['key'] ); $field['id'] = sprintf( '_%s', $field['key'] ); $field['name'] = $field['key']; $field['value'] = null; $field['class'] = join( ' ', $field['class'] ); $field['wrapper_class'] = 'wooccm-premium-field'; $field['value'] = $order->get_meta( $key, true ); if ( ! $field['value'] ) { $field['value'] = maybe_unserialize( $order->get_meta( sprintf( '%s', $field['name'] ), true ) ); if ( is_array( $field['value'] ) ) { $field['value'] = implode( ',', $field['value'] ); } } switch ( $field['type'] ) { case 'textarea': woocommerce_wp_textarea_input( $field ); break; default: $field['type'] = 'text'; woocommerce_wp_text_input( $field ); break; } } ?>
  • |
  • additional->get_fields(); $defaults = Plugin::instance()->additional->get_defaults(); $types = Plugin::instance()->additional->get_types(); $conditionals = Plugin::instance()->additional->get_conditional_types(); $option = Plugin::instance()->additional->get_option_types(); $price = Plugin::instance()->additional->get_price_types(); $multiple = Plugin::instance()->additional->get_multiple_types(); $template = Plugin::instance()->additional->get_template_types(); $disabled = Plugin::instance()->additional->get_disabled_types(); $product_categories = $this->get_product_categories(); $settings = $this->get_settings(); $product_types = wc_get_product_types(); // This type cannot setted because it is not added to to cart unset( $product_types['external'] ); // This type cannot setted because it is not added to to cart. It add every child to cart as simple product unset( $product_types['grouped'] ); $product_subtypes_options = array( 'virtual' => __( 'Virtual', 'woocommerce-checkout-manager' ), 'downloadable' => __( 'Downloadable', 'woocommerce-checkout-manager' ), 'virtual-downloadable' => __( 'Virtual & Downloadable', 'woocommerce-checkout-manager' ), ); $is_billing_shipping = false; include_once WOOCCM_PLUGIN_DIR . 'lib/view/backend/pages/additional.php'; } } }