如何在供应商仪表板上更改银行提款表单字段(IBAN 占位符)

已发表: 2022-04-12

Dokan 有多个支付系统来维护交易过程。 其中之一是“银行转账”。 管理员使用银行转账将佣金直接发送到供应商的账户。 它是一种流行的提款方式。

银行表格

供应商需要使用必要的信息填写默认的银行提款表,以便通过银行转账收取佣金。

但是,根据地区或国家,银行转账的系统可能会发生变化。 有些国家需要您提供 Swift 代码,而有些国家需要 IBAN 号码。 一些国家将 IBAN 号码称为路由号码。

尽管您可以对 Dokan 进行某些调整,但您无法在没有一些自定义的情况下更改 IBAN 占位符等字段。 您需要添加一个简单的代码来调整银行提款表单的表单字段。

我们将向您展示如何自定义 Dokan 的默认银行取款表单字段。

在供应商仪表板中自定义默认银行提款表格的 3 个步骤

银行转账方式字段来自dokan-lite/includes/withdraw-functions.php 文件。 现在没有默认设置来更改标签或删除字段。 您只能添加一些代码来更改标签。 撤回方法注册函数dokan_withdraw_register_methods上有一个过滤器,即dokan_withdraw_methods。 我们将使用这个过滤器来完成这项工作。

  • 第 1 步:安装子主题
  • Step2:在 Functions.Php 中插入代码
  • Step3:从前端检查更改

第 1 步:安装子主题

当您进行任何类型的自定义时,您需要使用您的子主题。 否则,您可能会在更新插件或主题后丢失数据。 因此,如果您的市场上没有,请创建一个儿童主题。

为子主题创建文件夹

第 2 步:在子主题的 Functions.Php 文件中插入代码

打开您的文件夹/查找器并导航到WP-Content–> Themes–> Your Child Theme Name–>Open Functions.php。 复制以下代码。

 <?php /* You can change any field title or remove any feild for the vendor -> settings -> payment -> bank transfer method. Please note that this code need to be placed on your child-theme functions.php file */ add_filter( 'dokan_withdraw_methods', 'wp1923_change_whithdraw_callback', 12 ); function wp1923_change_whithdraw_callback( $methods ) { $methods['bank']['callback'] = 'wp12232_render_bank_html'; $methods ['bank']['title'] = __( 'Wire Transfer', 'dokan-lite' ); //title can be changed as per your need return $methods; } function wp12232_render_bank_html( $store_settings ) { $account_name = isset( $store_settings['payment']['bank']['ac_name'] ) ? $store_settings['payment']['bank']['ac_name'] : ''; $account_number = isset( $store_settings['payment']['bank']['ac_number'] ) ? $store_settings['payment']['bank']['ac_number'] : ''; $bank_name = isset( $store_settings['payment']['bank']['bank_name'] ) ? $store_settings['payment']['bank']['bank_name'] : ''; $bank_addr = isset( $store_settings['payment']['bank']['bank_addr'] ) ? $store_settings['payment']['bank']['bank_addr'] : ''; $routing_number = isset( $store_settings['payment']['bank']['routing_number'] ) ? $store_settings['payment']['bank']['routing_number'] : ''; $iban = isset( $store_settings['payment']['bank']['iban'] ) ? $store_settings['payment']['bank']['iban'] : ''; $swift_code = isset( $store_settings['payment']['bank']['swift'] ) ? $store_settings['payment']['bank']['swift'] : ''; // Get new added values like other one ?> <div class="dokan-form-group"> <div class="dokan-w8"> <input name="settings[bank][ac_name]" value="<?php echo esc_attr( $account_name ); ?>" class="dokan-form-control" placeholder="<?php esc_attr_e( 'Your bank account name', 'dokan-lite' ); ?>" type="text"> </div> </div> <div class="dokan-form-group"> <div class="dokan-w8"> <input name="settings[bank][ac_number]" value="<?php echo esc_attr( $account_number ); ?>" class="dokan-form-control" placeholder="<?php esc_attr_e( 'Your bank account number', 'dokan-lite' ); ?>" type="text"> </div> </div> <div class="dokan-form-group"> <div class="dokan-w8"> <input name="settings[bank][bank_name]" value="<?php echo esc_attr( $bank_name ); ?>" class="dokan-form-control" placeholder="<?php esc_attr_e( 'Name of your bank', 'dokan-lite' ) ?>" type="text"> </div> </div> <div class="dokan-form-group"> <div class="dokan-w8"> <textarea name="settings[bank][bank_addr]" rows="5" class="dokan-form-control" placeholder="<?php esc_attr_e( 'Address of your bank', 'dokan-lite' ) ?>"><?php echo esc_html( $bank_addr ); ?></textarea> </div> </div> <div class="dokan-form-group"> <div class="dokan-w8"> <input name="settings[bank][routing_number]" value="<?php echo esc_attr( $routing_number ); ?>" class="dokan-form-control" placeholder="<?php esc_attr_e( 'Routing number', 'dokan-lite' ) ?>" type="text"> </div> </div> <div class="dokan-form-group"> <div class="dokan-w8"> <input name="settings[bank][iban]" value="<?php echo esc_attr( $iban ); ?>" class="dokan-form-control" placeholder="<?php esc_attr_e( 'IBAN', 'dokan-lite' ) ?>" type="text"> </div> </div> <div class="dokan-form-group"> <div class="dokan-w8"> <input value="<?php echo esc_attr( $swift_code ); ?>" name="settings[bank][swift]" class="dokan-form-control" placeholder="<?php esc_attr_e( 'Swift code', 'dokan-lite' ); ?>" type="text"> </div> </div> <!-- .dokan-form-group --> <!-- add whatever you want --> <?php }

完成编辑后不要忘记保存代码。

第 3 步:刷新您的网站,您会看到标签已更改

保存代码后,返回您的市场并进行一次硬刷新。 然后您会看到银行转账标签已更改,并且一些占位符的文本也已更改 -

IBAN 占位符的更新表格

这是您可以在供应商仪表板中更改默认银行提款表单的方式。

您还可以查看:如何在 Dokan 产品表单中添加新字段。

进行必要的更改并更有效地管理您的供应商

当您拥有像 WordPress 这样的开源平台和像 Dokan 这样的插件时,定制变得很容易。

与其添加插件和妨碍市场的性能,不如使用代码进行自定义。 这将使您的市场高效,并且您将有更多空间来添加您实际需要的插件。

使用上面的代码,您还可以在供应商设置区域将文本名称银行更改为您的银行名称,或者您可能需要将银行转帐更改为电汇。

如果您遇到任何问题,请在评论部分告诉我们。