Created
June 8, 2017 18:33
-
-
Save thommeredith/97922fba396c7a64b2c2772058f8c872 to your computer and use it in GitHub Desktop.
Referral Candy WooCommerce Order Confirmation Popup
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
add_action( 'woocommerce_thankyou', 'refcandy_lollipop' ); | |
function refcandy_lollipop( $order_id ) { | |
$order = wc_get_order( $order_id ); | |
$divData = [ | |
'id' => 'refcandy-lollipop', | |
'data-id' => 'USEYOURIDFROMYOURACCOUNT', | |
'data-fname' => $order->billing_first_name, | |
'data-lname' => $order->billing_last_name, | |
'data-email' => $order->billing_email, | |
]; | |
$div = '<div '.implode(' ', array_map(function ($v, $k) { return $k . '="'.addslashes($v).'"'; }, $divData, array_keys($divData))).'></div>'; | |
$script = '<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//portal.referralcandy.com/assets/widgets/refcandy-lollipop.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","refcandy-lollipop-js");</script>'; | |
echo $div.$script; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment