It’s no secret that I’m a huge fan of Easy Digital Downloads. All of my plugins are sold with it, and I’ve been a user of the plugin in one form or another for about 4 years now. Recently, I decided to be more open about the terms of purchase on my sites (Easy Digital Downloads calls it Terms of Agreement). It’s not that I ever was trying to “hide” those terms, but in reality they were hiding behind a popup on the checkout page. They really didn’t exist anywhere else on the site. My goal was to be displaying Easy Digital Downloads Terms of Agreement so that anyone can view them without being on the checkout page.
What I ultimately wanted to do was have my terms in two places. The first is where they’ve always been – on the checkout page. The second is on a regular WordPress page that was linked in the site’s footer. It’s easy enough to create a page, copy and paste the terms into the page, publish and call it a day. But what about when I update the terms? I don’t want to have to remember to update the terms of agreement in both locations.
When I did a little research, I found that I wasn’t the only one to have this issue. There was a rather lengthy issue on GitHub. It had a number of suggested improvements, and Pippin even ran a poll that found the majority of users at the time preferred keeping the terms of agreement as-is in the settings.
This was almost 5 years ago, and the terms of agreement still remains in the same spot.
I can understand why it remains this way. Think of all the sites that update without really understanding what was updated. Imagine if you were relying on the terms being on the checkout page, and all of a sudden **poof** they’re gone. There would be a lot of angry users, and probably rightfully so. I think the way the EDD team has handled this so far makes total sense. But there is still a way for displaying Easy Digital Downloads terms of agreement elsewhere.
Displaying Easy Digital Downloads Terms of Agreement on a Page
I had a couple requirements in order to display the terms of agreement on a page.
- I shouldn’t have to copy/paste the terms from the settings into a page.
- It should be a set it and forget it sort of operation.
Simple enough, right?
Since the terms of agreement are saved in the database in the EDD settings, it is easy enough to extract that data. Once it is extracted, I can display it however I want.
I decided to create a simple shortcode that does the following:
- Retrieves the EDD settings
- Checks if the terms of agreement is set
- Returns the terms of agreement text if it is
This way I can add a shortcode to a page called Terms & Conditions that will populate the page with the terms of agreement text from EDD’s settings. Any time I want to update those terms, I can go to the EDD settings, update once, and the same text will be displayed in both areas.
The Terms of Agreement Shortcode
Here is the code I used to create the shortcode.
add_shortcode( 'edd_display_terms_shortcode', 'display_terms' ); function display_terms(){ $edd_settings = get_option( 'edd_settings' ); if ( !$edd_settings['agree_text'] ){ return; } return $edd_settings['agree_text']; } |
On my Terms & Conditions page, I can simply enter the shortcode [edd_display_terms_shortcode]
and it will display the same text that is displayed on the checkout page.
Kevin says
Wow this is exactly what I was looking for!! Thank you for taking the time to do this and write up your solution!
Duncan says
This is really cool for my needs as was worrying about having to keep essentially the same document updated in two different places. I think I still need to play with it a bit as it is pulling in the appropriate text but not maintaining all the formatting. I’m using Divi so that may be the problem.
Darren says
This helped me greatly. Similar to Duncan I noticed there were some issues with the formatting. I looked at the plugin code and updated the function to this and it fixed the issue.
function display_terms(){
$agree_text = edd_get_option( ‘agree_text’, ” );
if ( empty( $agree_text ) ){
return;
}
return wpautop( stripslashes( $agree_text ) );
}