Add custom fields to existing form on Dokan

This topic contains 16 reply and 3 voices, and was last updated by Sk 9 years, 7 months ago
Viewing 15 Posts - 1 through 15 (of 16 total)
Author Posts
November 18, 2014 at 7:52 am 30660
Sk Let's help each other. Make this a comunity. Share our successfull customizations, and help on some developments. Please see: http://stackoverflow.com/questions/26985251/add-custom-fields-to-existing-form-on-dokan-wordpress-woocoomerce Anyone know how to do this?
November 20, 2014 at 7:59 am 30821
Gregório Sordi Gregório Sordi

Can anybody give me some light?

November 20, 2014 at 4:00 pm 30853
Sk Sk

Hello,

Have a look on that link. I have answered that.

Thank you.

November 20, 2014 at 6:13 pm 30864
Gregório Sordi Gregório Sordi

Great! Thanks. But this doesn’t update woocommerce user address , i added, update_user_meta( $stoer_id, ‘billing_city’, sanitize_text_field( $_POST[‘billing_city’] ) ); to each post on the save function and i worked!

You are the best, man!

November 21, 2014 at 7:15 am 30890
Gregório Sordi Gregório Sordi

The only thing that is not working is the billing_state. Actually, it was changed with postcode with the original code. i changed that. but billing_state doesn’t update on woocommerce user meta. Other than that it works great.

November 29, 2014 at 3:11 am 31362
Gregório Sordi Gregório Sordi

Shaikat, i really appreciate your answer. Really! But can i ask for one little more thing?

i want to do kind of the same thing, but with a checkbox.

code to show is:

function greglocal($current_user) {
	$store_id = get_current_user_id();
	$local_pickup_enabled = get_user_meta($store_id, 'pv_local_pickup_enabled', true);
?>               <div class="gregcustom dokan-form-group">
                <label class="dokan-w3 dokan-control-label" for="setting_address"><?php _e( 'Local Pickup', 'dokan' ); ?></label>
                <div class="dokan-w5">
                <div class="checkbox">
           <label>             <input name="pv_local_pickup_enabled" type="checkbox"
               id="pv_local_pickup_enabled" class="<?php echo 'id_' . $store_id; ?>" value="1" <?php checked('1', get_user_meta($store_id, 'pv_local_pickup_enabled', true), $echo = true) ?>/>
        <?php
        _e('Enable Local Pickup for the shop products', 'dokan');
        ?></label>
    </div></div>
</div>

<?php } 

add_filter( 'dokan_settings_after_banner', 'greglocal');

I tried to use the method above to save this:


        if (isset($_POST['pv_local_pickup_enabled']) == '1') {
            update_user_meta($user_id, 'pv_local_pickup_enabled', $_POST['pv_local_pickup_enabled']);
        } else {
            update_user_meta($user_id, 'pv_local_pickup_enabled', '0');
        }

but with no success. I feel the answer is right in my face and i’m not seeing it. Can you help me? I’ll buy you a beer.

November 30, 2014 at 6:53 pm 31432
Sekander Badsha Sekander Badsha

Hello Gregorio,

I have notified @Shaikat for your issue. He will review this within tomorrow. 🙂

December 3, 2014 at 12:51 am 31652
Gregório Sordi Gregório Sordi

Any news @Shaikat? =]

December 3, 2014 at 12:48 pm 31697
Sk Sk

Hello Gregório Sordi

Here is your total code.

