Skip to main content

Trovaprezzi datalayer script after order confirmation

More
9 years 11 months ago #252368 by crealiagroup
-- HikaShop version -- : 2.6.4
-- Joomla version -- : 3.4
-- PHP version -- : 5.5

I need to integrate this code after a product (or a series of products) is confirmed:

<script type="text/javascript" src=" tracking.trovaprezzi.it/javascripts/tracking.min.js " async="true">

<script type="text/javascript">
window._tt = window._tt || [];
window._tt.push({ event: "setAccount", id: /* chiavemerchant */ });
window._tt.push({ event: "setOrderId", order_id: /* idordine */ });
window._tt.push({ event: "setEmail", email: /* emailcliente */ });
window._tt.push({ event: "addItem", sku: /* sku */, product_name: /* nomeprodotto */ });
window._tt.push({ event: "setAmount", amount: /* totalecarrello */ });
window._tt.push({ event: "orderSubmit"});
</script>

Where the string "window._tt.push({ event: "addItem", sku: /* sku */, product_name: /* nomeprodotto */ });" is repeated for each product of the order.
If i have 3 product on order confirmed, i have to generate a string for each of these.

Is it possible to create? Contact us please.

Please Log in or Create an account to join the conversation.

More
9 years 11 months ago #252372 by nicolas
Hi,

Yes, it's possible to do that. You can edit the file "after_end" via the menu Display>Views in order to add your custom code.

If you need someone to work on that for you, you can contact our partners:
www.hikashop.com/home/our-partners.html
The following user(s) said Thank You: crealiagroup

Please Log in or Create an account to join the conversation.

More
9 years 11 months ago - 9 years 11 months ago #252564 by crealiagroup
I found a script for virtuemart. Do you think i can use even for hikashop, changing the db fields?
Code:
//TPtpi implemntation –Start $TPtpi['chiaveMerchant']="yourMerchantKey"; $TPtpi['email']=$order['details']['BT']->email; $TPtpi['orderid']=$order['details']['BT']->virtuemart_order_id; //array of elemets for scrippt -End //Printing Script echo "<script type=\"text/javascript\" src=\"https://tracking.trovaprezzi.it/javascripts/tracking.min.js\"></script>"; echo "<script type=\"text/javascript\">"; echo "window._tt = window._tt || [];"; echo "window._tt.push({ event: \"setAccount\", id: '". $TPtpi['chiaveMerchant'] ."' });"; echo "window._tt.push({ event: \"setOrderId\", order_id: " . $TPtpi['orderid'] . " });"; echo "window._tt.push({ event: \"setEmail\", email: '" . $TPtpi['email'] . "' });"; foreach( $order['items'] as $p ) { $name=str_replace("'", "", $ p->order_item_name); echo "window._tt.push({ event: \"addItem\", sku: '" . $p->order_item_sku . "', product_name: '" . $name . "' });"; } echo "window._tt.push({ event: \"orderSubmit\"});"; echo "</script>"; //TPtpi implemntation -End
Last edit: 9 years 11 months ago by nicolas.

Please Log in or Create an account to join the conversation.

More
9 years 11 months ago #252591 by nicolas
Hi,

If you change all the variables to use HikaShop's then yes.
For example,
Code:
$order['details']['BT']->virtuemart_order_id
is $this->order->order_id and
Code:
$order['details']['BT']->email
is $this->order->customer->user_email
The variables available in $this->order are listed here:
www.hikashop.com/support/documentation/156

Please Log in or Create an account to join the conversation.

More
9 years 11 months ago #252888 by crealiagroup
Thanks for reply Nicolas,

I would ask you if the "after_end" view will be always loaded (and user redirected) with every payment method. For example if user pays with PayPal or Credit card, will this page displayed before or after the payment?

This is necessary to execute the script for every transaction.

Please Log in or Create an account to join the conversation.

More
9 years 11 months ago #252902 by Mohamed Thelji
Hello,

The 'after_end' view will only be called after the return of your customer from a payment platform like PayPal (you'll have to make sure that payment methods like PayPal don't have any "Return Url" through your payment methods configuration page).
But the "after_end" view won't be called if you use payment methods like "HikaShop check payment plugin" instead the "check_end" view of the payment plugin will be called.

Please Log in or Create an account to join the conversation.

More
9 years 11 months ago #253008 by crealiagroup
Maybe we should work on a different way. Maybe a plugin that fires the trigger and generate the script when the order is created (or confirmed and so on...), right?

Please Log in or Create an account to join the conversation.

More
9 years 11 months ago #253020 by Mohamed Thelji
Hello,
Sure, that's a good idea, the solution will be to create a plugin based on the "onAfterOrderCreate" function :
www.hikashop.com/support/documentation/6...l#onAfterOrderCreate

Please Log in or Create an account to join the conversation.

Time to create page: 0.192 seconds
Powered by Kunena Forum