How to check completed payments with facebook pixel?

  • Posts: 224
  • Thank you received: 8
5 years 1 month ago #304595

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

Last edit: 5 years 1 month ago by oloccina.

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

  • Posts: 81540
  • Thank you received: 13071
  • MODERATOR
5 years 1 month ago #304600

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).

The following user(s) said Thank You: oloccina

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

  • Posts: 224
  • Thank you received: 8
5 years 1 month ago #305130

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

<script>
  fbq('track', 'Purchase', {
    value: <?php echo $this->order->order_full_price; ?>,
    currency: 'EUR',
  });
</script>

and
<?php echo $this->order->order_full_price; ?>
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

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

  • Posts: 81540
  • Thank you received: 13071
  • MODERATOR
5 years 4 weeks ago #305152

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:

<?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.

  • Posts: 224
  • Thank you received: 8
5 years 4 weeks ago #305156

Thank you!

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

  • Posts: 224
  • Thank you received: 8
5 years 4 weeks ago #305160

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)

<?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.

  • Posts: 81540
  • Thank you received: 13071
  • MODERATOR
5 years 4 weeks ago #305162

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.

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

  • Posts: 224
  • Thank you received: 8
5 years 3 weeks ago #305546

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: 5 years 3 weeks ago by oloccina.

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

  • Posts: 81540
  • Thank you received: 13071
  • MODERATOR
5 years 3 weeks ago #305547

Hi,

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.

  • Posts: 224
  • Thank you received: 8
5 years 1 week ago #305851

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

<?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: 5 years 1 week ago by Jerome. Reason: indent code

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

  • Posts: 81540
  • Thank you received: 13071
  • MODERATOR
5 years 1 week ago #305870

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, '.', ''); ?>

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

Time to create page: 0.049 seconds
Powered by Kunena Forum