I'm using Woocommerce
, it's up to date.
I've been looking for answers about my issue. I found quite a lot of posts about it but they don't seem to help me figure out the solution.
Found this website that describes how to hook the conversion code.
I tried quite a lot of snippets but the code doesn't fire.
Basically, I've got an iframe
code that I need to add to my conversion page.
This page is created from the template <b>thankyou.php</b>
I added some code through a hook to function.php but the iframe doesn't show up in the conversion page.
In order to test the code, I've been checking the network tab in "inspect element". It doesn't fire, I cannot even find the code in the page.
Here's the iframe
code:
[iframe src="https://lb.affilae.com/?key=59f3463ce8faceb82f8b4571-
59f345fedca96b441b37b6ce&id={UNIQUE_ID}&amount={AMOUNT}&payment=
{PAYMENT}&cv={CUSTOM_VAR}" frameborder="0" width="1" height="1"]
It is a wordpress shortcode, the only way for it to show up on the page.
Here's the hook I've been using:
add_action( 'woocommerce_thankyou', 'bbloomer_add_content_thankyou' );
function bbloomer_add_content_thankyou() {
echo 'my iframe conversion code';
}
Do you have any idea how to fix this? I can provide more info if needed.
Edit:
I found a solution!
The main issue came from the fact that I didn't specified the unique ID and the amount.
Here's the code that solved it all:
add_action( 'woocommerce_thankyou', 'my_custom_tracking' );
function my_custom_tracking( $order_id ) {
$order = new WC_Order( $order_id );
$total = $order->get_subtotal();
$id = str_replace('#', '', $order->get_order_number());
echo '<iframe src="https://lb.affilae.com/?[replace with the right code]&id=' . $id . '&amount=' . $total .
'&payment=online&cv={CUSTOM_VAR}" frameborder="0" width="1" height="1">
</iframe>';
}
I pasted this code at the top of the function.php file (after