I am trying to create some tracking events on OXID eShop Framework on a custom module but I can't find any event handlers or something to put the code on some custom pages, without editing the core files. What I want is to make some custom API calls if I am on product page, category page, basket, etc.
Is there any way I can handle this in a custom module?
OXID has no such events or hooks you might know from magento or shopware. You have two options:
1) For running server side php code you need to extend OXID's functions, e.g. render() function for the pages you want to track.
For the product page it would be "details" -> applications/controllers/details.php
category page is "alist.php" and basket is basket.php
2) Make client side api calls with simple JS. You could appent all your js code to a tempalte block (e.g. in header oder footer) and create some if-else logic for different controller classes.
Like here: https://github.com/OXID-eSales/oxideshop_ce/blob/b-5.3-ce/source/application/views/azure/tpl/layout/base.tpl#L32
You could also have a look at any tracking module for google analytics or piwik, they are pretty similar to what you want to do.
I can give you more examples if you want.
Related
I am writing an app and I want to make a switch button to hide/display 'Add to Cart' button by using this app. How can I write code and implement this in Liquid.
Assuming you are using PHP (Laravel) as the backend for your Shopify App you could use the "phpclassic/php-shopify" library and call the "ScriptTag" method to load an external Javascript file into a store's front-end. The JavaScript file would have to manipulate the DOM to hide/display the Add to Cart button.
Code to hide any add-to-cart buttons might look like:
Array.from(document.querySelectorAll('button.add-to-cart')).map(el=>el.style.display='none');
If you wanted to conditionally hide buttons for specific products, then the JavaScript file would need to talk to your App back-end to obtain that information.
Note that this does not involve Liquid at all. Liquid is the theme template laguage Shopify uses. Programmatically modifying the theme's liquid files is a more difficult approach and liquid files you've added via an App get left behind if your App is uninstalled.
I have a list of custom posts, and I want to have a sidebar, wherein the information associated with a post selected from the list to load.
If you insist on using ajax to do this then you will need an API for your WordPress site to call back into. Take a look at http://wp-api.org/. It won't necessarily be easy, but you should be able to get it setup and running and then put a piece of JavaScript in a widget to make the call and display the data.
Be careful, that plugin is under active development.
IMO, it would be easier to do this without ajax. Off the top of my head I would say that you could define a shorttag in your functions.php file and then put it in your widget. If the widget appears on a page with a post, pick up the post id, fetch the meta data, and display it.
Cheers!
=C=
I've created an admin component and now need to insert text on each page of the installing client. So I thought of using the function onContentPrepare but it's a method of a JPlugin class (a content plugin class to be exact).
Is there a way to invoke the component from the view in the same way like a plugin?
Short answer: No, you have to write a plugin. But that's not a big thing.
Long answer: On each request, exactly one component is called. Plugins are triggered at certain events within the control flow. The onContentPrepare event is triggered by the components (not from the Joomla! framework), so some components might not support it. Nevertheless, you can get access to the content of any component through plugins anyway - just use the onAfterRender event of the system plugins.
I'm currently trying to integrate Econda tracking in the one page checkout process of a magento webshop with the special requirement that the tracking which is normaly done on the thank-you-page already is done once the customer clicks the place-order-button (between button click and redirect to payment provider or thank-you-page). The tracking code itself is dynamically created by an magento extension and injected as html into the phtml file of the thank-you-page. By loading that phtml the information is sent. Also the order in magento must exists before the tracking code can be injected (means place order button must already be clicked).
Currently I'm trying to create an "invisible" phtml, which is loaded once the customer clicks place-order-button and which contains the tracking code. This page should be shown for some seconds and then forward/redirect to either the payment provider or the thank-you-page. This is where I'm totally lost.
I have an observer on the event that is fired once the order is complete/saved. This observer calls an action within my model. But the model can not load/show a phtml.
How can I load a custom phtml-file once the customer clicks the place-order-button, show this phtml for some seconds, and then dynamically forward to either payment provider or thank-you-page?
The Cart Success page, by its very nature is the place that you should be putting any e-commerce tracking Javascript or markup.
It's the very first thing to be delivered to the browser once all the necessary order processing has gone on in the back end. Delivering them to an interim page for only a few seconds seems cumbersome and ultimately inefficient. It's possible, but it's bad practice.
Do you have any particular reason why the success page is insufficient? I can't seem to find that in your question.
Loading a new block into your success page is an easy process. Learn some more about Layouts and Templates (Maybe try Alan Storm's tutorial here) and use this method.
There would be two more options:
You could add your tracking to the on click event of your button
You could use server side tracking using the econda PHP SDK
Here's how you can add tracking to click events
<script type="text/javascript">
function trackIt() {
window.emosPropertiesEvent({
siteid: "my-site.de",
content: "CONTENT-LABEL"
});
}
</script>
<tag onclick="trackIt();">content</tag>
Be careful using click event tracking in links, it will not work if your page unloads before the tracking event was send.
I could not find the english version of the econda PHP SDK documentation, so sorry, here are the German docs: https://support.econda.de/display/INDE/PHP-Helferklasse
As already mentioned, your thank-you page is the best place to add tracking. An additional reason is, that normally you want to track if a customer really ordered or not. Payment pages are common problems, so it makes no sense to add "order successful" tracking calls before.
I have created an Ajax cart in magento although it is a little hacky. It's not in a module or that. All I'm doing is using a script in the root of app that initialise mage and works with it.
What would be the correct way in implementing this? Ie how can I get my Ajax calls to interact wiu magento through a my module?
You should define a module, first and foremost. Once you've done that, you need to create controllers and actions such that they return the data you're looking for, but not the frame of the page. Since you get to define layout of the page, this shouldn't be too bad.
At that point, wiring the JS to the new actions should be as simple as changing URLs to your new, cleaner URLs.