问题描述
我正在为我的供应商制定自定义提款选项。我在下面有以下代码。输入电话号码即可。但如果我输入一个数字,它不会保存。如果供应商提出提款请求,即使我也无法从管理方面看到。
感谢任何帮助。 示例:我为供应商提款添加了此自定义付款方式。然后我以供应商身份登录并通过电话号码更新我的付款方式。
但是数字或任何输入都没有保存。点击保存按钮后丢失。
我希望它很清楚。
/**
* 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_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;
}```
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)