Please exuse me if my questions sound to stupid to you.
Installation
I try to understand how to install the Snipcart Plugin for Kirby (installinstructions see here).
Under “Install” there is “Download” and “Composer”.
Do I have to do the Download- AND the Composer-Method or just using one of both methods?
I tried both.
When I use Composer, in which directory do I have to run it? In the root or the plugin folder?
I tried both and it generats extrafolders like “vendor” (with alot of files inside) and so on. But the Download-Method does not contain this folder, why? Shoudn’t both methods be equal?
It confuses me alot.
What is the correct installation-method?
Usage
Cartsnippet: <?= snippet('cart/init') ?>
When I use the Download-Install-Method then there is no init.php file anywhere ergo this snippet code will not work. Or does automatically use cart/cart-init.php instead?
Edit: I just found the explanationin index.php of the Plugin: cart/init' => __DIR__ . '/snippets/snipcart/cart/cart-init.php
What are the other snippets for? I see that they just replace some lines of code. They are not real timesaver, I guess. Just another kind of organisation of the code, right?
If yes, what is the real benefit of this Plugin?
In which file do I have to put the “code” for “Options”? In /site/config/config.php?
Why is there so mutch vue.js in the Plugin?
Where is it used?
Composer would usually be the preferred method if you use Composer for you complete setup. Otherwise you can just download the zip and put the unzipped plugin folder into your /site/plugins or install as submodule via Git.
If you want to install with composer, don’t do it in the project root, otherwise you will end up with a second Kirby installation and your site will stop running.
Yes.
That’s for the Panel part of the Plugin. The Panel is a Vue app.
What I will never understand is, why developers tend to create so minimalistic documentations.
A few words more would have answered so many questions and saved SO mutch time for newbies like me
My guess is, they wanna keep their knowledge rare and precious
The word “or” between “Download” and “Composer” would have answered the first question.
The line /site/config/config.php would have answered the “Options”-question.
I’m still trying to find out how to use that Panelview, to me the most interesting part of the Plugin.
I wanna list all the orders which are in the order listing of the dashboard in snipcart.
How can I do that?
There is a dedicated panel view you can access using the menu at the top of the screen on the left hand side of the black bar. Press the little hamburger and choose Snipcart from the drop down list and you will see something like this:
In an ideal world, it would. But keep in mind that many devs create such plugins because they have a need themselves or do it in their sparetime, and then make it available to the public. They invest a lot of time and effort to produce the code. There is not always time to come up with extensive documentation in such circumstances.
If you want to help out to make it easier for others, why not make a PR with your suggested changes? Get involved! Give back! Buy a coffee for the devs.
A PR request is when you use github to make changes to someone elses project and then submit a “Pull Request” which basically you means you would like me to review and merge your modifications into the plugin so that everyone gets that update going forward.
this.$api is how the Vue components communicate with the Kirby PHP API, which is working in tandem with a custom route in this case. This is a Kirby feature, and not something specific to my plugin. The plugin communicates with a couple of different endpoints in the Snipcart API and gets the response back as JSON from Snipcart. (:all) is the param which in the the example above is “orders”. Basically the Vue component hits the custom route via www.yourdomain.com/snipcart/orders using PHP and passes a valid JSON response through to the Vue component so that it can work with it.
The plugin currently only reads data from Snipcart, it currentlly does not go the other way to update Snipcart from the panel, but if you are able to add that functionality, feel free to do so and submit a PR.
@jimbobrjames thanks for that additional information.
I the documentation of Kirby I can only find a remote::get function (which you also use in your Plugin).
But how can I define a put request to the Snipcart API?
Your route is a GET route, not a route that listens to a POST request, but then your fetch request is also a GET request and not a POST request, so you cannot send data with it. In both cases, to make your route listen to POST requests, you have to set the method property. And to make your fetch request a POST request, you also have to set the method.
What is right method to POST data to the Snipcart API from the vue.js-component perspective?
Javascript fetch > PHP route > Snipcart API
or
Javascript fetch > Snipcart API?
In the end the Snipcart API listens to CURL and if I understand it right, the Kirby remote::request handels CURL automatically?
I’m missing the part where you do something with the data you send to your route…, instead you send $snipcart when you do the remote request, but that variable is only assigned an empty array.
The question is, how do I transmit the data from the Javascript code to the PHP route (see snippets above)?
Or in other words: How can I put some data into $snipcart via Javascript?