Create a WordPress shortcode using PHP [duplicate]

This is a basis of the shortcode to be placed in your functions.php or custom plugin. You will need to edit it to fit your needs:

//Shortcode function can be called whatever you want
function merchantname_shortcode( $atts ) {
    $atts = shortcode_atts( array(
        //Creates a arg "merchantname" with no default value. 
        //To use this arg in your shortcode use: $atts['merchantname']
        'merchantname' => ''
    ), $atts, 'merchant-name' );

    //Anything else you want goes in here. You can't echo anything in a shortcode. 
    //Assign it to a var like: 
    $String = "foo"; 
    $String .= "bar"; 

    return $String; 

    //Anything that is echoed will be displayed at the top of $content regardless 
    //to where the shortcode is.
}

//First arg is the text you would put in your page to display the shortcode. 
//Creates a shortcode [merchant-name]. 
//Second arg is the function used to create the shortcode.
add_shortcode( 'merchant-name', 'merchantname_shortcode' );

Shortcode Codex Page