tracking code to heureka page

  • Posts: 36
  • Thank you received: 0
4 years 4 months ago #313333

-- HikaShop version -- : 4.2.2
-- Joomla version -- : 3.9.8
-- PHP version -- : 7.2.7
-- Browser(s) name and version -- : chrome

Hello,

can You please help me with implementing tracking code to hikashop?
As I find out, it should go in view end.php
code should look like:

<?php
require_once __DIR__ . '/../vendor/autoload.php';
try {
// Use your own API key here. And keep it secret!
$apiKey = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$options = [
// Use \Heureka\ShopCertification::HEUREKA_SK if your e-shop is on heureka.sk
'service' => \Heureka\ShopCertification::HEUREKA_SK,
];
$shopCertification = new \Heureka\ShopCertification($apiKey, $options);
// Set customer email - it is MANDATORY.
$shopCertification->setEmail('This email address is being protected from spambots. You need JavaScript enabled to view it.');
// Set order ID - it helps you track your customers' orders in Heureka shop administration.
$shopCertification->setOrderId(1597884);

// And finally send the order to our service.
$shopCertification->logOrder();
// Everything went well - we are done here.

I need to import in this code user mail who created the order and also order number

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

  • Posts: 81481
  • Thank you received: 13062
  • MODERATOR
4 years 4 months ago #313338

Hi,

The order id is available in $this->order->order_id and the email is available in $this->order->customer->user_email
in the view file checkout / end.php

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

  • Posts: 36
  • Thank you received: 0
4 years 4 months ago #313369

Thank You for Your replay
I implemented it like this:

<?php
require_once __DIR__ . '/../vendor/autoload.php';
try {
// Use your own API key here. And keep it secret!
$apiKey = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$options = [
// Use \Heureka\ShopCertification::HEUREKA_SK if your e-shop is on heureka.sk
'service' => \Heureka\ShopCertification::HEUREKA_SK,
];
$shopCertification = new \Heureka\ShopCertification($apiKey, $options);
// Set customer email - it is MANDATORY.
$shopCertification->setEmail('$this->order->customer->user_email');
// Set order ID - it helps you track your customers' orders in Heureka shop administration.
$shopCertification->setOrderId($this->order->order_id);

// And finally send the order to our service.
$shopCertification->logOrder();
// Everything went well - we are done here.


but get this error:
Warning: require_once(/www/e/n/u123817/public_html/libraries/joomla/document/html/renderer/head.php): failed to open stream: No such file or directory in /www/e/n/u123817/public_html/templates/sj_thecool_free/error.php on line 44

Fatal error: require_once(): Failed opening required '/www/e/n/u123817/public_html/libraries/joomla/document/html/renderer/head.php' (include_path='.:/usr/local/php72/lib/php') in /www/e/n/u123817/public_html/templates/sj_thecool_free/error.php on line 44

I am not programmer and dont know what is wrong

I would be gratefull if You can help me

thank You

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

  • Posts: 81481
  • Thank you received: 13062
  • MODERATOR
4 years 4 months ago #313377

Hi,

That error comes from your template. I would recommend to contact your template provider about it.
What I can propose to fix it temporarily is to rename that error.php file from your template via FTP and copy the error.php file from the protostar template there. That should hopefully avoid the problem.

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

  • Posts: 36
  • Thank you received: 0
4 years 1 month ago #315939

Can You please help to transom next code from virtuemart to work with hikashop?

<?php
$orderModel = VmModel::getModel('orders');
$order = $orderModel->getMyOrderDetails($this->cart->virtuemart_order_id);
$query = ' www.heureka.sk/direct/dotaznik/objednavka.php?id= ';
$query.= 'HEUREKA ID';
$query.= '&email='.$order->email;
foreach ($order as $item) {
$query.= '&itemId[]='.$item->order_item_sku;
}
$query.= '&orderid='.$order->order_number;

$parsed = parse_url($query);
$fp = fsockopen($parsed, 80, $errno, $errstr, 5);
if ($fp) {
$out = "GET " . $parsed . "?" . $parsed . " HTTP/1.1\r\n" .
"Host: " . $parsed . "\r\n" .
"Connection: Close\r\n\r\n";
fputs($fp, $out);
while (!feof($fp)) {
$return .= fgets($fp, 128);
}
fclose($fp);
}
?>

and should I put it in end.php view?

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

  • Posts: 81481
  • Thank you received: 13062
  • MODERATOR
4 years 1 month ago #315957

Hi,

Here you go:

<?php 
$query = 'http://www.heureka.sk/direct/dotaznik/objednavka.php?id=';
$query.= 'HEUREKA ID';
$query.= '&email='.$this->order->customer->user_email;
foreach ($this->order->products as $item) {
  $query.= '&itemId[]='.$item->order_product_code;
}
$query.= '&orderid='.$this->order->order_number;

$parsed = parse_url($query);
$fp = fsockopen($parsed['host'], 80, $errno, $errstr, 5);
if ($fp) {
  $out = "GET " . $parsed['path'] . "?" . $parsed['query'] . " HTTP/1.1\r\n" . 
    "Host: " . $parsed['host'] . "\r\n" . 
    "Connection: Close\r\n\r\n";
  fputs($fp, $out);
  while (!feof($fp)) {
    $return .= fgets($fp, 128);
  }
  fclose($fp);        
}
?>
and yes, you want to put it either in the checkout/end.php view file or the checkout/after_end.php view file. I would recommend to start with the end.php file and see if that works for you.

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

  • Posts: 36
  • Thank you received: 0
4 years 1 month ago #315959

I implemented it like this:

<?php
/**
* @package HikaShop for Joomla!
* @version 4.2.2
* @author hikashop.com
* @copyright (C) 2010-2019 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><?php
if(empty($this->html)) {
echo JText::_('THANK_YOU_FOR_PURCHASE');
if(!empty($this->url))
echo '<br/>'.JText::sprintf('YOU_CAN_NOW_ACCESS_YOUR_ORDER_HERE', $this->url);
} else {
echo $this->html;
}
$this->nextButton = false;

<?php
$query = ' www.heureka.sk/direct/dotaznik/objednavka.php?id= ';
$query.= 'HEUREKA ID';
$query.= '&email='.$this->order->customer->user_email;
foreach ($this->order->products as $item) {
$query.= '&itemId[]='.$item->order_product_code;
}
$query.= '&orderid='.$this->order->order_number;

$parsed = parse_url($query);
$fp = fsockopen($parsed, 80, $errno, $errstr, 5);
if ($fp) {
$out = "GET " . $parsed . "?" . $parsed . " HTTP/1.1\r\n" .
"Host: " . $parsed . "\r\n" .
"Connection: Close\r\n\r\n";
fputs($fp, $out);
while (!feof($fp)) {
$return .= fgets($fp, 128);
}
fclose($fp);
}
?>

and I get this error:

Warning: require_once(/www/e/n/u123817/public_html/libraries/joomla/document/html/renderer/head.php): failed to open stream: No such file or directory in /www/e/n/u123817/public_html/templates/sj_thecool_free/error.php on line 44

Fatal error: require_once(): Failed opening required '/www/e/n/u123817/public_html/libraries/joomla/document/html/renderer/head.php' (include_path='.:/usr/local/php72/lib/php') in /www/e/n/u123817/public_html/templates/sj_thecool_free/error.php on line 44

I copied error.php from other template but it didnt help

any ideas?

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

  • Posts: 81481
  • Thank you received: 13062
  • MODERATOR
4 years 1 month ago #315961

Hi,

As the view file doesn't end with ?> you need to either add it before you add your code, or remove the first <?php of your code, or add your code at the beginning.
www.php.net/manual/en/language.basic-syntax.phptags.php

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

  • Posts: 36
  • Thank you received: 0
4 years 1 month ago #315974

OK, thanks

i got it, but now I get new error:
Warning: fsockopen() expects parameter 1 to be string, array given in /www/e/n/u123817/public_html/templates/sj_thecool_free/html/com_hikashop/checkout/end.php on line 30

I do not understand coding wery well

All I need to do is to send info about new order to heureka.sk
And heureka.sk sends to my customer demand to rate(vote) the order he made

My eshop needs to call this address after order is finished:
www.heureka.sk/direct/dotaznik/objednavk...mple@email.sk&itemId []=206210&orderid=123456

I would be very thankfull if You can help me

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

  • Posts: 12953
  • Thank you received: 1778
4 years 1 month ago #315990

Hello,

Your issue is coming from both of these lines :

$parsed = parse_url($query);
$fp = fsockopen($parsed, 80, $errno, $errstr, 5);

The problem is that $parsed is an array, so you'll have to see what's in that variable and convert it to a string if you want the fsockopen to properly work.

Kind regards,
Mohamed.

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

  • Posts: 36
  • Thank you received: 0
4 years 1 month ago #316007

Is there any other way to call this address?
www.heureka.sk/direct/dotaznik/objednavk...mple@email.sk&itemId []=206210&orderid=123456

Itemid is not mandatory

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

  • Posts: 36
  • Thank you received: 0
4 years 1 month ago #316023

now I changed the code:

<?php
/**
* @package HikaShop for Joomla!
* @version 4.2.2
* @author hikashop.com
* @copyright (C) 2010-2019 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><?php
if(empty($this->html)) {
echo JText::_('THANK_YOU_FOR_PURCHASE');
if(!empty($this->url))
echo '<br/>'.JText::sprintf('YOU_CAN_NOW_ACCESS_YOUR_ORDER_HERE', $this->url);
} else {
echo $this->html;
}
$this->nextButton = false;


$query = ' www.heureka.sk/direct/dotaznik/objednavka.php?id= ';
$query.= 'HEUREKA ID';
$query.= '&email='.$this->order->customer->user_email;
$query.= '&orderid='.$this->order->order_number;


$fp = fsockopen($query, 80, $errno, $errstr, 5);
if ($fp) {
$out = "GET " . $query .
"Connection: Close\r\n\r\n";
fputs($fp, $out);
while (!feof($fp)) {
$return .= fgets($fp, 128);
}
fclose($fp);
}
?>

but get this error:

Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: hostname nor servname provided, or not known in /www/e/n/u123817/public_html/templates/sj_thecool_free/html/com_hikashop/checkout/end.php on line 30

Warning: fsockopen(): unable to connect to www.heureka.sk/direct/dotaznik/objednavka.php?id=HEUREKA ID&email=info@example.sk&orderid=920020581:80 (php_network_getaddresses: getaddrinfo failed: hostname nor servname provided, or not known) in /www/e/n/u123817/public_html/templates/sj_thecool_free/html/com_hikashop/checkout/end.php on line 30

what can be wrong?

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

  • Posts: 81481
  • Thank you received: 13062
  • MODERATOR
4 years 1 month ago #316029

Hi,

On the line:

$query = 'www.heureka.sk/direct/dotaznik/objednavka.php?id=';
You're missing the https://
So it should be:
$query = 'https://www.heureka.sk/direct/dotaznik/objednavka.php?id=';

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

  • Posts: 36
  • Thank you received: 0
4 years 1 month ago #316035

OK but now I get this error:

Warning: fsockopen(): unable to connect to https://www.heureka.sk/direct/dotaznik/objednavka.php?id=ba878678f84b0dde02b1cea4c02d625f&email=info@potravinyslovenska.sk&orderid=920020597:80 (Unable to find the socket transport "https" - did you forget to enable it when you configured PHP?) in /www/e/n/u123817/public_html/templates/sj_thecool_free/html/com_hikashop/checkout/end.php on line 26

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

  • Posts: 81481
  • Thank you received: 13062
  • MODERATOR
4 years 1 month ago #316038

Hi,

Looking online, it shoudl be ssl:// instead of https://
stackoverflow.com/questions/378574/unabl...cket-transport-https

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

  • Posts: 36
  • Thank you received: 0
4 years 1 month ago #316054

Hi,
with ssl:// I have the same error like mentioned above

Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: hostname nor servname provided, or not known in /www/e/n/u123817/public_html/templates/sj_thecool_free/html/com_hikashop/checkout/end.php on line 30

Warning: fsockopen(): unable to connect to www.heureka.sk/direct/dotaznik/objednavka.php?id=HEUREKA ID&email=info@example.sk&orderid=920020581:80 (php_network_getaddresses: getaddrinfo failed: hostname nor servname provided, or not known) in /www/e/n/u123817/public_html/templates/sj_thecool_free/html/com_hikashop/checkout/end.php on line 30

I am stacked

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

  • Posts: 81481
  • Thank you received: 13062
  • MODERATOR
4 years 1 month ago #316069

Hi,

It seems that your server is not able to open connections to the outside.
Probably a hosting issue.
In that case, remove the whole:

$fp = fsockopen($query, 80, $errno, $errstr, 5);
if ($fp) {
$out = "GET " . $query .
"Connection: Close\r\n\r\n";
fputs($fp, $out);
while (!feof($fp)) {
$return .= fgets($fp, 128);
}
fclose($fp);
}
?>
and add instead:
?><img src="<?php echo $query; ?>" />
and use https:// in the query, not ssl://
That way, it will be the browser of the customer which will call the URL and it should work fine.

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

  • Posts: 36
  • Thank you received: 0
4 years 1 month ago #316071

Hello,

thanks for Your response
now I get this error:
Warning: require_once(/www/e/n/u123817/public_html/libraries/joomla/document/html/renderer/head.php): failed to open stream: No such file or directory in /www/e/n/u123817/public_html/templates/sj_thecool_free/error.php on line 44

Fatal error: require_once(): Failed opening required '/www/e/n/u123817/public_html/libraries/joomla/document/html/renderer/head.php' (include_path='.:/usr/local/php72/lib/php') in /www/e/n/u123817/public_html/templates/sj_thecool_free/error.php on line 44

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

  • Posts: 12953
  • Thank you received: 1778
4 years 1 month ago #316072

Hello,

As it's said on the error message, you should check which file the "require_once" is trying to include through the file "/www/e/n/u123817/public_html/templates/sj_thecool_free/error.php". And see if that file exists.

Kind regards,
Mohamed.

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

  • Posts: 36
  • Thank you received: 0
3 years 3 months ago #328215

Hello,

after a while I returned to this issue and solved it

in end.php code should look like:


<?php
/**
* @package HikaShop for Joomla!
* @version 4.2.2
* @author hikashop.com
* @copyright (C) 2010-2019 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?><?php
if(empty($this->html)) {
echo JText::_('THANK_YOU_FOR_PURCHASE');
if(!empty($this->url))
echo '<br/>'.JText::sprintf('YOU_CAN_NOW_ACCESS_YOUR_ORDER_HERE', $this->url);
} else {
echo $this->html;
}
$this->nextButton = false;

$query = ' www.heureka.sk/direct/dotaznik/objednavka.php?id= ';
$query.= 'HEUREKA ID';
$query.= '&email='.$this->order->customer->user_email;
$query.= '&orderid='.$this->order->order_number;

?><img src="<?php echo $query; ?>" />

now at the end I get some small icon of picture because of the last line in code
can You tell me how will I call product ID which was bought? ( '&orderid='.$this->order->order_number)

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

Time to create page: 0.110 seconds
Powered by Kunena Forum