Mailbag: Multiple Download Buttons

Less a mailbag and more a forum question that grew from a logical question.

How do you link ‘external’ stores from your product pages?

Well, for me I do it by having a custom page I designed for my products, and listing three shortcodes. One for EDD (the default [purchase_link]) and then two for my own links. In non-shortcode, its like this:

[Buy from Me][Buy from Amazon][Buy from Apple]

The actual code is below. I try to keep things as simple as I can when I do this, and I did nick a bit of code from EDD core (you’re supposed to) to make it match. All this does is the most basic of links and it all fits in a nice little box like this:

The sales box sits on the upper rght of the page and lists image, price,  and links.

I like that layout. Reminds you a bit of Amazon, and there’s a reason. If you keep the space open and clear, it’s easy for a visitor to grasp their options. Also I can put below a link to my EU/VAT page and say this “Purchase disabled? Here’s why…” I don’t right now, though I probably should. I couldn’t think of how to elegantly handle making the button a link like that.

The code

	// EDD Buy Externally [edd_external store="iTunes" link="http://apple.com/foo" text="Add to Cart" ]
	function edd_external_shortcode_func( $atts ) {
		global $edd_options;

	    $atts = shortcode_atts( array(
	        'store' => '',
	        'link'  => '',
	        'text'	=> 'Buy Via',
			'style' => isset( $edd_options[ 'button_style' ] ) ? $edd_options[ 'button_style' ] : 'button',
			'color' => isset( $edd_options[ 'checkout_color' ] ) ? $edd_options[ 'checkout_color' ] : 'blue',
			'class' => 'edd-submit'
	    ),
	    $atts, 'edd_external' );

		// Override color if color == inherit
		if( isset( $atts['color'] )	) {
			$atts['color'] = ( $atts['color'] == 'inherit' ) ? '' : $atts['color'];
		}

		$content = '<a href="'.$atts&#91;'link'&#93;.'" class="edd-external edd-'.$atts&#91;'store'&#93;.'
		 '.$atts&#91;'style'&#93;.' '.$atts&#91;'color'&#93;.' '.$atts&#91;'class'&#93;.'
		"><span class="edd-add-to-cart-label">'.$atts['text'].' '.$atts['store'].'</a></span>';

		return '<div class="edd_purchase_submit_wrapper">'.$content.'</div>';
	}

	add_shortcode( 'edd_external', 'edd_external_shortcode_func' );

Like I said. Pretty basic.