I have read the documentation and related questions about the Snipcart Plugin from @jimbobrjames , and still having trouble getting basic setup with my Snipcart account.
The instructions say to include your Snipcart API keys, I have tried including them in the index.php file of the plugin, and the config.php of my site, and both are not working:
(below: in config.php)
(below: in plugin’s index.php file)
Error message on the Snipcart panel:
I have no doubt this is basic for most, please let me know if someone can help out.
Such an awesome looking plugin, will definitely send jimbobrjames some € for their time
They need to be strings in the config.php file.
'apitestkey' => 'YOURKEYHERE'
It should not be wrapped in option() in config.php. You may need to revert the changes to you made to the plugin before it will work.
On a side note, i do know there were some recent major changes made to Snipcarts features and i have not yet had the time to check if that causes any issues for the the plugin. However, i will do in the next few days.
Thank you @jimbobrjames ! Appreciate your response.
I reverted the changes I made to the plugin and inserted my keys in the config.php file as you mentioned and it’s still not working for me-
(Getting the same error as above, ‘Cannot read property ‘reduce’ of undefined’).
I will try I bit more and see if the issue is on my end, hope it is rather than due to the Snipcart updates.
You also have to name your options correctly, see readme e.g.
'hashandsalt.kirby-snipcart.apikeytest' => 'XXXX',
Plugin options always have to include the developer and plugin names as prefixes.
Ahhhh yes @pixelijn that is right! thank you very much, the Snipcart panel is working now:cowboy_hat_face:
Unfortunately still not in the clear: I am getting this error when I add the Add to Cart button on my individual product page
<?= snippet('product/add') ?>
do you have any idea where this is coming from?
Ah ok I got it to work now- I changed some of the code in the product-add-to-cart.php file to reflect all the info I have for the products in the dashboard.
<button class="snipcart-add-item <?= $class ?>"
data-item-id="<?= $page->slug() ?>"
data-item-price="<?= $page->price()->html() ?>"
data-item-url="<?= $page->url() ?>"
data-item-description="<?= $page->ProductDescription() ?>"
data-item-image="<?= $page->image()->resize(150)->url() ?>"
data-item-name="<?= $page->title()->html() ?>"
data-item-custom1-options="<?= implode(' | ', $page->sizeoptions()->split(',')) ?>">
Add to cart
This might be pushing my luck, but do you have an idea of how you would allow a user-selected size variation get sent to the Snipcart button?
If I have these options that I want users to select before clicking Add to Cart, do you have an idea of how to send it to the custom field in the Snipcart button?
I tried using a PHP cookie, where I saved the user-selected size and sent it over to Snipcart like this:
data-item-custom1-options="<?= $_COOKIE['sizechoice'] ?>">
Add to cart
but , when a user would go back to select a new size it would still keep the old cookie value (I wasn’t sure how to reset it).
Does anyone have a better solution to send that selected size info into that Snipcart button? I have a less elegant workaround that I can use, so really happy to drop it here.
Thanks for all your help🙏
So awesome @jimbobrjames , thank you and @pixelijn for your help
Thats what I needed. Thanks!