function endereco( $current_user, $profile_info ) {
	$pv_local_pickup_enabled = isset( $profile_info['pv_local_pickup_enabled'] ) ? esc_attr($profile_info['pv_local_pickup_enabled']) : 'no';
	$billing_city = isset( $profile_info['billing_city'] ) ? $profile_info['billing_city'] : '';
	$billing_postcode = isset( $profile_info['billing_postcode'] ) ? $profile_info['billing_postcode'] : '';
	$billing_state = isset( $profile_info['billing_state'] ) ? $profile_info['billing_state'] : '';
	$billing_address_1 = isset( $profile_info['billing_address_1'] ) ? $profile_info['billing_address_1'] : '';
	?>       

	<div class="gregcustom dokan-form-group">
        <label class="dokan-w3 dokan-control-label" for="setting_address"><?php _e( 'Local Pickup', 'dokan' ); ?></label>
        <div class="dokan-w5">
	        <div class="checkbox">
		           <label>             
			           <input name="pv_local_pickup_enabled" type="checkbox"
			               id="pv_local_pickup_enabled" class="<?php echo 'id_' . $store_id; ?>" value="yes" <?php checked( $pv_local_pickup_enabled, 'yes' ); ?>/>
				        <?php
				        _e('Enable Local Pickup for the shop products', 'dokan');
		        ?></label>
		    </div>
	    </div>
	</div>
	<div class="gregcustom dokan-form-group">
	    <label class="dokan-w3 dokan-control-label" for="setting_address"><?php _e( 'Cidade', 'dokan' ); ?></label>
	    <div class="dokan-w5">
			<input type="text" class="dokan-form-control input-md valid" name="billing_city" id="reg_billing_city" value="<?php echo $billing_city; ?>" />
		</div>
	</div>   
                
	<div class="gregcustom dokan-form-group">
		<label class="dokan-w3 dokan-control-label" for="setting_address"><?php _e( 'Estado', 'dokan' ); ?></label>
		<div class="dokan-w5">
			<input type="text" class="dokan-form-control input-md valid" name="billing_postcode" id="reg_billing_postcode" value="<?php echo $billing_postcode; ?>" />
		</div>
	</div>
                
	<div class="gregcustom dokan-form-group"> 
		<label class="dokan-w3 dokan-control-label" for="setting_address"><?php _e( 'CEP', 'dokan' ); ?></label>
		<div class="dokan-w5">
			<input type="text" class="dokan-form-control input-md valid" name="billing_state" id="reg_billing_state" value="<?php echo $billing_postcode; ?>" />
		</div>
	</div>    
	<div class="gregcustom dokan-form-group">
		<label class="dokan-w3 dokan-control-label" for="setting_address"><?php _e( 'Endereço', 'dokan' ); ?></label>
		<div class="dokan-w5">
			<input type="text" class="dokan-form-control input-md valid" name="billing_address_1" id="reg_billing_address_1" value="<?php echo $billing_address_1; ?>" />
		</div>
	</div>
				
	<?php
}
add_filter( 'dokan_settings_after_banner', 'endereco', 10, 2);

/**
 * Save the extra fields.
 *
 * @param  int  $customer_id Current customer ID.
 *
 * @return void
 */
function save_extra_endereco_fields( $store_id, $dokan_settings ) {

	if (isset($_POST['pv_local_pickup_enabled'])) {
        $dokan_settings['pv_local_pickup_enabled'] = $_POST['pv_local_pickup_enabled'];
    }

	if ( isset( $_POST['billing_city'] ) ) {
		$dokan_settings['billing_city'] = $_POST['billing_city'];
	}

	if ( isset( $_POST['billing_postcode'] ) ) {
		$dokan_settings['billing_postcode'] = $_POST['billing_postcode'];
	}

	if ( isset( $_POST['billing_state'] ) ) {
		$dokan_settings['billing_state'] = $_POST['billing_state'];
	}

	if ( isset( $_POST['billing_address_1'] ) ) {
		$dokan_settings['billing_address_1'] = $_POST['billing_address_1'];
	}
	update_user_meta( $store_id, 'dokan_profile_settings', $dokan_settings );
}

add_action( 'dokan_store_profile_saved', 'save_extra_endereco_fields', 10, 2 );

Note: Please don’t use more than one add_action in a hook for one event.

Thank you.. 🙂

December 3, 2014 at 8:37 pm 31728
Gregório Sordi Gregório Sordi

Shaikat, works great!

many thanks man.

how much is a beer there? Can i donate in paypal? Is it ok with forum regulations?

December 4, 2014 at 11:15 am 31776
Sk Sk This reply has been marked as private.
April 17, 2015 at 9:05 am 41577
Gregório Sordi Gregório Sordi

Hi. Sorry to reopen this post after 4 months, but i discovered an conflit with dokan seller vacation.

when this code is active, specially the function save_extra_endereco_fields, the checkbox for “setting_go_vacation” checkbox is always unchecked. Even if i check it and all works, sellers products are inavailable and $dokan_enable_seller_vacation = get_user_meta( $user_id , ‘dokan_enable_seller_vacation’, true ); is ok (value 1). The checkbox is still unchecked.

That’s a problem because seller will get confused. He is on vacation, but checkbox for go to vacation is unchecked.

Or worse, he is on vacation, then simply save the settings again, since checkbox is unchecked, he will “get back from vacation”.

Can i get some help in this @Shaikat?

April 22, 2015 at 9:03 pm 42056
Gregório Sordi Gregório Sordi

any reply to this issue?

April 23, 2015 at 2:11 pm 42122
Sk Sk

Hello,

Please provide your login details by using this form: http://wedevs.com/provide-login-details/. I will have a look what is going wrong.

Thank you 🙂

April 28, 2015 at 10:08 am 42496
Gregório Sordi Gregório Sordi This reply has been marked as private.
April 30, 2015 at 3:23 pm 42769
Sk Sk

Hello Gregório ,

I didn’t face any problem there. It’s working fine.

Let me know if you face any further problem.

Thank you

Viewing 15 Posts - 1 through 15 (of 16 total)