Jump to content

Implementing Paydot tracking


Recommended Posts

Hello guys.

Im trying to add my prestashop store as a merchat to a paydot.com affilliate network.

So they have instructions that i need to.....

 

 

To display order total you will need to create override/controllers/OrderConfirmationController.php


Add the following code in the OrderConfirmationController.php


class OrderConfirmationController extends OrderConfirmationControllerCore
{
public function displayContent()
{
global $cart;
self::$smarty->assign('shippingCost', $cart->getOrderShippingCost());
self::$smarty->assign('orderTotal', $cart->getOrderTotal());
parent::displayContent();
}
}

 

This should pass the order details to the order confirmation/thank you page. With this working, you should now be able to insert variables in to our tracking code to send us all the required infoormation.


Here is the tracking code example:

 

And then add to

order-confirmation.tpl
 
<img src="https://track.paydot.com/sale.php?value={$orderTotal}&oid={$id_order}&sid=%%SITEID%%&pid=DEFAULT" width="1" height="1">

Replace %%SITEID%% with your site ID number.

So i have no problems with "order-confirmation.tpl"

But when i add code to OrderConfirmationController.php i get Blank Page on OrderConfirmation Page.

I tried alot adding it in a different positions, but no luck. Im quit sure that i just need to add it in some sort of a way but dont know where exactly since im not a programmer.

I would Appriciate Alot if Someone could Insert it or explain where i should add it.

P.S i adedd Initial "OrderConfirmationController.php" file as an attachement. Also Year Ago one member already asked for Help but never recieved an answer.

https://www.prestashop.com/forums/topic/367592-implementing-paydot-tracking-pixel/

So i hope alot that this time some one will help us.

OrderConfirmationController.php
Link to comment
Share on other sites

For PS 1.6 and I think also 1.5 :

The path of your override is not correct, it should be override/controllers/front/OrderConfirmationController.php

The function displayContent() should be initContent().

Avoid using global variables.

<?php

class OrderConfirmationController extends OrderConfirmationControllerCore {
    
    public function initContent() {
        $cart = $this->context->cart;
        
        $this->context->smarty->assign(array(
            'shippingCost' => $cart->getOrderShippingCost(),
            'orderTotal' => $cart->getOrderTotal()
        ));
        
        parent::initContent();
    }

}

After placing the override file to the right path go to cache folder and delete class_index.php to make sure the override will apply.

OrderConfirmationController.php

Link to comment
Share on other sites

Thank you alot for taking your time! But could you please. Give me couple more hints.

So if in FTP i go to /htdocs/override/controllers/front  There is no file OrderConfirmationController.php

Even so i tried to create new one and place the code that you attached, but still no luck.

If i go to /htdocs/controllers/front i see that there is file OrderConfirmationController.php

I tried to put code in different ways but still no luck
 

 

HERE
<?php

class OrderConfirmationController extends OrderConfirmationControllerCore {

public function initContent() {
$cart = $this->context->cart;

$this->context->smarty->assign(array(
'shippingCost' => $cart->getOrderShippingCost(),
'orderTotal' => $cart->getOrderTotal()
));

parent::initContent();
}

}


<?php
/*
* 2007-2014 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
*  @author PrestaShop SA <[email protected]>
*  @copyright  2007-2014 PrestaShop SA
*  @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*/
OR HERE
<?php

class OrderConfirmationController extends OrderConfirmationControllerCore {

public function initContent() {
$cart = $this->context->cart;

$this->context->smarty->assign(array(
'shippingCost' => $cart->getOrderShippingCost(),
'orderTotal' => $cart->getOrderTotal()
));

parent::initContent();
}

}

class OrderConfirmationControllerCore extends FrontController
OR HERE
<?php

class OrderConfirmationController extends OrderConfirmationControllerCore {

public function initContent() {
$cart = $this->context->cart;

$this->context->smarty->assign(array(
'shippingCost' => $cart->getOrderShippingCost(),
'orderTotal' => $cart->getOrderTotal()
));

parent::initContent();
}

}

