Showing COVID-19 notice on the vendor store page – Dokan Multivendor

Due to COVID-19, each of your marketplace vendors is facing problems to deliver the product or processing order from customer. Just think that if your vendor could show a notice to the customer on their store page then customer satisfaction could remain the same or customers won’t be dissatisfied.

You might be thinking that how you can add a notice for each vendor separately. Well, it is pretty simple. Keep reading this blog till the end to know 😀

How to show notice on store page?

It can be done easily if we can –

  1. Add a new field on vendor settings called “Store Notice”
  2. Allow vendor to upload image with the notice
  3. Show the notice underneath the banner of vendor’s own store page.

To get all of the above things you do not need to worry, just you have to install a child-theme and you need to paste the below code on your child-theme functions.php file:

/* Store notice field seller settings */

add_filter( 'dokan_settings_form_bottom', 'extra_fields', 10, 2);
function extra_fields( $current_user, $profile_info ){
   $booth_news= get_user_meta( $current_user, 'booth_news', true );
?>
     <div class="gregcustom dokan-form-group">
            <label class="dokan-w3 dokan-control-label" for="setting_address">
                <?php _e( 'Store Notice', 'dokan' ); ?>
            </label>

                <div class="dokan-w8 dokan-text-left">
                        <?php
                            $booth_news_args = array(
                                'editor_height' => 200,
                                'media_buttons' => true,
                                'teeny'         => true,
                                'quicktags'     => false
                            );
                            wp_editor( $booth_news, 'booth_news', $booth_news_args );
                        ?>
            </div>


<?php
}
/* Saving the booth news field */
add_action( 'dokan_store_profile_saved','save_extra_fields', 10 );

    function save_extra_fields( $store_id ) {
         if ( ! $store_id ) {
            return;
        }

        if ( ! isset( $_POST['booth_news'] ) ) {
            return;
        }

        update_user_meta( $store_id, 'booth_news', $_POST['booth_news'] );
    
    }

/*Showing extra field data on the store page*/

add_action( 'dokan_store_profile_frame_after','custom_side_bar',10,2);

function custom_side_bar( $store_user, $store_info ){
    $booth_news = get_user_meta( $store_user->ID, 'booth_news', true );
   

?>
        <?php if ( !empty( $booth_news ) ) { ?>
            <div class="dokan-store-sidebar">
                   <aside class="widget">
                        <h3 class="widget-title"><?php _e( 'Notice', 'dokan' ); ?></h3>
                            <?php echo  wpautop( $booth_news ); ?>
                     </aside>
            </div>
        <?php } ?>


        <?php
}

After adding the above code, your vendor will get a new field on their Dashboard -> Settings

Store Notice Field on Vendor Dashboard

Now, save the settings and visit the store page, you will see the Notice below the Store banner :

Vendor Store page

I hope this quick tips will help your vendor to establish good relationship with their customers.

Insert on Elementor Widget for Store Page

If you are using Elementor to build the vendor store page then this is for you.

Add the below code on your child-theme functions.php file –

add_shortcode( 'store_booth_news', 'dokan_custom_store_booth_news',11 );

function dokan_custom_store_booth_news() {
    $vendor = dokan()->vendor->get( get_query_var( 'author' ) );
    echo $vendor->get_meta( 'booth_news', true );    
}

Now, add short-code widget on the vendor store page and use this short-code [store_booth_news] to show the notice 🙂

Be the first to reply

Leave a Reply

Your email address will not be published. Required fields are marked *