- Posts: 224
- Thank you received: 8
How to check completed payments with facebook pixel?
7 years 7 months ago - 7 years 7 months ago #304595
by oloccina
How to check completed payments with facebook pixel? was created by oloccina
Hello,
is there a way to check completed payments with facebook pixel?
And if yes, in which file exactly should I paste the pixel code among the view files?
maybe
checkout > end
or
checkout > after_end
?
Thank you
is there a way to check completed payments with facebook pixel?
And if yes, in which file exactly should I paste the pixel code among the view files?
maybe
checkout > end
or
checkout > after_end
?
Thank you
Last edit: 7 years 7 months ago by oloccina.
Please Log in or Create an account to join the conversation.
7 years 7 months ago #304600
by nicolas
Replied by nicolas on topic How to check completed payments with facebook pixel?
Hi,
PolishedGeek had developed a facebook pixel plugin for HikaShop :
www.hikashop.com/forum/integrations/8927...ct-pages.html#282510
I'm not sure where they are with it, but it might be worth contacting them about it.
Otherwise, this thread contains already a lot of helpful information about adding a facebook pixel to HikaShop:
www.hikashop.com/forum/reports-statistic...d-other-scripts.html
As stated there, it's probably the file "after_end" where you want to add your code provided that your payment method directs to the payment gateway for the payment after the checkout and then comes back to your website and that you didn't set a return URL for the payment method. If you set a return URL, then it would have to be added to the thing which displays the return URL (it could be anything on your website so hard to say exactly).
PolishedGeek had developed a facebook pixel plugin for HikaShop :
www.hikashop.com/forum/integrations/8927...ct-pages.html#282510
I'm not sure where they are with it, but it might be worth contacting them about it.
Otherwise, this thread contains already a lot of helpful information about adding a facebook pixel to HikaShop:
www.hikashop.com/forum/reports-statistic...d-other-scripts.html
As stated there, it's probably the file "after_end" where you want to add your code provided that your payment method directs to the payment gateway for the payment after the checkout and then comes back to your website and that you didn't set a return URL for the payment method. If you set a return URL, then it would have to be added to the thing which displays the return URL (it could be anything on your website so hard to say exactly).
The following user(s) said Thank You: oloccina
Please Log in or Create an account to join the conversation.
7 years 7 months ago #305130
by oloccina
Replied by oloccina on topic How to check completed payments with facebook pixel?
Hello,
I have read those topics and I remain with just one doubt.
So I have this code to insert in the checkout > after_end file
and
should correctly show the total paid by the client
but if I insert that code in a custom return page (not the checkout > after_end file) will still hikashop be able to print that line of code?
Thank you
I have read those topics and I remain with just one doubt.
So I have this code to insert in the checkout > after_end file
Code:
<script>
fbq('track', 'Purchase', {
value: <?php echo $this->order->order_full_price; ?>,
currency: 'EUR',
});
</script>
and
Code:
<?php echo $this->order->order_full_price; ?>
but if I insert that code in a custom return page (not the checkout > after_end file) will still hikashop be able to print that line of code?
Thank you
Please Log in or Create an account to join the conversation.
7 years 7 months ago #305152
by nicolas
Replied by nicolas on topic How to check completed payments with facebook pixel?
Hi,
No, it won't work as you don't have anything in $this->order in other pages.
you would have do add such code before to load HikaShop and load $this->order:
No, it won't work as you don't have anything in $this->order in other pages.
you would have do add such code before to load HikaShop and load $this->order:
Code:
<?php
if(!defined('DS'))
define('DS', DIRECTORY_SEPARATOR);
if(!include_once(rtrim(JPATH_ADMINISTRATOR,DS).DS.'components'.DS.'com_hikashop'.DS.'helpers'.DS.'helper.php')) return true;
$order_id = hikaInput::get()->getInt('order_id');
if(empty($order_id)) {
$app = JFactory::getApplication();
$order_id = $app->getUserState('com_hikashop.order_id');
}
$this->order = null;
if(!empty($order_id)) {
$orderClass = hikashop_get('class.order');
$this->order = $orderClass->loadFullOrder($order_id, false, true);
}
?>
The following user(s) said Thank You: oloccina
Please Log in or Create an account to join the conversation.
7 years 7 months ago #305156
by oloccina
Replied by oloccina on topic How to check completed payments with facebook pixel?
Thank you!
Please Log in or Create an account to join the conversation.
7 years 7 months ago #305160
by oloccina
Replied by oloccina on topic How to check completed payments with facebook pixel?
Is it normal that I receive a 404 error and this message
0 Using $this when not in object context
when visiting the page where I have inserted the code not actually coming back from Paypal?
see: accademiainfinita.it/ordine-online-confermato
this is the code in the page (apart some text below it)
0 Using $this when not in object context
when visiting the page where I have inserted the code not actually coming back from Paypal?
see: accademiainfinita.it/ordine-online-confermato
this is the code in the page (apart some text below it)
Code:
<?php
if(!defined('DS'))
define('DS', DIRECTORY_SEPARATOR);
if(!include_once(rtrim(JPATH_ADMINISTRATOR,DS).DS.'components'.DS.'com_hikashop'.DS.'helpers'.DS.'helper.php')) return true;
$order_id = hikaInput::get()->getInt('order_id');
if(empty($order_id)) {
$app = JFactory::getApplication();
$order_id = $app->getUserState('com_hikashop.order_id');
}
$this->order = null;
if(!empty($order_id)) {
$orderClass = hikashop_get('class.order');
$this->order = $orderClass->loadFullOrder($order_id, false, true);
}
?>
<script>
fbq('track', 'Purchase', {
value: <?php echo $this->order->order_full_price; ?>,
currency: 'EUR',
});
</script>
Please Log in or Create an account to join the conversation.
7 years 7 months ago #305162
by nicolas
Replied by nicolas on topic How to check completed payments with facebook pixel?
Hi,
Well, it means that you're not inside a function inside a class object.
In that case, just replace $this->order by $order and it will work.
Well, it means that you're not inside a function inside a class object.
In that case, just replace $this->order by $order and it will work.
Please Log in or Create an account to join the conversation.
7 years 7 months ago - 7 years 7 months ago #305546
by oloccina
Replied by oloccina on topic How to check completed payments with facebook pixel?
Thank you,
I have tested this and can record payments in facebook, but not the value of them
since the format requested from FB is similar to
value: 123.00
I wonder if
value: <?php echo $order->order_full_price; ?>
returns this kind of format: XX.XX
thank you
I have tested this and can record payments in facebook, but not the value of them
since the format requested from FB is similar to
value: 123.00
I wonder if
value: <?php echo $order->order_full_price; ?>
returns this kind of format: XX.XX
thank you
Last edit: 7 years 7 months ago by oloccina.
Please Log in or Create an account to join the conversation.
7 years 7 months ago #305547
by nicolas
Replied by nicolas on topic How to check completed payments with facebook pixel?
Hi,
You can use such code instead for that:
<?php echo round($order->order_full_price,2); ?>
You can use such code instead for that:
<?php echo round($order->order_full_price,2); ?>
The following user(s) said Thank You: oloccina
Please Log in or Create an account to join the conversation.
7 years 6 months ago - 7 years 6 months ago #305851
by oloccina
Replied by oloccina on topic How to check completed payments with facebook pixel?
I have tested for some days the code you suggested
<?php echo round($order->order_full_price,2); ?>
but it seems that is still printing a total value like this XX
see nimb.ws/CiKnMN
while Facebook for what I understand want something like this XX.YY
for example it wants 77.00 and not 77
this is what Facebook sees right now for an order of 77 €
{"value":"77","currency":"EUR"}
and this is the code I am using
anything else I could try to get this correctly?
Thank you
<?php echo round($order->order_full_price,2); ?>
but it seems that is still printing a total value like this XX
see nimb.ws/CiKnMN
while Facebook for what I understand want something like this XX.YY
for example it wants 77.00 and not 77
this is what Facebook sees right now for an order of 77 €
{"value":"77","currency":"EUR"}
and this is the code I am using
Code:
<?php
if(!defined('DS'))
define('DS', DIRECTORY_SEPARATOR);
if(!include_once(rtrim(JPATH_ADMINISTRATOR,DS).DS.'components'.DS.'com_hikashop'.DS.'helpers'.DS.'helper.php')) return true;
$order_id = hikaInput::get()->getInt('order_id');
if(empty($order_id)) {
$app = JFactory::getApplication();
$order_id = $app->getUserState('com_hikashop.order_id');
}
$order = null;
if(!empty($order_id)) {
$orderClass = hikashop_get('class.order');
$order = $orderClass->loadFullOrder($order_id, false, true);
}
?>
<script>
fbq('track', 'Purchase', {
value: <?php echo round($order->order_full_price,2); ?>,
currency: 'EUR',
});
</script>
anything else I could try to get this correctly?
Thank you
Last edit: 7 years 6 months ago by Jerome. Reason: indent code
Please Log in or Create an account to join the conversation.
7 years 6 months ago #305870
by nicolas
Replied by nicolas on topic How to check completed payments with facebook pixel?
Hi,
If you want exactly 2 decimals, then you want to user the number_format function instead:
<?php echo number_format($order->order_full_price, 2, '.', ''); ?>
If you want exactly 2 decimals, then you want to user the number_format function instead:
<?php echo number_format($order->order_full_price, 2, '.', ''); ?>
Please Log in or Create an account to join the conversation.
Time to create page: 0.087 seconds