SHOW THE CREATE DATE AND YEAR OF THE VENDOR IN VENDOR PROFILE PAGE

We are badly hit by super cyclone Amphan. Our response will get delayed!

Multi Vendor Marketplace Plugin | WCFM Marketplace Forums WC Vendors SHOW THE CREATE DATE AND YEAR OF THE VENDOR IN VENDOR PROFILE PAGE

This topic contains 20 replies, has 4 voices, and was last updated by Avatar Sushobhan 4 months, 2 weeks ago.

  • Author
    Posts
  • #92254
    Avatar
    karl.deligero
    Participant

    Hi,

    It is possible to show the Create Date and Year of the vendor on their profile page?

    Thank You

  • #92561
    Avatar
    Sushobhan
    Keymaster

    You can fetch the creation date of any WordPress user, this includes vendors as well, by the following two lines

    $user_data = get_userdata(get_current_user_id());
    $registered_date = $user_data->user_registered;

    The first line is fetching the currently logged in users data and the second line extracts the registration date out of it.
    By the way, in which position of the profile page, you want to show this detail?

  • #92895
    Avatar
    kpetty.iccs
    Participant

    where can these two lines be added

  • #92920
    Avatar
    Sushobhan
    Keymaster

    At first you need to tell me where you want to show this information. Share me the vendor profile image after marking your the position. Based on that I can suggest you the appropriate hook or filter name. In that function body you will need to add those two lines.

  • #92937
    Avatar
    karl.deligero
    Participant

    Hi, I want to show this in my vendor profile page. See the attached image. By the way, I use my elementor to integrate my vendor page

    Attachments:
    You must be logged in to view attached files.
  • #92963
    Avatar
    Sushobhan
    Keymaster

    You cannot add PHP code to Elementor, as it is not supported. Instead you can use shortcodes, there is an Elementor block for that. Use the following shortcode to get your desired result –
    [wcfm_store_info id='' data='register_on']

  • #93041
    Avatar
    karl.deligero
    Participant

    Hi,

    Thank You it’s worth by the way. But I want is not only the specific date but the term “Joined 1 month ago“see attached image.

    Note: The words Joined 1y 10 months are placeholder only.

    Attachments:
    You must be logged in to view attached files.
  • #93083
    Avatar
    Sushobhan
    Keymaster

    try using the following code –

    function vendor_registration_date_shortcode( $attr ) {
        global $post;
        $store_id = '';
        if ( isset( $attr['id'] ) && ! empty( $attr['id'] ) ) {
            $store_id = absint( $attr['id'] );
        }
        if ( wcfm_is_store_page() ) {
            $wcfm_store_url = get_option( 'wcfm_store_url', 'store' );
            $store_name = apply_filters( 'wcfmmp_store_query_var', get_query_var( $wcfm_store_url ) );
            $store_id = 0;
            if ( ! empty( $store_name ) ) {
                $store_user = get_user_by( 'slug', $store_name );
                $store_id = $store_user->ID;
            }
        }
        if ( is_product() ) {
            $store_id = $post->post_author;
        }
        if( !$store_id ) return;
        $register_on = abs( get_user_meta( $store_id, 'wcfm_register_on', true ) );
        $today = strtotime( "now" );
        $diff = abs( $today - $register_on );
        $years = floor( $diff / (365 * 24 * 60 * 60) );
        $months = floor( ($diff - $years * 365 * 24 * 60 * 60) / (30 * 24 * 60 * 60) );
        $days = floor( ($diff - $years * 365 * 24 * 60 * 60 - $months * 30 * 24 * 60 * 60) / (24 * 60 * 60) );
        $total_duration = '';
        if ( $years || $months || $days ) {
            if ( $years )
                $total_duration .= sprintf( _n( '%s year ', '%s years ', $years ), $years );
            if ( $months )
                $total_duration .= sprintf( _n( '%s month ', '%s months ', $months ), $months );
            if ( $days )
                $total_duration .= sprintf( _n( '%s day ', '%s days ', $days ), $days );
            return sprintf( 'Joined %sago', $total_duration );
        }
        return 'Joined Today';
    }
    
    // register shortcode
    add_shortcode( 'vendor_registration_date', 'vendor_registration_date_shortcode' );

    Add this code to your child theme’s functions.php
    In case you do not have child theme then add code using this plugin – https://wordpress.org/plugins/code-snippets/

    In the Elementor code block use the following shortcode –
    [vendor_registration_date id=”]

  • #93425
    Avatar
    karl.deligero
    Participant

    AWESOME IT’S WORK. THANKS A LOT 🙂

  • #93429
    Avatar
    karl.deligero
    Participant

    Btw I have 2 more problems encounter in my Vendor Profile Page. The First thing is the “Overall Vendor Star Count Rating” of the product of the vendor. For example, Product 1 has 5-star rates and Product 2 also 5-star rated. The star rate count in the pro is the GWA or General Weighted Average? See the 1st attached image for example. The Second is the following and the followers the problem is I want to count also how many the following or followers of the Vendor see the 2nd attached image. Thanks a Lot

    Attachments:
    You must be logged in to view attached files.
  • #93870
    Avatar
    Sushobhan
    Keymaster

    Hello, There is no direct hook of filter to achieve this. You need to custom code it.

  • #94579
    Avatar
    karl.deligero
    Participant

    Hi

    I do custom code in my themes I want is the value only of the followers. See the attached image.
    Only the number that I post here.

    Thank You So Much!

    Attachments:
    You must be logged in to view attached files.
  • #95086
    Avatar
    Sushobhan
    Keymaster

    Hi,
    If you want only the followers count of a vendor then you can use the following snippet –

    $followers_arr = get_user_meta( $vendor_id, '_wcfm_followers_list', true ); //fetch followers data from user_meta
    if( $followers_arr && is_array( $followers_arr ) ) {
    	$followers = count( $followers_arr ); //count of the followers
    }

    Thanks!

  • #95960
    Avatar
    karl.deligero
    Participant

    Hi,

    Where can I put this code? and how I integrated it into my Elementor Page?

    Thanks

  • #95993
    Avatar
    Sushobhan
    Keymaster

    Create a shortcode like we did for vendor registration date and use it the same way.

  • #99979
    Avatar
    raul.flores.arenas
    Participant

    hi, i have the same problem, but im want the custom information added in the settings to vendor registration, in my case, university and years of experience, i want show this in the profile, maybe in the filtre too.

    i hope you can help me, i going to attach a few images, we are using the multivendors plugin.

    thanks a lot

    Raul Flores

    Attachments:
    You must be logged in to view attached files.
  • #101354
    Avatar
    Sushobhan
    Keymaster

    Hi,
    Sorry for the delayed response. You can get the custom field values using the following shortcode snippet –

    function vendor_registration_fields_shortcode( $attr ) {
        global $post;
        if ( empty( $attr['field'] ) ) return;
        $field_name = sanitize_title( $attr['field'] );
        $store_id = '';
        if ( isset( $attr['id'] ) && ! empty( $attr['id'] ) ) {
            $store_id = absint( $attr['id'] );
        }
        if ( wcfm_is_store_page() ) {
            $wcfm_store_url = get_option( 'wcfm_store_url', 'store' );
            $store_name = apply_filters( 'wcfmmp_store_query_var', get_query_var( $wcfm_store_url ) );
            $store_id = 0;
            if ( ! empty( $store_name ) ) {
                $store_user = get_user_by( 'slug', $store_name );
                $store_id = $store_user->ID;
            }
        }
        if ( is_product() ) {
            $store_id = $post->post_author;
        }
        if ( ! $store_id ) return;
        $custom_fields = get_user_meta( $store_id, 'wcfmvm_custom_infos', true );
        if ( empty( $custom_fields[$field_name] ) ) return;
        return $custom_fields[$field_name];
    }
    
    // register shortcode
    add_shortcode( 'vendor_registration_fields', 'vendor_registration_fields_shortcode' );

    You can use this shortcode like this-
    [vendor_registration_fields id='{vendor id/ store id}’ field=’label name of the field’]

  • #101377
    Avatar
    raul.flores.arenas
    Participant

    thanks a lot for the answer, with this i can filter too?, i mean i can put this in the filter of vendors?

    thank you
    Raul Flores

  • #101455
    Avatar
    Sushobhan
    Keymaster

    Yes, you can. But you have to custom code it. As starting point, refer to ‘wp_ajax_wcfmmp_stores_list_search’ ajax action.

  • #101557
    Avatar
    raul.flores.arenas
    Participant

    thanks for the anwser, i understand where and how i can use tha refer, but if you can help us with the code too will be great, because we are having problems with that.

    thank you
    Raul Flores

  • #101991
    Avatar
    Sushobhan
    Keymaster

    In that case, please contact us here for the purpose – https://wclovers.com/woocommerce-multivendor-customization/

The topic ‘SHOW THE CREATE DATE AND YEAR OF THE VENDOR IN VENDOR PROFILE PAGE’ is closed to new replies.