{
    public $ssl = true;
    public $php_self = 'order-confirmation';

    public $id_cart;
    public $id_module;
    public $id_order;
    public $reference;
    public $secure_key;

    /**
     * Initialize order confirmation controller
     * @see FrontController::init()
     */
    public function init()
    {
        parent::init();

        $this->id_cart = (int)(Tools::getValue('id_cart', 0));
        $is_guest = false;

        /* check if the cart has been made by a Guest customer, for redirect link */
        if (Cart::isGuestCartByCartId($this->id_cart))
        {
            $is_guest = true;
            $redirectLink = 'index.php?controller=guest-tracking';
        }
        else
            $redirectLink = 'index.php?controller=history';

        $this->id_module = (int)(Tools::getValue('id_module', 0));
        $this->id_order = Order::getOrderByCartId((int)($this->id_cart));
        $this->secure_key = Tools::getValue('key', false);
        $order = new Order((int)($this->id_order));
        if ($is_guest)
        {
            $customer = new Customer((int)$order->id_customer);
            $redirectLink .= '&id_order='.$order->reference.'&email='.urlencode($customer->email);
        }
        if (!$this->id_order || !$this->id_module || !$this->secure_key || empty($this->secure_key))
            Tools::redirect($redirectLink.(Tools::isSubmit('slowvalidation') ? '&slowvalidation' : ''));
        $this->reference = $order->reference;
        if (!Validate::isLoadedObject($order) || $order->id_customer != $this->context->customer->id || $this->secure_key != $order->secure_key)
            Tools::redirect($redirectLink);
        $module = Module::getInstanceById((int)($this->id_module));
        if ($order->payment != $module->displayName)
            Tools::redirect($redirectLink);
    }

    /**
     * Assign template vars related to page content
     * @see FrontController::initContent()
     */
    public function initContent()
    {
        parent::initContent();
OR HERE
<?php

class OrderConfirmationController extends OrderConfirmationControllerCore {

public function initContent() {
$cart = $this->context->cart;

$this->context->smarty->assign(array(
'shippingCost' => $cart->getOrderShippingCost(),
'orderTotal' => $cart->getOrderTotal()
));

parent::initContent();
}

}

Link to comment
Share on other sites

The attachment file OrderConfirmationController.php it's not present at path override/controllers/front/ but you upload it there.
The original file controllers/front/OrderConfirmationController.php should not be modified in any way.
 
It's important to delete the file cache/class_index.php after you place the override file.
Then in order-confirmation.tpl you can use the variables {$shippingCost} and {$orderTotal}

Link to comment
Share on other sites

 

Thnxs "gabdara" For Help you where right about folder... And about Functions... But still something in a code docent works.

Tracking sends  Order Value 0 for some reason... even though it shouldn't be zero.

 

Also tracking dosent sends order ID for some reason.

 

I made many tests with their support but still no luck.  Would appreciate any other ideas.

 

P.S Attached conversation Log with paydot.com support

 

 

 

 

 

 

 

 

 

So from the yesterday. I found out that i was doing everything wrong.

 

https://www.prestashop.com/forums/topic/462041-implementing-paydot-tracking/

I was updating file "OrderConfirmationController" From totally wrong folder and thats why i got blank page

Also i found out that currently on your website you have misleading information that "OrderConfirmationController" should be located in

 

override/controllers/OrderConfirmationController.php

 

Actually should be in

 

override/controllers/front/OrderConfirmationController.php

 

Not 100% Sure but looks like that.

 

Shafiq Tajbhai - Merchant Acquisition

Thanks for looking into this and explaining your findings. Have you tried this?

 

Sportkid.eu OU

Yeap tried. But no luck. But i have even more stupid questions.

 

Shouldnt this code

 

class OrderConfirmationController extends OrderConfirmationControllerCore

{

public function displayContent()

{

global $cart;

self::$smarty->assign('shippingCost', $cart->getOrderShippingCost());

self::$smarty->assign('orderTotal', $cart->getOrderTotal());

parent::displayContent();

}

}

 

Start with <?php Or it docent matter? Sorry for F**king ur Brains.

But i spent half a day on researching and testing.

And now after finding my mane mistake i beleive that i am somewhere near the success.

 

Shafiq Tajbhai - Merchant Acquisition

so what were you getting when you checkout? do you still get a blank page?

 

Sportkid.eu OU

Nope this time no Blank Page. everything works fine

Just not going through verification on ur website.

So i know the right place where "orderconfirmation" file should be.

Just need to create it in right way with "<?php

" or withought.

Shafiq Tajbhai - Merchant Acquisition

without please

and you will need to remove %%

this is what we’re saying on our logs… 213.219.116.250 - - [13/Aug/2015:05:24:18 -0700] "GET /sale.php?value=0&oid=&sid=%%1904%%&pid=DEFAULT HTTP/1.1" 200 60 "http://sportkid.eu/en/order-confirmation?

 

Sportkid.eu OU

one moment

ill try one more time

 

Shafiq Tajbhai - Merchant Acquisition

ok

 

Sportkid.eu OU

Could u check logs now?

 

Shafiq Tajbhai - Merchant Acquisition

looks better… 213.219.116.250 - - [13/Aug/2015:05:55:41 -0700] "GET /sale.php?value=&oid=&sid=1904&pid=DEFAULT HTTP/1.1" 200 207 "http://sportkid.eu/en/order-confirmation?

does it let you continue on the merchant side

 

Sportkid.eu OU

Okey ) Soo.. Should i get verified now or still something dosent works?

Yeap... Dosent lets me through

 

Shafiq Tajbhai - Merchant Acquisition

ok bear with me

 

Sportkid.eu OU

Ok (P.S As i understand Tracking works only when "OrderConfirmationController" configured correctly so in some point i succeeded ^__^

 

Shafiq Tajbhai - Merchant Acquisition

ok I’m going to consult one of my colleagues

 

Sportkid.eu OU

Okey) Take ur time

Actually GET /sale.php?value=HERE SHOULD BE VALUE&

 

GET /sale.php?value=&oidHERE SHOULD BE ORDER ID=&sid=1904

And if its Empty that means my "OrderConfirmationController" is not Configured well

 

Shafiq Tajbhai - Merchant Acquisition

yes that’s correct you must send us an order ID

 

Sportkid.eu OU

Okey atleast tracking is done.

 

Shafiq Tajbhai - Merchant Acquisition

and value also,even if it records as 0.00 it will still tack and we are making progress

 

Sportkid.eu OU

One moment ill try again with different settings.

Ill be doing it 3-4 times so bear with me ^__^

 

Shafiq Tajbhai - Merchant Acquisition

sure no problem!

 

Sportkid.eu OU

Test nr1) File Placed Exactly as in described on ur Website.

