Adding [edd_social_discount] to your checkout page

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' );