Jump to content
Gadgetto

SnipWire - Snipcart integration for ProcessWire

Recommended Posts

Thanks for your attention on those hookable methods, Gadgetto. Those will definitely be necessary for launching this site (the subscription pause button will get us in a lot of trouble otherwise!)

Another item for the list: when a user role with snipwire-dashboard permissions clicks on the additional tabs (Orders, Subscriptions, Abandoned Carts, Customers, Products, Discounts) within the Dashboard, they reach the 404 page instead. 

Share this post


Link to post
Share on other sites

I have another issue to report.

When I:

  • use "+ Add New" buttons to add a new page with my product template (as children of any of the three allowed parent templates)
  • enter the page Title on the admin /page/add/
  • hit Save

I get the error "New page '/page/path/' must be saved before files can be accessed from it"

If I uninstall SnipWire, the error message goes away. The product templates are my own, not the default SnipWire templates.

Share this post


Link to post
Share on other sites
5 hours ago, creativejay said:

I have another issue to report.

When I:

  • use "+ Add New" buttons to add a new page with my product template (as children of any of the three allowed parent templates)
  • enter the page Title on the admin /page/add/
  • hit Save

I get the error "New page '/page/path/' must be saved before files can be accessed from it"

If I uninstall SnipWire, the error message goes away. The product templates are my own, not the default SnipWire templates.

Do you have a hook on path method of PagefilesManager class?

I’ll try to reproduce this behavior, but I’d need more infos. Could you please send me the complete stack trace of the exception? You can use TracyDebugger for this.

How does your product template look like?

Share this post


Link to post
Share on other sites
On 3/10/2020 at 7:15 PM, creativejay said:

Thanks for your attention on those hookable methods, Gadgetto. Those will definitely be necessary for launching this site (the subscription pause button will get us in a lot of trouble otherwise!)

I just read you’d like to use subscriptions feature? Subscriptions are not yet supported by SnipWire.

Share this post


Link to post
Share on other sites
On 3/10/2020 at 7:15 PM, creativejay said:

Another item for the list: when a user role with snipwire-dashboard permissions clicks on the additional tabs (Orders, Subscriptions, Abandoned Carts, Customers, Products, Discounts) within the Dashboard, they reach the 404 page instead. 

I’ll have a look at this!

BTW, could you please file your issues on SnipWires GitHub repo? it is hard to keep the overview here in the forum.

Share this post


Link to post
Share on other sites

UPDATE 2020-03-21

SnipWire 0.8.5 (beta) released!

