I am trying to get a value of order by PHP (in thank you page) and then use it in script as attribute (attribute v= in src link).
This is for Woocommerce
add_action( 'woocommerce_thankyou', 'bbloomer_conversion_tracking_thank_you_page' );
function bbloomer_conversion_tracking_thank_you_page() {
?>
<!-- Měřicí kód Sklik.cz -->
<iframe width="119" height="22" frameborder="0" scrolling="no" src="//c.imedia.cz/checkConversion?c=100056379&color=ffffff&v="></iframe>
<?php
}
I hoped that this code will work, but it doesnt.
add_action( 'woocommerce_thankyou', 'bbloomer_conversion_tracking_thank_you_page' );
function bbloomer_conversion_tracking_thank_you_page() {
$price=$order->get_total();
?>
<!-- Měřicí kód Sklik.cz -->
<iframe width="119" height="22" frameborder="0" scrolling="no" src="//c.imedia.cz/checkConversion?c=100056379&color=ffffff&v=$price"></iframe>
<?php
}
2
Answers
https://developer.wordpress.org/reference/functions/add_action/
Can you add more details, like the order number variable and where you want to insert.
A.S. as you add these details i will edit the answer or/and add a new answer.
Edit:
You can’t write php variables in a non-php script.
If you want to add a link, i suggest sing echo like this: this is your fixed code:
Enjoy your day!