Support » Plugin: Dokan - Best WooCommerce Multivendor Marketplace Solution - Build Your Own Amazon, eBay, Etsy » Add a new payment method
Add a new payment method
-
Hello @onlinerir,
You have added a new gateway which is working fine but this gateway needs to be added as a withdraw method for the vendor. Else, a vendor would not be able to insert their cart-to-cart gateway details.
You may need to customize Dokan plugin to add your own withdraw method. Please open
dokan-plugin/includes/withdraw-function.php
. In this file you will get this filter-apply_filters( 'dokan_withdraw_methods', $methods );
Now, you can use this filter to add a new withdraw methods.
Hello
I did all the work
<?php
// add custom method
function dokan_withdraw_add_methods_by_onliner($methods){if ( dokan_get_option( 'add_method_payment_cart_to_cart', 'other_setting_tab_by_onliner', 'on' ) == 'on' ){
$methods['cart_to_cart'] = array(
'title' => __( 'Cart to cart', 'dokan-lite' ),
'callback' => 'dokan_withdraw_method_cart_to_cart'
);
}return $methods;
}
add_filter('dokan_withdraw_methods', 'dokan_withdraw_add_methods_by_onliner');
/************************************************************************/
function dokan_withdraw_method_cart_to_cart($store_settings) {
$account_name = isset( $store_settings['payment']['cart_to_cart']['ac_namex'] ) ? esc_attr( $store_settings['payment']['cart_to_cart']['ac_namex'] ) : '';
$account_number = isset( $store_settings['payment']['cart_to_cart']['ac_numberx'] ) ? esc_attr( $store_settings['payment']['cart_to_cart']['ac_numberx'] ) : '';
$bank_name = isset( $store_settings['payment']['cart_to_cart']['bank_namex'] ) ? esc_attr( $store_settings['payment']['cart_to_cart']['bank_namex'] ) : '';
?>
<div class="dokan-form-group">
<div class="dokan-w8">
<input name="settings[cart_to_cart][ac_namex]" value="<?php echo $account_name; ?>" class="dokan-form-control" placeholder="your name" type="text">
</div>
</div><div class="dokan-form-group">
<div class="dokan-w8">
<input name="settings[cart_to_cart][ac_numberx]" value="<?php echo $account_number; ?>" class="dokan-form-control" placeholder="number cart" type="number">
</div>
</div><div class="dokan-form-group">
<div class="dokan-w8">
<input name="settings[cart_to_cart][bank_namex]" value="<?php echo $bank_name; ?>" class="dokan-form-control" placeholder="bank name" type="text">
</div>
</div>
<?php
}
/************************************************************************/
function save_dokan_withdraw_method_cart_to_cart( $store_id, $dokan_settings ){if ( isset( $_POST['settings']['cart_to_cart'] ) ) {
$cart_to_cart = $_POST['settings']['cart_to_cart'];
$dokan_settings['payment']['cart_to_cart'] = array(
'ac_namex' => $cart_to_cart['ac_namex'] ,
'ac_numberx' => $cart_to_cart['ac_numberx'] ,
'bank_namex' => $cart_to_cart['bank_namex'] ,
);
}
update_user_meta( $store_id, 'dokan_profile_settings', $dokan_settings );
}
add_action('dokan_store_profile_saved', 'save_dokan_withdraw_method_cart_to_cart',999 ,2 );
/************************************************************************/
add_filter('dokan_get_seller_active_withdraw_methods', function($active_payment_methods){$user_id = get_current_user_id();
$dokan_settings = get_user_meta( $user_id, 'dokan_profile_settings', true );
if ( $dokan_settings['payment']['cart_to_cart']['ac_namex'] != '' && $dokan_settings['payment']['cart_to_cart']['ac_numberx'] != '' && $dokan_settings['payment']['cart_to_cart']['bank_namex'] != '' )
array_push( $active_payment_methods, 'cart_to_cart' );return $active_payment_methods;
});
But I just can not display account info:
<?php// add custom method
function dokan_withdraw_add_methods_by_onliner($methods){if ( dokan_get_option( 'add_method_payment_cart_to_cart', 'other_setting_tab_by_onliner', 'on' ) == 'on' ){
$methods['cart_to_cart'] = array(
'title' => __( 'Cart to cart', 'dokan-lite' ),
'callback' => 'dokan_withdraw_method_cart_to_cart'
);
}return $methods;
}
add_filter('dokan_withdraw_methods', 'dokan_withdraw_add_methods_by_onliner');
/************************************************************************/
function dokan_withdraw_method_cart_to_cart($store_settings) {
$account_name = isset( $store_settings['payment']['cart_to_cart']['ac_namex'] ) ? esc_attr( $store_settings['payment']['cart_to_cart']['ac_namex'] ) : '';
$account_number = isset( $store_settings['payment']['cart_to_cart']['ac_numberx'] ) ? esc_attr( $store_settings['payment']['cart_to_cart']['ac_numberx'] ) : '';
$bank_name = isset( $store_settings['payment']['cart_to_cart']['bank_namex'] ) ? esc_attr( $store_settings['payment']['cart_to_cart']['bank_namex'] ) : '';
?>
<div class="dokan-form-group">
<div class="dokan-w8">
<input name="settings[cart_to_cart][ac_namex]" value="<?php echo $account_name; ?>" class="dokan-form-control" placeholder="your name" type="text">
</div>
</div><div class="dokan-form-group">
<div class="dokan-w8">
<input name="settings[cart_to_cart][ac_numberx]" value="<?php echo $account_number; ?>" class="dokan-form-control" placeholder="number cart" type="number">
</div>
</div><div class="dokan-form-group">
<div class="dokan-w8">
<input name="settings[cart_to_cart][bank_namex]" value="<?php echo $bank_name; ?>" class="dokan-form-control" placeholder="bank name" type="text">
</div>
</div>
<?php
}
/************************************************************************/
function save_dokan_withdraw_method_cart_to_cart( $store_id, $dokan_settings ){if ( isset( $_POST['settings']['cart_to_cart'] ) ) {
$cart_to_cart = $_POST['settings']['cart_to_cart'];
$dokan_settings['payment']['cart_to_cart'] = array(
'ac_namex' => $cart_to_cart['ac_namex'] ,
'ac_numberx' => $cart_to_cart['ac_numberx'] ,
'bank_namex' => $cart_to_cart['bank_namex'] ,
);
}
update_user_meta( $store_id, 'dokan_profile_settings', $dokan_settings );
}
add_action('dokan_store_profile_saved', 'save_dokan_withdraw_method_cart_to_cart',999 ,2 );
/************************************************************************/
add_filter('dokan_get_seller_active_withdraw_methods', function($active_payment_methods){$user_id = get_current_user_id();
$dokan_settings = get_user_meta( $user_id, 'dokan_profile_settings', true );
if ( $dokan_settings['payment']['cart_to_cart']['ac_namex'] != '' && $dokan_settings['payment']['cart_to_cart']['ac_numberx'] != '' && $dokan_settings['payment']['cart_to_cart']['bank_namex'] != '' )
array_push( $active_payment_methods, 'cart_to_cart' );return $active_payment_methods;
});
Hello,
You have to pull the method details on the backend too. The withdraw listing of the backend has been done via vue.js. You can check
dokan-lite/assets/js/vue-admin.js
file and check thisgetPaymentDetails
.As it’s a custom development related query for that reason I am unable to provide the full integration code/support.
thanks
But I do not know how to work with vue.js
how to customise getPaymentDetails
Please help me.I do not wanna edit the core js plugin directly
Hello @onlinerir,
If you are unable to add then you can hire a developer to do this for you. I can only help you with the default functionality of this plugin.
- The topic ‘Add a new payment method’ is closed to new replies.