Order made... so any changes in logs?

 

Shafiq Tajbhai - Merchant Acquisition

no… "GET /sale.php?value=&oid=&sid=1904&pid=DEFAULT

Sportkid.eu OU

Ok Test Nr2- File Placed in Different folder override/controllers/front/

 

Sportkid.eu OU

Order made any changes?

 

Shafiq Tajbhai - Merchant Acquisition

no… "GET /sale.php?value=&oid=&sid=1904&pid=DEFAULT

Are you trying any other methods?

 

Sportkid.eu OU

Yeap

I got modified code from Prestashop Community so triyng it now

 

Sportkid.eu OU

Test NR3 Modified Code Placed in override/controllers/front/

 

Code itselfe

 

class OrderConfirmationController extends OrderConfirmationControllerCore {

 

public function initContent() {

$cart = $this->context->cart;

 

$this->context->smarty->assign(array(

'shippingCost' => $cart->getOrderShippingCost(),

'orderTotal' => $cart->getOrderTotal()

));

 

parent::initContent();

}

 

}

Any luck?>

 

Shafiq Tajbhai - Merchant Acquisition

"GET /sale.php?value=0&oid=&sid=1904&pid=DEFAULT

value parameter shows 0

so some progress

we need an order id

 

Sportkid.eu OU

Hmmm...

Interesting that actually value should be 300 euros but since the order is made by (bank wire) i understand why its 0

 

Shafiq Tajbhai - Merchant Acquisition

you should still be able to pass through that value somehow even though you’re not taking payment at that time

 

Sportkid.eu OU

Ok lets do another test

Test nr 4 done.

 

Shafiq Tajbhai - Merchant Acquisition

back to square one… "GET /sale.php?value=&oid=&sid=1904&pid=DEFAULT

 

Sportkid.eu OU

Ok

Test Nr 5

done

 

Shafiq Tajbhai - Merchant Acquisition

"GET /sale.php?value=&oid=&sid=1904&pid=DEFAULT

 

Sportkid.eu OU