This update improves SnipWires webhooks interface and provides some other fixes and additions:

  • Catch module settings access for non super users
  • Fixes [#2] Dashboard not accessible for non SuperUsers
  • Added documentation (php comments) to Webhooks class and hookable event handler methods
  • All Webhooks event handler methods now have a return value (Snipcart payload)

Hookable event handler methods:

All hookable event handler methods will return an array containing payload Snipcart sent to your endpoint.
In addition the following class properties will be set:

$this->payload (The payload Snipcart sent to your endpoint)
$this->responseStatus (The response status your endpoint sent to Snipcart)
$this->responseBody (The response body your endpoint sent to Snipcart)

(Use the appropriate getter methods to receive these values!)

How to use the hookable event handler methods (sample):

$webhooks->addHookAfter('handleOrderCompleted', function($event) {
    $payload = $event->return;
    //... your code here ...
}); 

PLEASE NOTE: those hooks will currently only work when placed in init.php or init() or ready() module methods!
 

  • Like 1

Share this post


Link to post
Share on other sites
On 3/11/2020 at 5:34 PM, creativejay said:

I have another issue to report.

When I:

  • use "+ Add New" buttons to add a new page with my product template (as children of any of the three allowed parent templates)
  • enter the page Title on the admin /page/add/
  • hit Save

I get the error "New page '/page/path/' must be saved before files can be accessed from it"

If I uninstall SnipWire, the error message goes away. The product templates are my own, not the default SnipWire templates.

Hi @creativejay,

do you still have this issue?

If so, could you please file an issue in SnipWires GitHub repo and provide more information: https://github.com/gadgetto/SnipWire/issues

I could not reproduce this problem but I think I have too little information.

Share this post


Link to post
Share on other sites

Hi there, thanks so much for working as hard as you have been/still are on this module! I'm testing it out at the moment, and have come up against the error that was previously reported:

Quote

Can’t save page 0: /custom-cart-fields/: It has no parent assigned

Having dug into the code, I think I found the cause. My test PW installation is in a subdirectory - not its own host - and snipWireRootUrl returns the full path include the folders:

/misc/pw-snipwire/processwire/setup/snipwire/

In the installer, as this variable is only used to set the parent page for custom-cart-fields, could ExtendedInstaller.php be updated to use the path instead of full URL?

I updated it like this, re-installed, and it worked:

// In ExtendedInstaller::__construct():

$this->snipWireRootPath = rtrim($this->wire('pages')->findOne('template=admin, name=snipwire')->path, '/') . '/';

// in _installPage():

// Page "parent" key may have "string tags"
$parent = \ProcessWire\wirePopulateStringTags(
    $item['parent'],
    array('snipWireRootPath' => $this->snipWireRootPath)
);

// In SystemResources.php

'parent' => '{snipWireRootPath}',

 

  • Like 2

Share this post


Link to post
Share on other sites
1 hour ago, Craig said:

Hi there, thanks so much for working as hard as you have been/still are on this module! I'm testing it out at the moment, and have come up against the error that was previously reported:

Having dug into the code, I think I found the cause. My test PW installation is in a subdirectory - not its own host - and snipWireRootUrl returns the full path include the folders:

/misc/pw-snipwire/processwire/setup/snipwire/

In the installer, as this variable is only used to set the parent page for custom-cart-fields, could ExtendedInstaller.php be updated to use the path instead of full URL?

I updated it like this, re-installed, and it worked:


// In ExtendedInstaller::__construct():

$this->snipWireRootPath = rtrim($this->wire('pages')->findOne('template=admin, name=snipwire')->path, '/') . '/';

// in _installPage():

// Page "parent" key may have "string tags"
$parent = \ProcessWire\wirePopulateStringTags(
    $item['parent'],
    array('snipWireRootPath' => $this->snipWireRootPath)
);

// In SystemResources.php

'parent' => '{snipWireRootPath}',

 

Oh, you are right for sure! Thanks, I'll fix this.

Share this post


Link to post
Share on other sites

Thanks! 🙂

Share this post


Link to post
Share on other sites
On 3/21/2020 at 1:04 PM, Gadgetto said:

Hi @creativejay,

do you still have this issue?

If so, could you please file an issue in SnipWires GitHub repo and provide more information: https://github.com/gadgetto/SnipWire/issues

I could not reproduce this problem but I think I have too little information.

I wasn't able to correct it, but the website had to launch so I uninstalled the Module and am using the direct API for Snipcart in the php templates and their dashboard for managing orders.

Before I uninstalled, I couldn't find a single logged error anywhere.

Share this post


Link to post
Share on other sites

UPDATE 2020-04-06

SnipWire 0.8.6 (beta) released!

This update adds support for Snipcart subscriptions and also fixes some problems:

  • Finished subscriptions dashboard section
  • Added support for Snipcart subscriptions
  • Added necessary fields for subscription products
  • Added debug output for webhooks request payload data
  • Updated MarkupSnipWire to output subscription data-item-* tags
  • Fixed deletion of segmented caches
  • Fixed display of empty image field in product details
  • Fixed a problem with namespace in Countries.php
  • Fixed a problem with duplicate SKU check on page save
  • Fixed [#3] Installer error: Can’t save page 0: /custom-cart-fields/: It has no parent assigned

Please note:

The additional fields required for providing subscription based products are automatically installed with this update! You need to create a new template (best is to use the snipcart-product template as a base) and add these fields manually.

Snipcart subscriptions are only supported when using the Stripe payment gateway!

Share this post


Link to post
Share on other sites

Hello.

I am impressed by the work you have done with your module. Congratulations! You are incredible!.

I am evaluating snipcart for a store for a friend who has a very low budget. I would like to know how difficult it is to implement a new payment gateway, in my case I am from Chile and none of the gateways offered by snipcart can be used by credit cards here. I am not an expert in php nor in processwire. I have implemented websites in processwire, so I have some experience with the framework.

Share this post


Link to post
Share on other sites
11 hours ago, Krlos said:

Hello.

I am impressed by the work you have done with your module. Congratulations! You are incredible!.

I am evaluating snipcart for a store for a friend who has a very low budget. I would like to know how difficult it is to implement a new payment gateway, in my case I am from Chile and none of the gateways offered by snipcart can be used by credit cards here. I am not an expert in php nor in processwire. I have implemented websites in processwire, so I have some experience with the framework.

Thanks for your kind words!

Implementing a custom payment gateway is definitely possible with Snipcart. It’s quite a bit of work and depends on the API the payment provider offers.

EDIT: sorry, only possible with Snipcart v3. As v3 isn’t feature complete, SnipWire currently only supports v2.

As far as I know is PayPal also working in Chile!

Which other gateway did you have in mind?

— Martin

Share this post


Link to post
Share on other sites
On 4/10/2020 at 5:27 PM, Gadgetto said:

EDIT: sorry, only possible with Snipcart v3. As v3 isn’t feature complete, SnipWire currently only supports v2.

@Gadgetto thank you for your reply, Do you plan to update Snipwire to version 3?

In the meantime, I am testing your module to see if I can use it in any project in the near future.

Everything is working fine except when I try to place an order in test mode I get this error in the last step of the check out:

Everything works perfect, except when I'm placing an order and in the last step the payment throws this error:

We have not been able to validate your order. Looks like some product prices might have changed since you added them to the cart. Please review your order and try again.

 I changed the payment currency from Euro to CLP and snipwire was able to correctly read the change from Snipcart dashboard. I removed snipcart_item_price_eur field from snipcart-product template and added snipcart_item_price_clp.

Then it gives me the following message:

It looks like this item is not available anymore. You may need to contact the merchant to get this resolved as it may be a configuration problem. By continuing this item will be removed from your cart.

 


When I check the Snipwire log file I see this:

Snipcart product with SKU [BEER-10001] could not be fetched. 500 Internal Server Error:

I'm testing in my local machine.

Processwire 3.0.148.

 

 

Share this post


Link to post
Share on other sites
10 hours ago, Krlos said:

Do you plan to update Snipwire to version 3?

Definitely!
Unfortunately Snipcart v3 still isn't feature par with v2. As soon as this is the case I'll implement v3 APIs!

10 hours ago, Krlos said:

Everything works perfect, except when I'm placing an order and in the last step the payment throws this error:

I think I know what happened, so I've pushed a fix to the dev branch on GitHub: https://github.com/gadgetto/SnipWire/tree/dev

Could you please test if this works now and let me know?

Share this post


Link to post
Share on other sites

Hello,

I'm new to Snipcart and SnipWire, just a few questions before I try your module, which looks very promising!

I'm working on a multilanguage site (Italian/English/Cech) and I need to have three different currencies and (maybe) taxes.

Am I covered with SnipWire?

🙂

Share this post


Link to post
Share on other sites
16 hours ago, Marco Angeli said:

Hello,

I'm new to Snipcart and SnipWire, just a few questions before I try your module, which looks very promising!

I'm working on a multilanguage site (Italian/English/Cech) and I need to have three different currencies and (maybe) taxes.

Am I covered with SnipWire?

🙂

Hi Marco,

SnipWire supports multi currency. The taxes handling is very flexible: you could either use Snipcart's own taxes handling, an external taxes provider (like TaxJar) or the custom taxes provider of SnipWire (which has the most flexible taxes handling when it comes to shipping taxes calculation).

Starting with 2021 there will be new tax rules in Europe! In simplified terms, the VAT from the customers country must be charged (this is already the case when you sell digital products!).

This means that a shop system must reliably determine the country of the customer. This is currently not supported by SnipWire but will be in a future version! Nevertheless, some of the external taxes providers implemented by Snipcart already supports this kind of taxes handling.

Hopefully this clears things up a bit!

-- Martin

  • Like 1

Share this post


Link to post
Share on other sites

Hello,

I'm also getting this kind of error


Uff da… Fatal Error: Uncaught Error: Call to undefined function ukIcon() in site/templates/snipcart-shop.php:45

#0 wire/core/TemplateFile.php (318): require()
#1 wire/core/Wire.php (380): TemplateFile->___render()
#2 wire/core/WireHooks.php (823): Wire->_callMethod('___render', Array)
#3 wire/core/Wire.php (450): WireHooks->runHooks(Object(TemplateFile), 'render', Array)
#4 wire/modules/PageRender.module (536): Wire->__call('render', Array)
#5 wire/core/Wire.php (383): PageRender->___renderPage(Object(HookEvent))
#6 wire/core/WireHooks.php (823): Wire->_callMethod('___renderPage', Array)
#7 wire/core/Wire.php (450): WireHooks->runHooks(Object(ProcessW (line 45 of site/templates/snipcart-shop.php)

This error message was shown because: site is in debug mode. ($config->debug = true; => site/config.php). Error has been logged.

I installed SnipWire to my best knowledge, did the additional steps, created a SnipCart account, generated the public and the secret API key which I put in the module's settings, installed the product Snipcart products package, just not necessarily in that order. The only thing I didn't do is to set up the domains cause I'm working on the MAMP server

I also downloaded the _uikit.php clone from github as suggested by @dragan but I don't know how to install that.

So how to install that or is there another way to fix solve this issue?

Also, is there an alternative shopping module to snipcart because my requirements are very primitive. Just buying a product, no insights, no stats, no fancy stuff like "clients also bought" and whatnot. Really just a shopping cart, enter shipping and billing address and then checkout with paypal. Maybe a confirmation email. 

thanks for help!

 

Share this post


Link to post
Share on other sites
12 minutes ago, fruid said:

Hello,

I'm also getting this kind of error


Uff da… Fatal Error: Uncaught Error: Call to undefined function ukIcon() in site/templates/snipcart-shop.php:45

#0 wire/core/TemplateFile.php (318): require()
#1 wire/core/Wire.php (380): TemplateFile->___render()
#2 wire/core/WireHooks.php (823): Wire->_callMethod('___render', Array)
#3 wire/core/Wire.php (450): WireHooks->runHooks(Object(TemplateFile), 'render', Array)
#4 wire/modules/PageRender.module (536): Wire->__call('render', Array)
#5 wire/core/Wire.php (383): PageRender->___renderPage(Object(HookEvent))
#6 wire/core/WireHooks.php (823): Wire->_callMethod('___renderPage', Array)
#7 wire/core/Wire.php (450): WireHooks->runHooks(Object(ProcessW (line 45 of site/templates/snipcart-shop.php)

This error message was shown because: site is in debug mode. ($config->debug = true; => site/config.php). Error has been logged.

I installed SnipWire to my best knowledge, did the additional steps, created a SnipCart account, generated the public and the secret API key which I put in the module's settings, installed the product Snipcart products package, just not necessarily in that order. The only thing I didn't do is to set up the domains cause I'm working on the MAMP server

I also downloaded the _uikit.php clone from github as suggested by @dragan but I don't know how to install that.

So how to install that or is there another way to fix solve this issue?

Also, is there an alternative shopping module to snipcart because my requirements are very primitive. Just buying a product, no insights, no stats, no fancy stuff like "clients also bought" and whatnot. Really just a shopping cart, enter shipping and billing address and then checkout with paypal. Maybe a confirmation email. 

thanks for help!

 

The sample templates, which come as an additional installation, are based on the Regular site profile which is based on Markup regions output strategy and UIKit CSS framework.

ukIcon is a function in _uikit.php which is part of the regular site profile.

If you are using another profile or output strategy, you'll need to rewrite the template source. If you like to run a quick test - just install PW using the "regular" profile.

Share this post


Link to post
Share on other sites

Hi fruid,

Quote

Also, is there an alternative shopping module to snipcart because my requirements are very primitive. Just buying a product, no insights, no stats, no fancy stuff like "clients also bought" and whatnot. Really just a shopping cart, enter shipping and billing address and then checkout with paypal. Maybe a confirmation email. 

If your requirements are more basic you can always use snipcart with their default Dashboard. There's a good tutorial here:

https://snipcart.com/blog/processwire-ecommerce-tutorial

 

  • Like 1

Share this post


Link to post
Share on other sites
9 minutes ago, Marco Angeli said:

Hi fruid,

If your requirements are more basic you can always use snipcart with their default Dashboard. There's a good tutorial here:

https://snipcart.com/blog/processwire-ecommerce-tutorial

 

Even if your requirements are very basic it would be much easier to use the SnipWire module, because it comes with all necessary product fields and settings and an easy to use API variable to output cart and products.

Share this post


Link to post
Share on other sites
On 4/21/2020 at 5:22 PM, Gadgetto said:

The sample templates, which come as an additional installation, are based on the Regular site profile which is based on Markup regions output strategy and UIKit CSS framework.

ukIcon is a function in _uikit.php which is part of the regular site profile.

If you are using another profile or output strategy, you'll need to rewrite the template source. If you like to run a quick test - just install PW using the "regular" profile.

thanks, went for a new installation with "regular"-profile and it worked out fine.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By bernhard
      --- Please use RockFinder3 ---
    • By MoritzLost
      Cacheable Placeholders
      This module allows you to have pieces of dynamic content inside cached output. This aims to solve the common problem of having a mostly cacheable site, but with pieces of dynamic output here and there.  Consider this simple example, where you want to output a custom greeting to the current user:
      <h1>Good morning, <?= ucfirst($user->name) ?></h1> This snippet means you can't use the template cache (at least for logged-in users), because each user has a different name. Even if 99% of your output is static, you can only cache the pieces that you know won't include this personal greeting. A more common example would be CSRF tokens for HTML forms - those need to be unique by definition, so you can't cache the form wholesale.
      This module solves this problem by introducing cacheable placeholders - small placeholder tokens that get replaced during every request. The replacement is done inside a Page::render hook so it runs during every request, even if the response is served from the template cache. So you can use something like this:
      <h1>Good morning, {{{greeting}}}</h1> Replacement tokens are defined with a callback function that produces the appropriate output and added to the module through a simple hook:
      // site/ready.php wire()->addHookAfter('CachePlaceholders::getTokens', function (HookEvent $e) { $tokens = $e->return; $tokens['greeting'] = [ 'callback' => function (array $tokenData) { return ucfirst(wire('user')->name); } ]; $e->return = $tokens; }); Tokens can also include parameters that are parsed and passed to the callback function. There are more fully annotated examples and step-by-step instructions in the README on Github!
      Features
      A simple and fast token parser that calls the appropriate callback and runs automatically. Tokens may include multiple named or positional parameters, as well as multi-value parameters. A manual mode that allows you to replace tokens in custom pieces of cached content (useful if you're using the $cache API). Some built-in tokens for common use-cases: CSRF-Tokens, replacing values from superglobals and producing random hexadecimal strings. The token format is completely customizable, all delimiters can be changed to avoid collisions with existing tag parsers or template languages. Links
      Github Repository & documentation Module directory (pending approval) If you are interested in learning more, the README is very extensive, with more usage examples, code samples and usage instructions!
    • By Craig
      I've been using Fathom Analytics for a while now and on a growing number of sites, so thought it was about time there was a PW module for it.
      WayFathomAnalytics
      WayFathomAnalytics is a group of modules which will allow you to view your Fathom Analytics dashboard in the PW admin panel and (optionally) automatically add and configure the tracking code on front-end pages.
      Links
      GitHub Readme & documentation Download Zip Modules directory Module settings screenshot What is Fathom Analytics?
      Fathom Analytics is a simple, privacy-focused website analytics tool for bloggers and businesses.

      Stop scrolling through pages of reports and collecting gobs of personal data about your visitors, both of which you probably don't need. Fathom is a simple and private website analytics platform that lets you focus on what's important: your business.
      Privacy focused Fast-loading dashboards, all data is on a single screen Easy to get what you need, no training required Unlimited email reports Private or public dashboard sharing Cookie notices not required (it doesn't use cookies or collect personal data) Displays: top content, top referrers, top goals and more
    • By daniels
      This is a lightweight alternative to other newsletter & newsletter-subscription modules.
      You can find the Module in the Modules directory and on Github
      It can subscribe, update, unsubscribe & delete a user in a list in Mailchimp with MailChimp API 3.0. It does not provide any forms or validation, so you can feel free to use your own. To protect your users, it does not save any user data in logs or sends them to an admin.
      This module fits your needs if you...
      ...use Mailchimp as your newsletter / email-automation tool ...want to let users subscribe to your newsletter on your website ...want to use your own form, validation and messages (with or without the wire forms) ...don't want any personal user data saved in any way in your ProcessWire environment (cf. EU data regulation terms) ...like to subscribe, update, unsubscribe or delete users to/from different lists ...like the Mailchimp UI for creating / sending / reviewing email campaigns *I have only tested it with PHP 7.x so far, so use on owners risk
      EDIT:
      Since 0.0.4, instructions and changelog can be found in the README only. You can find it here  🙂
      If you have questions or like to contribute, just post a reply or create an issue or pr on github, thanks!
    • By MoritzLost
      Sorry for the convoluted title. I have a problem with Process modules that define a custom page using the page key through getModuleInfo (as demonstrated in this excellent tutorial by @bernhard). Those pages are created automatically when the module is installed. The problem is that the title of the page only gets set in the current language. That's not a problem if the current language (language of the superuser who is installing the module) is the default language; if it isn't, the Process page is missing a title in the default language. This has the very awkward effect that a user using the backend in the default language (or any other language) will see an empty entry in the setup menu:

      This screenshot comes from my Cache Control module which includes a Process page. Now I realize the description sounds obscure, but for us it's a common setup: We a multiple bilingual sites where the default language is German and the second language is English. While the clients use the CMS in German, as a developer I prefer the English interface, so whenever I install a Process module I get this problem.
      As a module author, is there a way to handle this situation? I guess it would be possible to use post-installation hooks or create the pages manually, but I very much prefer the declarative approach. The page title is already translatable (through the __ function), but of course at the time of installation there is no translation, and as far as I'm aware it's not possible to ship translations with a module so they are used automatically. Could this situation be handled better in the core? I would prefer if the module installation process would always set the title of the Process page in the default language, instead of the language of the current user.
×
×
  • Create New...