get_id() !== $post->ID ) { $the_subscription = wc_get_order( $post->ID ); } $subscription = $the_subscription; self::init_address_fields(); wp_nonce_field( 'woocommerce_save_data', 'woocommerce_meta_nonce' ); ?>

get_order_number() ) ); ?>

get_user_id() && ( false !== get_userdata( $subscription->get_user_id() ) ) ) { $user_id = absint( $subscription->get_user_id() ); $user = get_user_by( 'id', $user_id ); $user_string = esc_html( $user->display_name ) . ' (#' . absint( $user->ID ) . ' – ' . esc_html( $user->user_email ) . ')'; } WCS_Select2::render( array( 'class' => 'wc-customer-search', 'name' => 'customer_user', 'id' => 'customer_user', 'placeholder' => esc_attr__( 'Search for a customer…', 'woocommerce-subscriptions' ), 'selected' => $user_string, 'value' => $user_id, ) ); ?>

'; if ( $subscription->get_formatted_billing_address() ) { echo '

' . esc_html__( 'Address', 'woocommerce-subscriptions' ) . ':' . wp_kses( $subscription->get_formatted_billing_address(), array( 'br' => array() ) ) . '

'; } else { echo '

' . esc_html__( 'Address', 'woocommerce-subscriptions' ) . ': ' . esc_html__( 'No billing address set.', 'woocommerce-subscriptions' ) . '

'; } foreach ( self::$billing_fields as $key => $field ) { if ( isset( $field['show'] ) && false === $field['show'] ) { continue; } $function_name = 'get_billing_' . $key; if ( is_callable( array( $subscription, $function_name ) ) ) { $field_value = $subscription->$function_name( 'edit' ); } else { $field_value = $subscription->get_meta( '_billing_' . $key ); } echo '

' . esc_html( $field['label'] ) . ': ' . wp_kses_post( make_clickable( esc_html( $field_value ) ) ) . '

'; } echo 'get_payment_method() ) ? ' class="' . esc_attr( $subscription->get_payment_method() ) . '"' : '' ) . '>' . esc_html__( 'Payment Method', 'woocommerce-subscriptions' ) . ':' . wp_kses_post( nl2br( $subscription->get_payment_method_to_display() ) ); // Display help tip if ( '' != $subscription->get_payment_method() && ! $subscription->is_manual() ) { echo wcs_help_tip( sprintf( _x( 'Gateway ID: [%s]', 'The gateway ID displayed on the Edit Subscriptions screen when editing payment method.', 'woocommerce-subscriptions' ), $subscription->get_payment_method() ) ); } echo '

'; echo '
'; // Display form echo '
'; foreach ( self::$billing_fields as $key => $field ) { if ( ! isset( $field['type'] ) ) { $field['type'] = 'text'; } if ( ! isset( $field['id'] ) ) { $field['id'] = '_billing_' . $key; } switch ( $field['type'] ) { case 'select' : woocommerce_wp_select( $field ); break; default : woocommerce_wp_text_input( $field ); break; } } WCS_Change_Payment_Method_Admin::display_fields( $subscription ); echo '
'; do_action( 'woocommerce_admin_order_data_after_billing_address', $subscription ); ?>

'; if ( $subscription->get_formatted_shipping_address() ) { echo '

' . esc_html__( 'Address', 'woocommerce-subscriptions' ) . ':' . wp_kses( $subscription->get_formatted_shipping_address(), array( 'br' => array() ) ) . '

'; } else { echo '

' . esc_html__( 'Address', 'woocommerce-subscriptions' ) . ': ' . esc_html__( 'No shipping address set.', 'woocommerce-subscriptions' ) . '

'; } if ( ! empty( self::$shipping_fields ) ) { foreach ( self::$shipping_fields as $key => $field ) { if ( isset( $field['show'] ) && false === $field['show'] ) { continue; } $function_name = 'get_shipping_' . $key; if ( is_callable( array( $subscription, $function_name ) ) ) { $field_value = $subscription->$function_name( 'edit' ); } else { $field_value = $subscription->get_meta( '_shipping_' . $key ); } echo '

' . esc_html( $field['label'] ) . ': ' . wp_kses_post( make_clickable( esc_html( $field_value ) ) ) . '

'; } } if ( apply_filters( 'woocommerce_enable_order_notes_field', 'yes' == get_option( 'woocommerce_enable_order_comments', 'yes' ) ) && $post->post_excerpt ) { echo '

' . esc_html__( 'Customer Provided Note', 'woocommerce-subscriptions' ) . ': ' . wp_kses_post( nl2br( $post->post_excerpt ) ) . '

'; } echo '
'; // Display form echo '
'; if ( ! empty( self::$shipping_fields ) ) { foreach ( self::$shipping_fields as $key => $field ) { if ( ! isset( $field['type'] ) ) { $field['type'] = 'text'; } if ( ! isset( $field['id'] ) ) { $field['id'] = '_shipping_' . $key; } switch ( $field['type'] ) { case 'select' : woocommerce_wp_select( $field ); break; default : woocommerce_wp_text_input( $field ); break; } } } if ( apply_filters( 'woocommerce_enable_order_notes_field', 'yes' == get_option( 'woocommerce_enable_order_comments', 'yes' ) ) ) { ?>

'; do_action( 'woocommerce_admin_order_data_after_shipping_address', $subscription ); ?>
post_type || empty( $_POST['woocommerce_meta_nonce'] ) || ! wp_verify_nonce( $_POST['woocommerce_meta_nonce'], 'woocommerce_save_data' ) ) { return; } self::init_address_fields(); // Get subscription object. $subscription = wcs_get_subscription( $post_id ); // Ensure there is an order key. if ( ! $subscription->get_order_key() ) { $key = 'wc_' . apply_filters( 'woocommerce_generate_order_key', uniqid( 'order_' ) ); wcs_set_objects_property( $subscription, 'order_key', $key ); } // Update meta update_post_meta( $post_id, '_customer_user', absint( $_POST['customer_user'] ) ); // Handle the billing fields. foreach ( self::$billing_fields as $key => $field ) { $field['id'] = isset( $field['id'] ) ? $field['id'] : "_billing_{$key}"; if ( ! isset( $_POST[ $field['id'] ] ) ) { continue; } wcs_set_objects_property( $subscription, $field['id'], wc_clean( $_POST[ $field['id'] ] ) ); } // Handle the shipping fields. foreach ( self::$shipping_fields as $key => $field ) { $field['id'] = isset( $field['id'] ) ? $field['id'] : "_shipping_{$key}"; if ( ! isset( $_POST[ $field['id'] ] ) ) { continue; } wcs_set_objects_property( $subscription, $field['id'], wc_clean( $_POST[ $field['id'] ] ) ); } try { WCS_Change_Payment_Method_Admin::save_meta( $subscription ); if ( 'cancelled' == $_POST['order_status'] ) { $subscription->cancel_order(); } else { $subscription->update_status( $_POST['order_status'], '', true ); } } catch ( Exception $e ) { // translators: placeholder is error message from the payment gateway or subscriptions when updating the status wcs_add_admin_notice( sprintf( __( 'Error updating some information: %s', 'woocommerce-subscriptions' ), $e->getMessage() ), 'error' ); } do_action( 'woocommerce_process_shop_subscription_meta', $post_id, $post ); } }