Installation & Setup
Before plugin activation, do the following to begin processing impact requests to the ecologi API.
Retrieve API Key
Within your ecologi account, create an API key for use with EDD purchases.
Add API Key
Within wp-config.php
, add your API key and ecologi username as constants.
define( 'TYPEWHEEL_EDDE_ECOLOGI_API_KEY', 'your-key-goes-here' );
define( 'TYPEWHEEL_EDDE_ECOLOGI_USERNAME', 'your-username-goes-here' );
Configure Impact Breakpoints
The next step is to define the parameters within which trees and carbon offsets will be purchased. Hook into the filter typewheel_edd_ecologi_array
and set values in the array for various purchase and renewal amounts. The impact array you set for a value will apply to all values above the associated key and up to the next associated key’s amount.
add_filter( 'typewheel-edd-ecologi/impact', function( $impact ) {
return array(
'edd_purchase' => array
'0' => [ 'trees' => 2, 'carbon' => 0 ],
'42' => [ 'trees' => 4, 'carbon' => 0 ],
'75' => [ 'trees' => 7, 'carbon' => 0 ],
'100' => [ 'trees' => 11, 'carbon' => 0 ],
'150' => [ 'trees' => 20, 'carbon' => 0 ]
),
'edd_renewal' => array(
'0' => [ 'trees' => 1, 'carbon' => 75 ],
'42' => [ 'trees' => 2, 'carbon' => 150 ],
'75' => [ 'trees' => 3, 'carbon' => 250 ],
'100' => [ 'trees' => 4, 'carbon' => 500 ],
'150' => [ 'trees' => 5, 'carbon' => 500 ]
)
);
} );
Email Tags
The following tags can be used in EDD email templates. Formatted with units & text.
Purchase Related
{ecologi_purchase_tree_count}
– Display the number of trees planted with this purchase.{ecologi_purchase_tree_url}
– Display the unique URL of the trees planted with this purchase.{ecologi_purchase_carbon_offset}
– Display the amount of carbon offset with this purchase (in kg){ecologi_purchase_carbon_projects}
– Display the projects involved in carbon offset with this purchase.
Customer Related
{ecologi_customer_tree_count}
– Display the number of trees planted by this customer.{ecologi_customer_carbon_offset}
– Display the amount of carbon offset by this customer. (in kg)
ecologi User Related
{ecologi_tree_count}
– Display the total number of trees planted by your ecologi user.{ecologi_carbon_offset}
– Display the amount of carbon offset by your ecologi user. (in tonnes)
Shortcodes
The following shortcodes can be used throughout your site. Returns number value only.
Customer Related
[ecologi_customer_tree_count]
[ecologi_customer_carbon_offset]
accepts units=”kg” parameter (default is tonnes)
ecologi User Related
[ecologi_tree_count]
[ecologi_carbon_offset]
accepts units=”kg” parameter (default is tonnes)