Test 6.

 

Shafiq Tajbhai - Merchant Acquisition

ok i refreshed and got this came through in the logs

"GET /sale.php?value=0&oid=&sid=1904&pid=DEFAULT

can you send a copy of your code please?

 

Sportkid.eu OU

OrderConfirmationController.php

So this file was given by Prestashop community

Yours docent work at all.

Also it works only in folder

override/controllers/front/

So atleast folder should be changed 100%

Okey Made Test 7. And im out of ideas....

 

Shafiq Tajbhai - Merchant Acquisition

213.219.116.250 - - [13/Aug/2015:07:00:58 -0700] "GET /sale.php?value=&oid=&sid=1904&pid=DEFAULT HTTP/1.1" 200 207 "http://sportkid.eu/en/order-confirmation?

Sportkid.eu OU

F**CK

 

So i wonder that "OrderConfirmationController" File allows Prestashop to use

 

global $cart;

self::$smarty->assign('shippingCost', $cart->getOrderShippingCost());

self::$smarty->assign('orderTotal', $cart->getOrderTotal());

parent::displayContent();

 

Basically "shippingCost" and "orderTotal"

 

"id_order" value is already exists since dont see any functions in Controller that reffers to it...

 

So why the hell it docent works!

 

Smoking Brake 5min

 

Unfortunately we’re running out of time. I’m unable to help further. Happy to check the logs whenever you need me to. Would the dev package be of any interest to you?

we’re sure to help you out once you are on board but we cannot guarantee any results

Sportkid.eu OU In some point.... Well i can spend 250pounds.

If ill be sure that it will bring results!

 

ok any thnx for help

Shafiq Tajbhai - Merchant Acquisition

 

What you could do is contact the dev contact. I’ll send you his email address and see if he’s able to negotiate a better rate after telling him that you’re very close to completing signup. He may offer you a better rate, he may not, but it’s worth a try

His email address is: [email protected]

 

 

Sportkid.eu OU For sure i would appriciate that

 

Shafiq Tajbhai - Merchant AcquisitionI think they’ll be able to help you very efficiently and quickly and do further tests for you.

7:28 am ok best of luck and stay in touch :)

Link to comment
Share on other sites

I've looked again in what variables you need in order-confirmation.tpl .

The shippingCost I don't see it used, the order id was assumed as existing by default but actually it has to be set and the orderTotal returns 0 because I used the wrong cart.

I've updated the code below:

<?php

class OrderConfirmationController extends OrderConfirmationControllerCore {
    
    public function initContent() {
        $cart = new Cart($this->id_cart);
        
        $this->context->smarty->assign(array(
            'id_order' => $this->id_order,
            'orderTotal' => $cart->getOrderTotal()
        ));
        
        parent::initContent();
    }

}

Link to comment
Share on other sites

Made a Test with a new code but still no luck.

Hello,

Can you do quick look in logs. (I just made test order with new code version)

Shafiq Tajbhai - Merchant AcquisitionGET /sale.php?value=&oid=&sid=1904&pid=DEFAULT

Sportkid.eu OU ok thnxs

Shafiq Tajbhai - Merchant Acquisitionno problem, any other ideas/


P.S Deleted Cache Etc..... last time there was at least Zero :wacko:

Link to comment
Share on other sites

I've tested the variables in order-confirmation.tpl and both are set now.

Maybe your override isn't taken into consideration again.

To test in tpl use the following code in the beginning:

{$id_order|p}
{$orderTotal|d}

After you click the "I confirm order" you should see a blank page with first value the id of order and second value the total to be payed.

If you don't see that, but only a blank apage and END, then the override it's not running and you should verify it's path again and delete cache/class_index.php

Link to comment
Share on other sites

Good News!  Friend of mine managed to get override working. The code is bellow. Thanks "Gabdara" without ur help we wouldnt reach this point.

But there is one big problem left. At this moment tracking sends to Paydot.com total order value including shipping cost.

But we need only product price without shipping expenses. Could you please advise how we can do this!

 

<?php

class OrderConfirmationController extends OrderConfirmationControllerCore {

    public function initContent() {
        $cart = $this->context->cart;
        $order = new Order($this->id_order);
        $this->context->smarty->assign(array(
            'shippingCost' => $cart->getOrderShippingCost(),
            'id_order' => $this->id_order,
            'orderTotal' => $order->getOrdersTotalPaid()
        ));

        parent::initContent();
    }

}

 

