Last active
March 14, 2024 18:14
-
-
Save Nerd-Rush/e15c7fa8603c0bfc1d0af89beeada3ee to your computer and use it in GitHub Desktop.
Ads Online - bootlegproducts.com
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
add_action( 'woocommerce_thankyou', 'my_custom_tracking' ); | |
if ( ! function_exists( 'custom_meta_to_order' ) ) { | |
add_action( 'woocommerce_checkout_create_order', 'custom_meta_to_order', 20, 1 ); | |
function custom_meta_to_order( $order ) { | |
$eftid = isset( $_COOKIE['ef_tid_c_a_1342'] ) ? sanitize_text_field( $_COOKIE['ef_tid_c_a_1342'] ) : ''; | |
$order->update_meta_data( "eftid", $eftid ); | |
} | |
} | |
function my_custom_tracking( $order_id ) { | |
$order = wc_get_order( $order_id ); | |
$efOrder = array( | |
'items' => array(), | |
'oid' => $order_id, | |
'amt' => $order->get_total(), | |
'bs' => $order->get_billing_state(), | |
'bc' => $order->get_billing_country(), | |
'cc' => implode(',', $order->get_coupon_codes()) | |
); | |
foreach ( $order->get_items() as $item_id => $item ) { | |
$product = $item->get_product(); | |
$efItem = array( | |
'ps' => $product ? $product->get_sku() : '', | |
'qty' => $item->get_quantity(), | |
'p' => $order->get_line_total( $item, true, true ) | |
); | |
$efOrder['items'][] = $efItem; | |
} | |
$javascriptCode = "<script type='text/javascript' src='https://www.r1kln3trk.com/scripts/sdk/everflow.js'></script> | |
<script type='text/javascript'> | |
EF.conversion({ | |
aid: 1342, | |
amount: ".json_encode($order->get_total() - $order->get_shipping_total()).", | |
order_id: '{$order_id}', | |
order: ".json_encode($efOrder).", | |
coupon_code: '{$efOrder['cc']}', | |
email: '{$order->get_billing_email()}', | |
}); | |
</script>"; | |
echo $javascriptCode; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment