Viewing 5 replies - 1 through 5 (of 5 total)
  • Nazmul Hassan

    (@nazmulhassann20)

    @ryandesigned,

    Kindly delete the below line from your code to resolve your issue-

    if ( ! class_exists( ‘Dokan_Setup_Wizard’ ) ) {
    require_once DOKAN_INC_DIR . ‘/admin/setup-wizard.php’;
    }

    Cheers!

    Thread Starter ryandesigned

    (@ryandesigned)

    No that didn’t work. I believe it’s deprecated.

    Nazmul Hassan

    (@nazmulhassann20)

    Hello @ryandesigned,

    I just checked and it is working fine. Please make sure that you have used this code.

    Thread Starter ryandesigned

    (@ryandesigned)

    Thank you, I would also like to remove fields from the next steps. I tried to use this code in the same function it doesn’t work either.. Any advice?

    /**
    * Store step.
    */
    public function dokan_setup_store() {
    $store_info = $this->store_info;

    $store_ppp = isset( $store_info[‘store_ppp’] ) ? esc_attr( $store_info[‘store_ppp’] ) : 10;
    $show_email = isset( $store_info[‘show_email’] ) ? esc_attr( $store_info[‘show_email’] ) : ‘no’;
    $address_street1 = isset( $store_info[‘address’][‘street_1’] ) ? $store_info[‘address’][‘street_1’] : ”;
    $address_street2 = isset( $store_info[‘address’][‘street_2’] ) ? $store_info[‘address’][‘street_2’] : ”;
    $address_city = isset( $store_info[‘address’][‘city’] ) ? $store_info[‘address’][‘city’] : ”;
    $address_zip = isset( $store_info[‘address’][‘zip’] ) ? $store_info[‘address’][‘zip’] : ”;
    $address_country = isset( $store_info[‘address’][‘country’] ) ? $store_info[‘address’][‘country’] : ”;
    $address_state = isset( $store_info[‘address’][‘state’] ) ? $store_info[‘address’][‘state’] : ”;

    $country_obj = new WC_Countries();
    $countries = $country_obj->countries;
    $states = $country_obj->states;
    ?>
    <h1><?php _e( ‘Store Setup’, ‘dokan-lite’ ); ?></h1>
    <form method=”post” class=”dokan-seller-setup-form”>
    <table class=”form-table”>
    <tr>
    <th scope=”row”><label for=”store_ppp”><?php _e( ‘Store Product Per Page’, ‘dokan-lite’ ); ?></label></th>
    <td>
    <input type=”text” id=”store_ppp” name=”store_ppp” value=”<?php echo $store_ppp; ?>” />
    </td>
    </tr>
    <tr>
    <th scope=”row”><label for=”address[street_1]”><?php _e( ‘Street’, ‘dokan-lite’ ); ?></label></th>
    <td>
    <input type=”text” id=”address[street_1]” name=”address[street_1]” value=”<?php echo $address_street1; ?>” />
    </td>
    </tr>
    <tr>
    <th scope=”row”><label for=”address[street_2]”><?php _e( ‘Street 2’, ‘dokan-lite’ ); ?></label></th>
    <td>
    <input type=”text” id=”address[street_2]” name=”address[street_2]” value=”<?php echo $address_street2; ?>” />
    </td>
    </tr>
    <tr>
    <th scope=”row”><label for=”address[city]”><?php _e( ‘City’, ‘dokan-lite’ ); ?></label></th>
    <td>
    <input type=”text” id=”address[city]” name=”address[city]” value=”<?php echo $address_city; ?>” />
    </td>
    </tr>
    <th scope=”row”><label for=”address[zip]”><?php _e( ‘Post/Zip Code’, ‘dokan-lite’ ); ?></label></th>
    <td>
    <input type=”text” id=”address[zip]” name=”address[zip]” value=”<?php echo $address_zip; ?>” />
    </td>
    <tr>
    <th scope=”row”><label for=”address[country]”><?php _e( ‘Country’, ‘dokan-lite’ ); ?></label></th>
    <td>
    <select name=”address[country]” class=”wc-enhanced-select country_to_state” id=”address[country]”>
    <?php dokan_country_dropdown( $countries, $address_country, false ); ?>
    </select>
    </td>
    </tr>
    <th scope=”row”><label for=”calc_shipping_state”><?php _e( ‘State’, ‘dokan-lite’ ); ?></label></th>
    <td>
    <input type=”text” id=”calc_shipping_state” name=”address[state]” value=”<?php echo $address_state; ?>” / placeholder=”<?php esc_attr_e( ‘State Name’, ‘dokan-lite’ ); ?>”>
    </td>
    </tr>
    <tr>
    <th scope=”row”><label for=”show_email”><?php _e( ‘Email’, ‘dokan-lite’ ); ?></label></th>
    <td>
    <input type=”checkbox” name=”show_email” id=”show_email” class=”input-checkbox” value=”1″ <?php echo ( $show_email == ‘yes’ ) ? ‘checked=”checked”‘ : ”; ?>/>
    <label for=”show_email”><?php _e( ‘Show email address in store’, ‘dokan-lite’ ); ?></label>
    </td>
    </tr>

    <?php do_action( ‘dokan_seller_wizard_store_setup_field’, $this ); ?>

    </table>
    <p class=”wc-setup-actions step”>
    <input type=”submit” class=”button-primary button button-large button-next store-step-continue” value=”<?php esc_attr_e( ‘Continue’, ‘dokan-lite’ ); ?>” name=”save_step” />
    get_next_step_link() ); ?>” class=”button button-large button-next store-step-skip-btn”><?php _e( ‘Skip this step’, ‘dokan-lite’ ); ?>
    <?php wp_nonce_field( ‘dokan-seller-setup’ ); ?>
    </p>
    </form>
    <script>
    (function($){
    var states = <?php echo json_encode( $states ); ?>;

    $(‘body’).on( ‘change’, ‘select.country_to_state, input.country_to_state’, function() {
    // Grab wrapping element to target only stateboxes in same ‘group’
    var $wrapper = $( this ).closest(‘form.dokan-seller-setup-form’);

    var country = $( this ).val(),
    $statebox = $wrapper.find( ‘#calc_shipping_state’ ),
    $parent = $statebox.closest(‘tr’),
    input_name = $statebox.attr( ‘name’ ),
    input_id = $statebox.attr( ‘id’ ),
    value = $statebox.val(),
    placeholder = $statebox.attr( ‘placeholder’ ) || $statebox.attr( ‘data-placeholder’ ) || ”,
    state_option_text = ‘<?php echo esc_attr__( ‘Select an option…’, ‘dokan-lite’ ); ?>’;

    if ( states[ country ] ) {
    if ( $.isEmptyObject( states[ country ] ) ) {
    $statebox.closest(‘tr’).hide().find( ‘.select2-container’ ).remove();
    $statebox.replaceWith( ‘<input type=”hidden” class=”hidden” name=”‘ + input_name + ‘” id=”‘ + input_id + ‘” value=”” placeholder=”‘ + placeholder + ‘” />’ );

    $( document.body ).trigger( ‘country_to_state_changed’, [ country, $wrapper ] );

    } else {

    var options = ”,
    state = states[ country ];

    for( var index in state ) {
    if ( state.hasOwnProperty( index ) ) {
    options = options + ‘<option value=”‘ + index + ‘”>’ + state[ index ] + ‘</option>’;
    }
    }

    $statebox.closest(‘tr’).show();

    if ( $statebox.is( ‘input’ ) ) {
    // Change for select
    $statebox.replaceWith( ‘<select name=”‘ + input_name + ‘” id=”‘ + input_id + ‘” class=”wc-enhanced-select state_select” data-placeholder=”‘ + placeholder + ‘”></select>’ );
    $statebox = $wrapper.find( ‘#calc_shipping_state’ );
    }

    $statebox.html( ‘<option value=””>’ + state_option_text + ‘</option>’ + options );
    $statebox.val( value ).change();

    $( document.body ).trigger( ‘country_to_state_changed’, [country, $wrapper ] );

    }
    } else {
    if ( $statebox.is( ‘select’ ) ) {

    $parent.show().find( ‘.select2-container’ ).remove();
    $statebox.replaceWith( ‘<input type=”text” class=”input-text” name=”‘ + input_name + ‘” id=”‘ + input_id + ‘” placeholder=”‘ + placeholder + ‘” />’ );

    $( document.body ).trigger( ‘country_to_state_changed’, [country, $wrapper ] );

    } else if ( $statebox.is( ‘input[type=”hidden”]’ ) ) {

    $parent.show().find( ‘.select2-container’ ).remove();
    $statebox.replaceWith( ‘<input type=”text” class=”input-text” name=”‘ + input_name + ‘” id=”‘ + input_id + ‘” placeholder=”‘ + placeholder + ‘” />’ );

    $( document.body ).trigger( ‘country_to_state_changed’, [country, $wrapper ] );

    }
    }

    $( document.body ).trigger( ‘country_to_state_changing’, [country, $wrapper ] );
    $(‘.wc-enhanced-select’).select2();
    });

    $( ‘:input.country_to_state’ ).change();

    })(jQuery)

    </script>
    <?php

    do_action( ‘dokan_seller_wizard_after_store_setup_form’, $this );
    }

    Nazmul Hassan

    (@nazmulhassann20)

    @ryandesigned, This is a separate problem and I have checked but everything is working fine and you have to just insert the second function in the right position. Also, make sure you are removing fields correctly.

    As it is related to custom development for that reason, I am unable to provide more specific support or solution. Kindly play with your code to get a successful output.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Override Store Setup Wizard’ is closed to new replies.