Jump to content

Tracking cookies after payment


Recommended Posts

Hello,

I have developed a module to track cookies after CB payment as Google Analytics does not track all orders placed on my website.
I use the Tarteaucitron service for the GDPR.
All payments that are made other than with CB, I can retrieve the status of cookies (true or false).
For payments made by credit card, I have no feedback.

Do you have any idea why the cookies are not retrieved?
Is there another hook I can use that could help me do what I need?

Thanks for your help.

I use the following code (based on the hook actionObjectOrderAddAfter):

 

public function hookActionObjectOrderAddAfter($params)
    {
        $payment = $params['object']->payment;
        $date_add = $params['object']->date_add;
        $total_paid_tax_incl = $params['object']->total_paid_tax_incl;
        $reference = $params['object']->reference;

        $rgpd = isset($_COOKIE['tarteaucitron']) && !empty($_COOKIE['tarteaucitron']) ? $_COOKIE['tarteaucitron'] : 'N/D';

        $sql_select = 'SELECT id_order FROM `' . _DB_PREFIX_ . 'orders` WHERE `reference` = "'.$reference.'"';
        $id_order = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql_select);
        
        $sql = array();

        $sql[] = 'INSERT INTO `' . _DB_PREFIX_ . 's2m_trackingpaiement` (`id_order`, `reference`, `total_paid_tax_incl`, `rgpd`, `payment`, `date_add`, `hook`)
        VALUES ("'.$id_order.'", "'.$reference.'", "'.$total_paid_tax_incl.'", "'.$rgpd.'", "'.$payment.'", "'.$date_add.'", "actionObjectOrderAddAfter")';

        foreach ($sql as $query) {
            if (Db::getInstance()->execute($query) == false) {
                return false;
            }
        }
    }

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...