This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
auth_token_sniply = 'YOUR_SNIPLY_AUTH_TOKEN' | |
campaign_id = 'YOUR_CAMPAIGN_ID' | |
headers = {'Authorization': 'Bearer ' + auth_token_sniply, 'Content-Type': 'application/json'} | |
payload = {'url': input['url'], 'campaign': campaign_id} | |
r = requests.post('https://snip.ly/api/v2/links/', data=json.dumps(payload), headers=headers) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
auth_token_sniply = 'YOUR_AUTH_TOKEN' | |
campaign_id = 'YOUR_CAMPAIGN_ID' | |
headers = {'Authorization': 'Bearer ' + auth_token_sniply, 'Content-Type': 'application/json'} | |
payload = {'url': input['url'], 'campaign': campaign_id} | |
r = requests.post('https://snip.ly/api/v2/links/', data=json.dumps(payload), headers=headers) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function give_course_access( $user_id, $subscription_key ) { | |
// Get the course ID related to the subscription | |
$subscription = WC_Subscriptions_Manager::get_subscription( $subscription_key ); | |
$courses_id = get_post_meta($subscription['product_id'], '_related_course', true); | |
$start_date = $subscription['start_date']; | |
error_log('Start Date :' . $start_date . ' Epoch: ' . strtotime($start_date)); | |
// Update access to the courses | |
if ($courses_id && is_array($courses_id)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function send_receipt($order_id){ | |
//if($new_status == 'processing' && $status != 'completed' || $new_status == 'completed' && $status == 'processing'){ | |
if($status != 'processing' && $status != 'completed') { | |
$order = new WC_Order($order_id); | |
$products = $order->get_items(); | |
foreach($products as $product){ | |
$courses_id = get_post_meta($product['product_id'], '_related_course', true); | |
if($courses_id && is_array($courses_id)){ | |
foreach($courses_id as $cid) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** PHP Script to generate WooCommerce temporary coupon from ActiveCampaign **/ | |
/** By Thomas Le Coz - http://thomaslecoz.com **/ | |
/** Configuration **/ | |
$key = "YOURSECRETKEY"; // Secret key you should add to the webhook URL too: http://yourwebsite.com/coupon-gen/coupon-generator.php?key=YOURSECRETKEY | |
$ck_woocommerce = 'YOUR_WOOCOMEMRCE_API_CLIENT_KEY'; // WooCommerce API client key | |
$cs_woocommerce = 'YOUR_WOOCOMEMRCE_API_SECRET_KEY'; // WooCommerce API secret key | |
// Catch Hook from ActiveCampaign & basic security check |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function __construct() { | |
// [...] | |
add_action('cancelled_subscription', array($this, 'remove_course_access'), 10, 2); | |
add_action('subscription_put_on-hold', array($this, 'remove_course_access'), 10, 2); | |
add_action('activated_subscription', array($this, 'give_course_access'), 10, 2); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Remove this line from the constructor | |
add_action('subscription_expired', array($this, 'remove_course_access'), 10, 2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Remove Access to the course linked to the subscription key | |
function remove_course_access( $user_id, $subscription_key ) { | |
// Get the course ID related to the subscription | |
$subscription = WC_Subscriptions_Manager::get_subscription( $subscription_key ); | |
$courses_id = get_post_meta($subscription['product_id'], '_related_course', true); | |
// Update access to the courses | |
if ($courses_id && is_array($courses_id)) { | |
foreach ($courses_id as $course_id) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function __construct() { | |
[...] | |
add_action('cancelled_subscription', array($this, 'remove_course_access'), 10, 2); | |
add_action('subscription_put_on-hold', array($this, 'remove_course_access'), 10, 2); | |
add_action('subscription_expired', array($this, 'remove_course_access'), 10, 2); | |
add_action('activated_subscription', array($this, 'give_course_access'), 10, 2); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function render_course_selector() { | |
global $post; | |
$courses = $this->list_courses(); | |
echo '<div class="options_group show_if_course show_if_simple">'; | |
[...] | |
} |