As soon as you add something to the cart a cookie is set with durationNormal (two hours), see Kirby Reference options/session.
When you use Stripe additional cookies are set by Stripe’s JavaScript.
Orders are stored as order.txt pages within content/orders (or another folder, depending on your Merx configuration)
No, you don’t need to set up any of the API Keys unless you want to use Stripe or PayPal. If you only want to use PayPal, you only need to provide the PayPal keys. Furthermore you don’t need the live keys as long as you are testing. The sandbox/live keys are toggled by the ww.merx.production option.
Same for me.
Just added exactly what the plainkit contains but don’t know why after clicking to “add product”, the page goes to /add and return the error page.
Tried to get more details with $ex->toArray() but didn’t get anymore.
I’m running with 3.3.5 and two languages, I have removed every plugins but it doesn’t come from here.
This is my code, the same as @jamiehunter
two languages is a good hint. The html form’s action is add (See site/templates/home.php:3). Which is a bit sloppy. The action attribute should be <?= url('add') ?> to make sure it always points to domain.tld/add and the add route is triggered. I updated the Plainkit with this patch.
Changing add to <?= url('add') ?> into the form doesn’t change. It’s like the route is not triggered as expected, it’s always redirected to the “add” page.
Yes, I’m running into a subfolder. Uncommenting didn’t work. When I change to add into my route, the page is still getting into the /add page as an error, without any request returned.
It’s reacting as if the route didn’t want to be listened.
If you want to check my settings, I’ve set all my config into this link
EDIT : I had an other route for sitemap into my config file. This is the lines :
So sorry for my mistake about the route writting, I’m trying to fix that bug. I’m getting the error Item “” could not be added to cart.
I’ve set return $ex->toArray(); to show me what’s going wrong. I get this :
|exception|"Kirby\\Exception\\Exception"|
|---|---|
|message|"L’article \"editions/edition1\" n’a pas pu être ajouté au panier."|
|key|"error.merx.cart.add"|
|file|"CREDAC2/site/plugins/merx/src/cart.php"|
|line|49|
|details||
|exception|{}|
|code|500|
So this is pointing to the line 49 of the cart.php file on
Thank you very much for taking the time to look at the code. The second route was indeed a mistake on my part.
But I didn’t know we have to strictly named the file product as product.txt to make it work. This seems to be the right solution.
I am now faced with another problem, when I click on “add to cart”, I have an error message saying
A non well formed numeric value encountered
pointing on the line 28 inside : /site/plugins/merx/index.php
Great job on merx @tobiasfabian. I’ve been playing around with it (through babyreport.de) to get a feel for it.
One thing I was looking at was product variants and stock control (I’ve seen the cookbooks for each). Having product child variants also use product.txt is a little limiting. It would be nice to use variant.txt for product children, is that a bunch of work? Alternatively within a product it would be nice to use a variants structure field with variant title and stock fields to handle this. Would make it a lot easier to manage. Is it possible to update the stock value within a structure field on the product page?
On another note with the mjml for the emails, is it possible to export php (I’m using the vscode plugin)? Whenever I do this I have to add the use merx php line to the top of each template.
I could identify the <?= formatPrice($item['sumTax']) ?> call, inside the cart snippet, is getting the error from formatPrice function although my taxes field are set inside my product.txt files.
Still investigating on this but don’t know where could it come from.
I looked at the code and with the latest commit removed the check for the product template since it’s no longer needed. As long as your page has a price field you now can add everything to your cart.
@Oziris this might be interesting for you as well. You can rename your product.txt pages to edition.txt
A variants structure field would also be possible. You can update the stock and set the new structure data by $structure->data(). I would prefer variant.txt pages since updating and saving structure fields feels a bit difficult to me.
mjml: I also used the VSCode plugin and then manually inserted the $page variables. For the shop I’m currently building I go for very simple html emails. Just paragraphs, links and maybe bold/italic text – no table layouts.