wordpress - Dokan pro 插件:添加自定义提款选项但数据不保存
问题描述
我正在为我的供应商制作自定义提款选项。我在下面有以下代码。输入电话号码就可以了。但是,如果我输入一个数字,它不会保存。即使供应商提出提款请求,我也无法从管理员方面看到。
任何帮助表示赞赏。示例:我为供应商提款添加了这种自定义付款方式。然后我以供应商身份登录并通过电话号码更新我的付款方式。
但是数字或任何输入都没有保存。单击保存按钮后它丢失了。
甚至我可以从管理员端提款页面看到电话号码。详细信息 col 为空。
我希望这很清楚。
/**
* Get default to withdrawing methods
*
* @return array
*/
function add_custom_withdraw_methods( $methods ){
$methods['payment_gateway_id'] = array(
'title' => __( 'Payment Gateway Name', 'dokan-lite' ),
'callback' => 'dokan_withdraw_method_dagpay'
);
return $methods;
}
/**
* Callback for Skrill in store settings
*
* @global WP_User $current_user
* @param array $store_settings
*/
function dokan_withdraw_method_dagpay( $store_settings ) {
global $current_user;
$phone = isset( $store_settings['payment']['payment_gateway_id']['phone'] ) ? esc_attr( $store_settings['payment']['payment_gateway_id']['phone'] ) : '' ;
?>
<div class="dokan-form-group">
<div class="dokan-w8">
<div class="dokan-input-group">
<span class="dokan-input-group-addon"><?php esc_html_e( 'Phone Number', 'dokan-lite' ); ?></span>
<input value="<?php echo esc_attr( $phone ); ?>" name="settings[payment_gateway_id][phone]" class="dokan-form-control phone" placeholder="+0194397933243" type="text">
</div>
</div>
</div>
<?php
}
add_action( 'dokan_store_profile_saved', 'save_withdraw_method_dagpay', 10, 2 );
/**
* Save store settings
*
* @return void
*/
function save_withdraw_method_dagpay( $store_id, $dokan_settings ){
$existing_dokan_settings = get_user_meta( $store_id, 'dokan_profile_settings', true );
$prev_dokan_settings = ! empty( $existing_dokan_settings ) ? $existing_dokan_settings : array();
$post_data = wp_unslash( $_POST );
if( wp_verify_nonce( $post_data['_wpnonce'], 'dokan_payment_settings_nonce' ) ){
if ( isset( $post_data['settings']['payment_gateway_id'] ) ) {
$dokan_settings['payment']['payment_gateway_id'] = array(
'phone' => $post_data['settings']['payment_gateway_id']['phone'], // validate phone number here
);
}
}
$dokan_settings = array_merge( $prev_dokan_settings, $dokan_settings );
update_user_meta( $store_id, 'dokan_profile_settings', $dokan_settings );
}
add_filter( 'dokan_get_seller_active_withdraw_methods', 'active_payment_methods' );
/**
* Get active withdraw methods for the seller.
* @return array
*/
function active_payment_methods( $active_payment_methods ){
$payment_methods = get_user_meta( dokan_get_current_user_id(), 'dokan_profile_settings' );
$payment_gateway = isset( $payment_methods[0]['payment']['payment_gateway_id']['phone'] ) && $payment_methods[0]['payment']['payment_gateway_id']['phone'] !== '' ? 'payment_gateway_id' : '';
if( $payment_gateway !== '' ){
array_push( $active_payment_methods, 'payment_gateway_id' );
}
return $active_payment_methods;
}```
解决方案
推荐阅读
- javascript - 尝试使用 CDN 中的 Vue.js 库,但出现 Uncaught SyntaxError: Unexpected identifier
- php - 使用 $_GET 参数删除 MySQL 数据库的行
- c - 使用空格检测单词或句子将摩尔斯电码解码为文本的 C 程序
- python - 从客户 ID 购买日期到 python 中 ID 的购买间隔天数
- logging - 我无法按日期设置日志?如何在 log4j.prop 文件中设置 bydate?我已经应用了这些东西,但没有每天生成
- javascript - 完全动态地从 JSON 创建表
- ruby - 转换三个字节、二进制补码、有符号整数
- javascript - 姜戈;如何将javascript连接到数据库?
- c# - 在 C 和 C# 之间传递指向数组的指针
- c - 除非在主项目中使用,否则静态库中的链接错误