• Hello! I have created an extra field in the General Setting tab of the vendor so that they can enter the external web page of their company but I cannot create the link so that it opens in a new window.

    How can I create a field external URL correctly?

    The store page is created with Elementor and I need to be able to add the shortcode. In the created code I use this shortcode but only the web URL is displayed in text format and I want it to be a link. [wcfm_store_info data = “store_type”]

    /* WCFM Extra field "Pàgina web" */
    add_filter('wcfm_marketplace_settings_fields_general','wcfm_marketplace_add_custom_field_settings_fields_general',10,2);
    function wcfm_marketplace_add_custom_field_settings_fields_general($fields, $user_id) {
    	$vendor_data = get_user_meta( $user_id, 'wcfmmp_profile_settings', true );
    	$store_type          = isset( $vendor_data['v_store_type'] ) ? esc_attr( $vendor_data['v_store_type'] ) : '';
    	if(isset($fields['store_name'])) {
    	$fields = array_slice($fields, 0, 3, true) +
    	array("v_store_type" => array('label' => __('Pàgina web', 'wc-frontend-manager') , 'type' => 'text', 'class' => 'wcfm-text wcfm_ele', 'label_class' => 'wcfm_title wcfm_ele', 'value' => $store_type )) +
    																	array_slice($fields, 3, count($fields) - 3, true) ;
    	}
    	return $fields;
    }
    add_action( 'wcfm_wcfmmp_settings_update','fn_wcfm_vendor_settings_storetype_update', 30, 2);
    add_action( 'wcfm_vendor_settings_update','fn_wcfm_vendor_settings_storetype_update', 30, 2);
    function fn_wcfm_vendor_settings_storetype_update($user_id, $wcfm_settings_form ){	
    	$wcfm_settings_form_data_new = array();
    	parse_str($_POST['wcfm_settings_form'], $wcfm_settings_form_data_new);	
    	$wcfm_settings_form_data_storetype = array();
    	if(isset($wcfm_settings_form_data_new['v_store_type']) && !empty($wcfm_settings_form_data_new['v_store_type'])) {
    		$wcfm_settings_form_data_storetype['v_store_type'] = $wcfm_settings_form_data_new['v_store_type'];
    	}
    	$wcfm_settings_form = array_merge( $wcfm_settings_form, $wcfm_settings_form_data_storetype );
    	update_user_meta( $user_id, 'wcfmmp_profile_settings', $wcfm_settings_form );
    }
    
    add_filter('wcfmmp_additional_store_info','vendor_store_type_wcfmmp_additional_store_info',10,3);
    function vendor_store_type_wcfmmp_additional_store_info($data_value, $data_info, $store_id) {
    	$vendor_data = get_user_meta( $store_id, 'wcfmmp_profile_settings', true );
    	$store_type          = isset( $vendor_data['v_store_type'] ) ? esc_attr( $vendor_data['v_store_type'] ) : '';
    	if($data_info == 'store_type') {
    		$data_value = '<p>'.$store_type.'</p>';
    	}	
    	return $data_value;
    }
    

    thanks

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author WC Lovers

    (@wclovers)

    Add this snippet to your site as well-

    add_filter( 'wcfmmp_additional_store_info', function( $data_value, $data_info, $store_id ) {
    	if( $data_info == 'store_type' ) {
    		$data_value = '<a target="_blank" href="'.$data_value.'">'.$data_value.'</a>';
    	}
    	return $data_value;
    }, 50, 3 );
    Thread Starter Threads

    (@ardits)

    Hi, thanks for the code but it just doesn’t work properly.

    The shortcode [wcfm_store_info data = “store_type”] is displayed incorrectly as you can see here: https://ibb.co/5sp0VN7

    If we click on the link the URL is displayed incorrectly: https://mywebsite.com/liststores/namestore/<p>www.webiste.com </p>

    I think it has to do with the first fragment.

    Thank you again

    Thread Starter Threads

    (@ardits)

    Hello?

    Plugin Author WC Lovers

    (@wclovers)

    $data_value = ‘<p>’.$store_type.'</p>’;

    Remove this “p” tags from this code. Even you may remove this function. It’s not required.

    If you want then add such tag at my provided snippet

    Thread Starter Threads

    (@ardits)

    I tried to remove <p> but it still doesn’t link correctly to an external URL.

    		$data_value = ''.$store_type.'';
    

    Now clicking the website button redirects to:
    https://mywebsite.com/liststores/namestore/www.website.com

    If you look at the website link is at the end of the URL link. I want a new window with the external link of the store left over.

    • This reply was modified 4 years, 4 months ago by Threads.
    Plugin Author WC Lovers

    (@wclovers)

    Insert website url with “http”.

    Thread Starter Threads

    (@ardits)

    OK, now redirect correctly if we add http. How can I do this so that the button does not appear in http? now comes out as text https://website.com. Is it possible to put a generic text as a website? thanks

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Create external field URL’ is closed to new replies.