Last active
February 28, 2018 18:16
-
-
Save kimcoleman/b1afe6398d4e0cf74ccb79d45df0227e to your computer and use it in GitHub Desktop.
Fire Facebook Pixel on second order
This file contains hidden or 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 | |
/* | |
* Fire Facebook Pixel on second order | |
*/ | |
function fire_fb_pixel( $MemberOrder ) { | |
global $wpdb; | |
$orders = $wpdb->get_results("SELECT o.*, UNIX_TIMESTAMP(o.timestamp) as timestamp, l.name as membership_level_name FROM $wpdb->pmpro_membership_orders o LEFT JOIN $wpdb->pmpro_membership_levels l ON o.membership_id = l.id WHERE o.user_id = '$MemberOrder->user_id' AND o.subscription_transaction_id = '$MemberOrder->subscription_transaction_id' ORDER BY timestamp DESC"); | |
$transactionCount = count( $orders ); | |
if( $transactionCount == 2 ) { | |
//fire pixel | |
} | |
} | |
add_action( 'pmpro_added_order', 'fire_fb_pixel', 10, 1 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment