Ecommerce Shopify WordPress Discussion

Wocommerce Affiliate iframe link

I have a problem with embedding an affiliate link in the purchase summary in woocommerce (thankyou page). I need to pass the order number and order amount variables to an external affiliate provider. I found a script from the xlplugins collection (https://xlplugins.com/docs/nextmove-woocommerce-thank-you-page/how-to/add-custom-javascript-events-thank-page/) that helps with such a task, and modified it for my application by embedding an iframe in javascript. Unfortunately the values for order number and subtotal are not passed to the affiliate partner. The affiliate panel counts interactions on the website, but does not pass on the values of the variables. Code: /** * This is a PHP code, so should be wrapped inside PHP * Like we added here. * If PHP is already open then don't include above <?php open tag */ /** * Adding custom javascripts or php action on WooCommerce Thank you page * Works with WooCommerce 3.0 or above */ add_action( "woocommerce_thankyou", "xlwcty_thank_you_script", 20 ); if ( ! function_exists( 'xlwcty_thank_you_script' ) ) { function xlwcty_thank_you_script( $order_id ) { if ( $order_id > 0 ) { $order = wc_get_order( $order_id ); if ( $order instanceof WC_Order ) { $order_id = $order->get_id(); // order id $order_key = $order->get_order_key(); // order key $order_total = $order->get_total(); // order total $order_currency = $order->get_currency(); // order currency $order_payment_method = $order->get_payment_method(); // order payment method $order_shipping_country = $order->get_shipping_country(); // order shipping country $order_billing_country = $order->get_billing_country(); // order billing country $order_status = $order->get_status(); // order status /** * full list methods and property that can be accessed from $order object * https://docs.woocommerce.com/wc-apidocs/class-WC_Order.html */ ?> <script type="text/javascript"> const iframe = document.createElement("iframe"); iframe.style.display = "none"; iframe.src = 'https://randomaddress.randomdomain.org/aff_l?offer_id=123&adv_sub=$order_id&amount=$order_total'; document.body.appendChild(iframe); </script> <?php } } } } /** * This code execute inside head tag */ add_action( "wp_head", "xlwcty_thank_you_header_script", 20 ); if ( ! function_exists( 'xlwcty_thank_you_header_script' ) ) { function xlwcty_thank_you_header_script() { if ( function_exists( 'is_order_received_page' ) && is_order_received_page() && isset( $_GET['order_id'] ) ) { $order_id = $_GET['order_id']; $order = wc_get_order( $order_id ); if ( $order instanceof WC_Order ) { $order_id = $order->get_id(); // order id $order_key = $order->get_order_key(); // order key $order_total = $order->get_total(); // order total $order_currency = $order->get_currency(); // order currency $order_payment_method = $order->get_payment_method(); // order payment method $order_shipping_country = $order->get_shipping_country(); // order shipping country $order_billing_country = $order->get_billing_country(); // order billing country $order_status = $order->get_status(); // order status /** * full list methods and property that can be accessed from $order object * https://docs.woocommerce.com/wc-apidocs/class-WC_Order.html */ ?> <script type="text/javascript"> const iframe = document.createElement("iframe"); iframe.style.display = "none"; iframe.src = 'https://randomaddress.randomdomain.org/aff_l?offer_id=123&adv_sub=$order_id&amount=$order_total'; document.body.appendChild(iframe); </script> <?php } } } } I added this code by embedding it in the head section using the WP code plugin. I am a noob, what am I doing wrong? I tried to embed the link directly, but found that the data required by the affiliate partner could not be passed directly by specifying a parameter in the link.
TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.