Last active
September 19, 2023 16:10
-
-
Save nayemDevs/b629d4b1c27c794bdfb729ce6927069e to your computer and use it in GitHub Desktop.
Add extra field on vendor settings area and show the field value on the store banner
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*Extra field on the seller settings and show the value on the store banner -Dokan*/ | |
// Add extra field in seller settings | |
add_filter( 'dokan_settings_form_bottom', 'extra_fields', 10, 2); | |
function extra_fields( $current_user, $profile_info ){ | |
$seller_url= isset( $profile_info['seller_url'] ) ? $profile_info['seller_url'] : ''; | |
?> | |
<div class="gregcustom dokan-form-group"> | |
<label class="dokan-w3 dokan-control-label" for="setting_address"> | |
<?php _e( 'Website', 'dokan' ); ?> | |
</label> | |
<div class="dokan-w5"> | |
<input type="text" class="dokan-form-control input-md valid" name="seller_url" id="reg_seller_url" value="<?php echo $seller_url; ?>" /> | |
</div> | |
</div> | |
<?php | |
} | |
//save the field value | |
add_action( 'dokan_store_profile_saved', 'save_extra_fields', 15 ); | |
function save_extra_fields( $store_id ) { | |
$dokan_settings = dokan_get_store_info($store_id); | |
if ( isset( $_POST['seller_url'] ) ) { | |
$dokan_settings['seller_url'] = $_POST['seller_url']; | |
} | |
update_user_meta( $store_id, 'dokan_profile_settings', $dokan_settings ); | |
} | |
// show on the store page | |
add_action( 'dokan_store_header_info_fields', 'save_seller_url', 10); | |
function save_seller_url($store_user){ | |
$store_info = dokan_get_store_info( $store_user); | |
?> | |
<?php if ( isset( $store_info['seller_url'] ) && !empty( $store_info['seller_url'] ) ) { ?> | |
<i class="fa fa-globe"></i> | |
<a href="<?php echo esc_html( $store_info['seller_url'] ); ?>"><?php echo esc_html( $store_info['seller_url'] ); ?></a> | |
<?php } ?> | |
<?php | |
} |
Hello, I would like to add extra fields as shown in the attachment. I'm using Dokan Pro, and I want sellers to be able to add custom extra prices and options they define themselves on their product submission pages, just like in the image. For example, if it's a restaurant selling hamburgers, I want them to be able to add options like extra ketchup, hot sauce, etc., along with their respective prices. If you could assist me on how to achieve this, I would appreciate it. https://tinypic.host/images/2023/08/28/IMG_3722.png
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello,
I want to add multiple fields for vendors. But I don't know how to edit the code. How can I edit the code for each new field? I need 4 different fields.
Thank you