Link to comment
Share on other sites

SOLVED

 

 

<?php

class OrderConfirmationController extends OrderConfirmationControllerCore {

    public function initContent() {
        $cart = $this->context->cart;
        $order = new Order($this->id_order);
        $this->context->smarty->assign(array(
            'shippingCost' => $cart->getOrderShippingCost(),
            'id_order' => $this->id_order,
                        'orderTotal'=>$order->total_products_wt,
        ));

        parent::initContent();
    }

}

Link to comment
Share on other sites

Now i have another problem. When client pays through PayPal after payment is complete.
PayPal redirects to its own confirmation page

P.S I mean the page where client is redirected after he completed all the step on PayPals website.

So page looks like

http://sportkid.eu/r...03&id_order=104

And at this moment tracking docent works obviously.

My question how do i add tracking for PrestaShop PayPal module.

Should i add Same Override file to /htdocs/modules/paypal/controllers/front
 

Quote

 

<?php

class OrderConfirmationController extends OrderConfirmationControllerCore {

    public function initContent() {
        $cart = $this->context->cart;
        $order = new Order($this->id_order);
        $this->context->smarty->assign(array(
            'shippingCost' => $cart->getOrderShippingCost(),
            'id_order' => $this->id_order,
                        'orderTotal'=>$order->total_products_wt,
        ));

        parent::initContent();
    }

}


And then add tracking code to /htdocs/modules/paypal/views/templates/front
 

Quote

 

<img src="https://track.paydot...sale.php?value={$orderTotal}&oid={$id_order}&sid=1904&pid=DEFAULT" width="1" height="1">

to files order-confirmation.tpl and submit.php


P.S Have no idea how override works.  If added it ones should i add it again in PayPal Module Directory?

Link to comment
Share on other sites

Tried to add Tracking code to /htdocs/modules/paypal/views/templates/hook  confirmation.tpl          (But no results)
Tried to add Tracking Code to /htdocs/modules/paypal/views/templates/front order-confirmation.tpl (But no results)

 

 

 

P>S on the forum found similar case when someone tried to implement tracking to PayPal. (But this case is little bit different and i dont have skills to repeat it with mine variables)

 

 

EDIT: FOUND THE SOLUTION

Go to /modules/paypal/views/templates/front/order-confirmation.tpl

and put your affiliate tracking code. Mine is like:

<script type="text/javascript">
    affiliate.load_action("11628", "{Tools::getvalue('id_order')}", "1::{$total_wt_fpa}", "", "pending");
</script>

Then go to /modules/paypal/controllers/front/submit.php

near line 67, says

$price = Tools::convertPriceFull($paypal_order['total_paid'], $order_currency, $display_currency);

at the next line insert 

$total_wt_fpa = round((($order->total_products - $order->total_discounts) / 1.23), 2);

and also at the next array (lines 72-80) put one more line to send to tpl.

'total_wt_fpa' => $total_wt_fpa,

This is it!

Edited by sportkid (see edit history)
  • Like 1
Link to comment
Share on other sites

IMO adding the tracking code to /modules/paypal/views/templates/front/order-confirmation.tpl just like you did in the theme order-confirmation.tpl should work.

Maybe the smarty variable should be assigned again into a paypal php file, I'll have a look and see what I find.

Link to comment
Share on other sites

There are two files that extend the OrderConfirmationControllerCore and use their own function to display the order confirmation page for paypal:

/modules/paypal/express_checkout/submit.php

/modules/paypal/integral_evolution/submit.php

Instead of initContent(), paypal uses displayContent().

In both files add at the beginning of the displayContent() function the assignment for your smarty variables.

$order is already defined in express_checkout, add these lines after $order:

$cart = new Cart($order->id_cart);
        
$this->context->smarty->assign(array(
    'shippingCost' => $cart->getOrderShippingCost(),
    'id_order' => $order->id_order,
    'orderTotal' => $cart->getOrderTotal()
));

In integral_evolution the $order variable it's not what you need like the one in express_checkout.

Create $ord = new Order($id_order); and use this in the code above to replace $order.

Link to comment
Share on other sites

×
×
  • Create New...