- Posts: 255
- Thank you received: 2
Pinterest Integration
-- HikaShop version -- : 4.5.0
-- Joomla version -- : 3.10.6
-- PHP version -- : 7.4.28
-- Browser(s) name and version -- : chrome
I am working to integrate Pinterest and Hikashop. I have added their base code to the head of the site just fine. Now I need to add "add to cart", "checkout" and "page visit" to the site. I THINK I need to add it to each product page. Howe do I add script to each product page?
Please Log in or Create an account to join the conversation.
Go in the menu Display>Views of HikaShop. There edit the file product / show for your frontend template and you can add your javascript in there.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
I don't think there is anything in HikaShop which does that for the product description. It's probably your HTML editor.
In the HikaShop configuration, you can change the "editor" setting to "none" to get a normal textarea instead of the HTML editor. That way you'll be able to check if it works like that, which would confirm it comes from the HTML editor, and maybe it has a setting to toggle to allow for that.
Alternatively, you can also create a custom field of the table "product" with ti's "input filtering" setting turned off via the menu Display>custom fields to add your code, and then in the product / show view file, you can use such code:
<?php echo $this->element->xxx; ?>
where xxx is the column name of the custom field.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
I have added them to:
"cart / showcart.php" and "checkout / show.php" -- I do not think it is working correctly and cannot see them in source file.
Is this the best spot?
"sample"
Please Log in or Create an account to join the conversation.
If you want to add javascript code on the checkout, you can indeed add it in the checkout / show view file.
I actually do see your javascript code on the checkout page on your website:
i.imgur.com/IDJwjCY.png
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
You can. For that, instead of directly writing your Javascript code inside script tags, you want to use the addScriptDeclaration method of Joomla:
docs.joomla.org/Adding_JavaScript
This method will add the script tags around your JS code and will add all that to the bottom of the head tag of the page.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
In a previous message ( www.hikashop.com/forum/integrations/9041...egration.html#340336 ), you said that you had added your javascript code to "cart / showcart.php" and "checkout / show.php".
So I was thinking you would use an addScriptDeclaration call in these.
Please Log in or Create an account to join the conversation.
I previously put this code (below)in "cart / showcart.php" page and it shows up at the bottom of page source just fine, but it needs to be in the head. So now I need to use the addScriptDeclaration as you suggested.
<script>
pintrk('track', 'addtocart', {
value: 10.00,
order_quantity: 1,
currency: 'USD'
});
</script>
I am not exactly sure how to implement it. Trying to learn a few new things - I found this below:
Inline JavaScript
Blocks of JavaScript code can be declared directly within a component or module's display template using the JDocument class' addScriptDeclaration method:
```
<?php
$document = JFactory::getDocument();
$document->addScriptDeclaration('
window.event("domready", function() {
alert("An inline JavaScript Declaration");
});
');
?>
```
Question1 - So I need to put this code in my "cart / showcart.php" page. Where do I put the script, Inside the brackets?
<?php
$document = JFactory::getDocument();
$document->addScriptDeclaration('
window.event("domready", function() {
alert("An inline JavaScript Declaration");
});
');
?
<script>
pintrk('track', 'addtocart', {
value: 10.00,
order_quantity: 1,
currency: 'USD'
});
</script>>
I am a bit lost here - or do I put it somewhere else in my template and point to it???
+++++++
Question 2 - Here is a script commonly used in pinterest:
<script>
pintrk('track', 'pagevisit', {
line_items: [
{
product_id: {{ product.id }}
}
]
});
</script>
This part:
"product_id: {{ product.id }}"
will this automatically pull my hikashop product id and use it ? - at one time I was thinking I had to add this code with my actual product id pasted in - such as "product_id: {{ lp_3cyl }}" - I think this is incorrect?
Last Question/comment - I do not see a lot of info about using Pinterest with Hikashop - lots of stuff with Shopify and other systems. I really would like to see Hikashop playing nice with Pinterest - It would add value to Hikashop and their users. If you have any other links regarding Pinterest integration, please let me know.
Thank you for answering all my uninformed questions.
Bill
Please Log in or Create an account to join the conversation.
If you've added the code:
In order to track everything (products, carts, orders), it requires the development of a plugin with hundreds of lines of code, similarly to what we did with the GA4 and Matomo plugins on our marketplace.
It's possible, but it's not something I can do for you here and if you're not familiar with PHP, you won't be able to do it either.
Please Log in or Create an account to join the conversation.
$document = JFactory::getDocument();
$document->addScriptDeclaration("
pintrk('track', 'addtocart', {
value: 10.00,
order_quantity: 1,
currency: 'USD'
});
");
to the bottom of this page:
www.beeswaxcandleshop.com/cart/checkout.html
Looking at the page source, I see it in the bottom of the body, but not in the head where I want it - Did I do something wrong?
(I must have - I am seeing this code in bottom of live checkout page - oops)
Please Log in or Create an account to join the conversation.
You need to add PHP tags around your PHP code:
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
What you could do then is to use this code:
Please Log in or Create an account to join the conversation.