/** * Display fields for the Customer ID meta for each and every environment, * on the view/edit user page, if this gateway uses Customer ID's * (ie SV_WC_Payment_Gateway::get_customer_id_user_meta_name() does not * return false). * * If only a single environment is defined, the field will be named * "Customer ID". If more than one environment is defined the field will * be named like "Customer ID (Production)", etc to distinguish them. * * NOTE: the plugin id, rather than gateway id, is used here, because it's * assumed that in the case of a plugin having multiple gateways (ie credit * card and eCheck) the customer id will be the same between them. * * @since 3.0.0 * @see SV_WC_Payment_Gateway::get_customer_id_user_meta_name() * @see SV_WC_Payment_Gateway_Admin_User_Edit_Handler::save_user_profile_customer_id_fields() * @param SV_WC_Payment_Gateway $gateway the gateway instance * @param WP_User $user user object for the current edit page */ protected function maybe_add_user_profile_customer_id_fields($gateway, $user) { $environments = $gateway->get_environments(); ?> <table class="form-table"> <?php foreach ($environments as $environment_id => $environment_name) { ?> <tr> <th><label for="<?php printf('_wc_%s_customer_id_%s', $gateway->get_id(), $environment_id); ?> "><?php echo count($environments) > 1 ? sprintf(esc_html__('Customer ID (%s)', 'woocommerce-plugin-framework'), $environment_name) : esc_html__('Customer ID', 'woocommerce-plugin-framework'); ?> </label></th> <td> <input type="text" name="<?php printf('_wc_%s_customer_id_%s', $gateway->get_id(), $environment_id); ?> " value="<?php echo esc_attr($gateway->get_customer_id($user->ID, array('environment_id' => $environment_id, 'autocreate' => false))); ?> " class="regular-text" /><br/> <span class="description"><?php echo count($environments) > 1 ? sprintf(esc_html__('The gateway customer ID for the user in the %s environment. Only edit this if necessary.', 'woocommerce-plugin-framework'), $environment_name) : esc_html__('The gateway customer ID for the user. Only edit this if necessary.', 'woocommerce-plugin-framework'); ?> </span> </td> </tr> <?php } ?> </table> <?php }