edd-theme-updater
edd-theme-updater copied to clipboard
Edd checkout uri
In commit 86987358ecfa3beb14469508a51df9232036aaa8 there is hardcoded url like this:
/checkout/?edd_license_key=' . $license_key . '&download_id=' . $this->download_id
Is checkout page always /checkout? It's the default page slug but that can be changed, right?
Could we use function edd_get_checkout_uri instead?
https://easydigitaldownloads.com/codex/function-edd_get_checkout_uri.html
Note that I haven't even checked the complete code so I can be terrible wrong here.
The theme shop API would to provide the renewal link for edd_get_checkout_uri to work. Perhaps the JSON response could add that rather than us coding it.
But that's one reason I also added the "renew_url" param. If you were using a custom link structure, you could build your own link.
Makes sense, thanks.
I use this to provide a renewal link
/**
* Add the renewal checkout URL to the remote license check response.
*
* @param array $response The response array.
* @param array $atts The atts for EDD_Software_Licensing::remote_license_check()
* @param string $license_id The license key.
* @return array The response array.
*/
function cn_remote_license_check_response( $response, $atts, $license_id ) {
// Ensure the required functions exist; if not return $response.
if ( ! function_exists( 'edd_sl_renewals_allowed' ) &&
! function_exists( 'edd_software_licensing' ) &&
! function_exists( 'edd_get_checkout_uri' ) ) {
return $response;
}
// Ensure the license key exists; if not return $response.
if ( ! isset( $atts['key'] ) || empty( $atts['key'] ) ) {
return $response;
}
// If license renewal is not permitted; return $response.
if ( ! edd_sl_renewals_allowed() ) {
return $response;
}
// No need to add the checkout URI to the response if the license is not expired.
if ( $response['license'] !== 'expired' ) {
return $response;
}
// Bring into scope the EDD SL Class.
$licensing = edd_software_licensing();
// Get the download ID from the license key.
$download_id = $licensing->get_download_by_license( $atts['key'] );
// If the download ID was found, add the renewal URI to $response.
if ( $download_id !== FALSE ) {
$response['renewal_url'] = edd_get_checkout_uri( array( 'edd_license_key' => $atts['key'], 'download_id' => $download_id ) );
}
return $response;
}
add_filter( 'edd_remote_license_check_response', 'cn_remote_license_check_response', 10, 3 );
Thanks for posting @shazahm1. Did you see if @pippinsplugins was interested in a pull request? I think this would be a nice feature.
@devinsays no, I haven't ... Honestly, I thought if enough people actually wanted it, it would already be in EDD-SL.
Since EDD-SL a commercial plugin, can't really submit a pull request.
I definitely would love to see a pull request :)
@pippinsplugins How would I submit a PR to EDD-SL? Or, would you want this in core somehow???
I've just added you to the repo.
On Fri, Oct 3, 2014 at 9:48 AM, shazahm1 [email protected] wrote:
@pippinsplugins https://github.com/pippinsplugins How would I submit a PR to EDD-SL? Or, would you want this in core somehow???
— Reply to this email directly or view it on GitHub https://github.com/devinsays/edd-theme-updater/issues/12#issuecomment-57806090 .
I was wondering if renewal link is now in EDD SL Plugin?