• Resolved marvin0o

    (@marvin0o)


    Hello

    I use your plugin “CUSTOM THANK YOU PAGE”. This overwrite or replace the standard Woo checkoutpage.
    I need to load a script on the checkout page to enable the affiliate tracking. See below:
    https://sc.tradetracker.net/implementation/overview?f%5Btarget%5D=merchant&f%5Bname%5D=General&f%5Bv…
    This script is not working anymore with Custom thankyou page enabled. I hope you can help me to get this script working with your plugin enabled.

    I add the following codes to my WP

    CODE1
    to file: woocommerce/includes/wc-template-hooks.php
    add_action(‘woocommerce_thankyou’, ‘tradetracker’);

    CODE 2
    to file: /wp-includes/functions.php file

    function tradetracker($order_id)
    {
    $campaignID = ‘#ID’; // Enter your campaignID as provided by TradeTracker.
    $productID = ‘#ID’; // Enter your productID as provided by TradeTracker.

    // *****************
    $order = new WC_Order($order_id);
    $transactionID = htmlentities($order_id, ENT_QUOTES);
    $transactionAmount = htmlentities((float) $order->order_total – (float) $order->order_shipping – (float) $order->order_discount – (float) $order->order_tax);

    echo “<script type=\”text/javascript\”>
    var ttConversionOptions = ttConversionOptions || [];
    ttConversionOptions.push({
    type: ‘sales’,
    campaignID: ‘{$campaignID}’,
    productID: ‘{$productID}’,
    transactionID: ‘{$transactionID}’,
    transactionAmount: ‘{$transactionAmount}’,
    quantity: ‘1’,
    descrMerchant: ”,
    descrAffiliate: ”,
    currency: ”
    });
    </script>
    <noscript>

    </noscript>
    <script type=\”text/javascript\”>
    (function(ttConversionOptions) {
    var campaignID = ‘campaignID’ in ttConversionOptions ? ttConversionOptions.campaignID : (‘length’ in ttConversionOptions && ttConversionOptions.length ? ttConversionOptions[0].campaignID : null);
    var tt = document.createElement(‘script’); tt.type = ‘text/javascript’; tt.async = true; tt.src = ‘//tm.tradetracker.net/conversion?s=’ + encodeURIComponent(campaignID) + ‘&t=m’;
    var s = document.getElementsByTagName(‘script’); s = s[s.length – 1]; s.parentNode.insertBefore(tt, s);
    })(ttConversionOptions);
    </script>”;
    }

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author YITHEMES

    (@yithemes)

    Hi there,
    You can use this plugin action, to realize your needs.

    do_action('yith_ctpw_successful_ac', $order);
    But this action need of the order object, so you need change your code in this case.

    Thread Starter marvin0o

    (@marvin0o)

    Hi many thanks for you reply. Sorry for the late response. I missed the mail notifcation.

    Ok where do I need to add to code? or what code do I need to change?
    I understand when something cost you time you will send an invoice.

    Plugin Author YITHEMES

    (@yithemes)

    Hello,
    remove Code1

    inside the file functions.php of your theme

    add:

    add_action( 'yith_ctpw_successful_ac', 'tradetracker');

    your function will be

    
    function tradetracker($order)
    {
    $campaignID = ‘#ID’; // Enter your campaignID as provided by TradeTracker.
    $productID = ‘#ID’; // Enter your productID as provided by TradeTracker.
    
    // *****************
    $order_id = $order->get_id();
    $transactionID = htmlentities($order_id, ENT_QUOTES);
    $transactionAmount = htmlentities((float) $order->order_total – (float) $order->order_shipping – (float) $order->order_discount – (float) $order->order_tax);
    
    echo “<script type=\”text/javascript\”>
    var ttConversionOptions = ttConversionOptions || [];
    ttConversionOptions.push({
    type: ‘sales’,
    campaignID: ‘{$campaignID}’,
    productID: ‘{$productID}’,
    transactionID: ‘{$transactionID}’,
    transactionAmount: ‘{$transactionAmount}’,
    quantity: ‘1’,
    descrMerchant: ”,
    descrAffiliate: ”,
    currency: ”
    });
    </script>
    <noscript>
    
    </noscript>
    <script type=\”text/javascript\”>
    (function(ttConversionOptions) {
    var campaignID = ‘campaignID’ in ttConversionOptions ? ttConversionOptions.campaignID : (‘length’ in ttConversionOptions && ttConversionOptions.length ? ttConversionOptions[0].campaignID : null);
    var tt = document.createElement(‘script’); tt.type = ‘text/javascript’; tt.async = true; tt.src = ‘//tm.tradetracker.net/conversion?s=’ + encodeURIComponent(campaignID) + ‘&t=m’;
    var s = document.getElementsByTagName(‘script’); s = s[s.length – 1]; s.parentNode.insertBefore(tt, s);
    })(ttConversionOptions);
    </script>”;
    }
    Thread Starter marvin0o

    (@marvin0o)

    You are great, its working!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Script not working with custom thankyou page plugin’ is closed to new replies.