Social Discounts - Usage/Modifications

The Social Discounts extension for Easy Digital Downloads has available filters, shortcodes, etc that can be used for a more customized experience. 

CSS Syling

A .shared CSS class is added dynamically to the wrapping HTML div when a product is shared. This will allow you to style the “thanks” title and message to make it more obvious that the product was shared and the user should should add the product to their cart, or proceed to checkout.

Filters

The following filters are available to developers when the Social Discounts extension is activated:

edd_social_discounts_classes<br>

edd_social_discounts_share_title<br>

edd_social_discounts_share_message

edd_social_discounts_facebook_share_button<br>

edd_social_discounts_share_box

Shortcodes

With Social Discounts, by default the sharing buttons will be shown automatically after the content on all your products. By using the included shortcode you can fine tune the placement on a per product basis, or even include the sharing buttons on posts and/or pages.

Default usage

[edd_social_discount]

Advanced usage

The shortcode accepts an “id” parameter. This could be the ID another post, page or product. Extremely useful for when you want to share a product, from an entirely different page. If you want to share the current product/post/page that the shortcode is on, you do not need to include the ID parameter.

[edd_social_discount id="50"]

If you’re using the ID parameter above, chances are you’ll want to also customize the sharing title and message. You can use the “title” and “message” parameters like this:

[edd_social_discount id="50" title="Share my awesome product!" message="Share my awesome product and you'll receive a discount at checkout."]

Custom Tweet message:

[edd_social_discount tweet="This is a custom message for the twitter sharing button"]

Add Shortcode to Checkout

When a customer lands on your checkout page they have shown a desire in purchasing from you. This is a perfect opportunity to offer them a discount on their order in exchange for a social share with Social Discounts.

Although adding an ID parameter to the shortcode can share a specific post/page/download, if you don’t use the ID parameter, it will share the current page. This is not ideal in situations like this, where we want to share the site URL, not the URL to the checkout page.

This small code snippet will show you how to change the share URL conditionally, and share the site URL, not the checkout page.

<?php
/**
 * Change share URL conditionally
 */
function sumobi_edd_sd_change_share_url( $url ) {

	// change the URL to share only on the checkout page
	if ( function_exists( 'edd_is_checkout' ) && edd_is_checkout() ) {
		$url = site_url(); // the URL of your website
	}
	
	return $url;
}
add_filter( 'edd_social_discounts_share_url', 'sumobi_edd_sd_change_share_url' );