Join our new community forum for support & discussion

Join Now

Home Support Themes ExpertHive Geolocation for vendors

Geolocation for vendors

  • Author
    Posts
  • Terry_tip

    Hello team, i know that the Geolocation support for vendors is on the way, but is there some other way to implement this? With another pluging from another developer, etc?

    My team and I are very happy with the Experthive theme, the hivepress and markeplace plugins, so thanks A LOT for the support!

    yevhen developer

    Sorry, there is no simple code snippet for this, but I can provide a code snippet for adding the Location field to the vendor profiles – the location will be saved, but there will be no location search and display. Please let me know if this works for you, this way you can start collecting locations before this feature is implemented.

    Terry_tip

    Ok Yevhen i’ll like to try that snipet. Thanks for the answer.

    Terry_tip

    I have another question Yven, i would like to hide the List a Service Button, just hide it without disabling new announces, and put a List Service button or link inside the vendor dashboard.

    For example:

    https://imagizer.imageshack.com/img924/5927/DczsDl.png

    Thanks!!

    yevhen developer

    1) Please try this PHP snippet as said above

    add_filter( 
    	'hivepress/v1/models/vendor/attributes', 
    	function ( $attributes ) {
    
    		// Get countries.
    		$countries = array_filter( (array) get_option( 'hp_geolocation_countries' ) );
    
    		return array_merge(
    			$attributes,
    			[
    				'latitude'  => [
    					'editable'     => true,
    					'searchable'   => true,
    
    					'edit_field'   => [
    						'type' => 'latitude',
    					],
    				],
    
    				'longitude' => [
    					'editable'     => true,
    					'searchable'   => true,
    
    					'edit_field'   => [
    						'type' => 'longitude',
    					],
    				],
    
    				'location'  => [
    					'editable'     => true,
    					'searchable'   => true,
    
    					'edit_field'   => [
    						'label'     => esc_html__( 'Location', 'hivepress-geolocation' ),
    						'type'      => 'location',
    						'countries' => $countries,
    						'_order'    => 25,
    					],
    				],
    			]
    		);
    	},
    );
    
    add_filter( 
    	'hivepress/v1/models/vendor', 
    	function($model){
    		$attributes = hivepress()->attribute->get_attributes( 'vendor' );
    
    		foreach ( [ 'latitude', 'longitude' ] as $field ) {
    			if ( isset( $attributes[ $field ] ) ) {
    				$model['fields'][ $field ] = $attributes[ $field ]['edit_field'];
    
    				$model['fields'][ $field ]['_external'] = true;
    			}
    		}
    
    		return $model;
    	},
    );

    2) It is possible to hide the header button with this CSS snippet:

    .header-navbar .hp-menu__item--listing-submit{
    	display: none;
    }

    Adding a custom button to the dashboard page is possible, but requires template customizations, if you are familiar with basic code changes please check this tutorial https://youtu.be/LkojYp-8uwY

    Also, if direct vendor registration is disabled in settings, users will not be able to add listings since the dashboard and listings pages appear only if the user already has at least 1 listing.

    Terry_tip

    Thanks Yhven, i’ll try the tutorial!

    Terry_tip

    Hi Yheven, im facing a new problem, i used the code snipet to add the Location field to the vendor profiles, but that field now appears between the name field and the last name field 🙁

    I need to add it below the last name field.

    yevhen developer

    Please try this PHP snippet instead. It puts location field below last name field

    add_filter( 
    	'hivepress/v1/models/vendor/attributes', 
    	function ( $attributes ) {
    
    		// Get countries.
    		$countries = array_filter( (array) get_option( 'hp_geolocation_countries' ) );
    
    		return array_merge(
    			$attributes,
    			[
    				'latitude'  => [
    					'editable'     => true,
    					'searchable'   => true,
    
    					'edit_field'   => [
    						'type' => 'latitude',
    					],
    				],
    
    				'longitude' => [
    					'editable'     => true,
    					'searchable'   => true,
    
    					'edit_field'   => [
    						'type' => 'longitude',
    					],
    				],
    
    				'location'  => [
    					'editable'     => true,
    					'searchable'   => true,
    
    					'edit_field'   => [
    						'label'     => esc_html__( 'Location', 'hivepress-geolocation' ),
    						'type'      => 'location',
    						'countries' => $countries,
    						'_order'    => 35,
    					],
    				],
    			]
    		);
    	},
    );
    
    add_filter( 
    	'hivepress/v1/models/vendor', 
    	function($model){
    		$attributes = hivepress()->attribute->get_attributes( 'vendor' );
    
    		foreach ( [ 'latitude', 'longitude' ] as $field ) {
    			if ( isset( $attributes[ $field ] ) ) {
    				$model['fields'][ $field ] = $attributes[ $field ]['edit_field'];
    
    				$model['fields'][ $field ]['_external'] = true;
    			}
    		}
    
    		return $model;
    	},
    );
    Terry_tip

    Thanks a lot Yevhen!

    fsimoni

    Hi,
    I’m interested too, but when I insert this snippet in functions.php no Map appear on vendor’s page
    Why?
    What’s mistake?

    Federico

    ihor developer

    This is just a temporary fix that adds the location field to vendor profiles, it doesn’t add all the features like the location search and maps (you can use this snippet to start collecting locations now, and after this feature is added the map will appear since locations are already stored in the DB).

    fsimoni

    Ah ok ok

    Tnx Federico

Viewing 12 posts - 1 through 12 (of 12 total)

New Reply

This forum has been archived and is no longer accepting new posts or replies. Please join our new community forum for support & discussion.