Jump to content
Gadgetto

SnipWire - Snipcart integration for ProcessWire

Recommended Posts

UPDATE 2019-11-15

In the last 3 weeks I (nearly) finished the complete order handling for store merchants (ProcessWire backend). This includes the following features:

  • search for orders
  • filter orders
  • extensive overview of all order details
  • download of invoices
  • resend invoices to customers
  • refund amounts to customers

... all right from within your ProcessWire backend!

That doesn't sound like much, but it was a good piece of work. 🙂

Here is a short clip to demonstrate the new features:

order_handling.thumb.gif.4dc4ced581d0f2c409d62613bb8f3358.gif

  • Like 16
  • Thanks 1

Share this post


Link to post
Share on other sites

Hi @Gadgetto,

Thank you for this great module, currently I'am using it for a test-case.

When I updated with your recent version I get the following error when I want to navigate to the dashboard / products page:

Fatal error: Uncaught ProcessWire\PageFinderSyntaxException: Field does not exist: snipcart_item_id in /Users/macbookweb014/Documents/BB/localhost/wetthrasport/wire/core/PageFinder.php:1272 Stack trace: #0

Can you help me fixing it? Do I need to create a snipcart_item_id field?

Thanks in advance!

Kind regards, 
Peejay

 

Share this post


Link to post
Share on other sites
4 hours ago, Peejay said:

When I updated with your recent version I get the following error when I want to navigate to the dashboard / products page:

Fatal error: Uncaught ProcessWire\PageFinderSyntaxException: Field does not exist: snipcart_item_id in /Users/macbookweb014/Documents/BB/localhost/wetthrasport/wire/core/PageFinder.php:1272 Stack trace: #0

Can you help me fixing it? Do I need to create a snipcart_item_id field?

Hi @Peejay,

did you run the Additional stepsInstall Snipcart products package in SnipWire module settings?

This step installs product templates, files, fields and some demo pages required to build a Snipcart product catalogue. This additional step is needed to prevent unintended deletion of your Snipcart products catalogue when main module is uninstalled.

In the current alpha version this isn't yet checked by SnipWire.

If you did already run the additional step with an earlier SnipWire version there will be fields missing which were added in a later version. So you will need to re-run this step. The missing resources(fields, templates, pages, ...) will then be installed. Existing ones won't be touched!

To re-run this step, you will need to edit/remove a key in database directly:

DB table: "modules" -> find entry with class "SnipWire" -> edit the "data" field and remove the Json key: "product_package":true (be sure to leave a valid Json string - you will need to also remove the corresponding comma :

{"api_key":"YOUR_LIVE_API_KEY","api_key_test":"ODQzZTc1MjktZGQxNy00YmUzLWFkMWYtZDE3MDQ2YTk1ODNjNjM2ODE3NTg5NzUyNDQxOTc0","api_key_secret":"YOUR_LIVE_API_KEY_SECRET","api_key_secret_test":"","snipcart_environment":"0","single_page_shop":"","single_page_shop_page":1,"credit_cards":["visa","mastercard","amex"],"currencies":["eur","usd"],"show_cart_automatically":1,"shipping_same_as_billing":1,"show_continue_shopping":1,"split_firstname_and_lastname":1,"snipcart_debug":1,"snipcart_css_path":"https:\/\/cdn.snipcart.com\/themes\/2.0\/base\/snipcart.min.css","snipcart_css_integrity":"","snipcart_js_path":"https:\/\/cdn.snipcart.com\/scripts\/2.0\/snipcart.js","snipcart_js_integrity":"","include_jquery":"","jquery_js_path":"https:\/\/code.jquery.com\/jquery-3.3.1.min.js","jquery_js_integrity":"sha256-FgpCb\/KJQlLNfOu91ta32o\/NMZxltwRo8QtmkMRdAu8=","excluded_templates":["promailer-email","promailer-subscribe"],"cart_image_width":65,"cart_image_height":65,"cart_image_quality":70,"cart_image_hidpi":1,"cart_image_hidpiQuality":50,"cart_image_cropping":1,"data_item_name_field":"title","uninstall":"","submit_save_module":"Submit","taxes_included":1,"webhooks_endpoint":"\/webhooks\/snipcart","include_snipcart_css":1,"taxes":"[{\"name\":\"20% VAT\",\"numberForInvoice\":\"\",\"rate\":\"0.20\",\"appliesOnShipping\":[]},{\"name\":\"10% VAT\",\"numberForInvoice\":\"\",\"rate\":\"0.10\",\"appliesOnShipping\":[]},{\"name\":\"10% VAT (Shipping)\",\"numberForInvoice\":\"\",\"rate\":\"0.10\",\"appliesOnShipping\":[\"1\"]}]","snipwire_debug":1,"data_item_categories_field":"snipcart_item_categories","product_package":true}

After the key is removed, visit the SnipCart module settings again and re-run the product package installer!

In the release version of SnipCart, this will be handled automatically. On each update it will check if there are new fields or other resources to be installed.

Hope this helps!

p.s. You could also completely uninstall the SnipCart module and then reinstall - this should also activate the product package installer link!

-- Martin

  • Like 3

Share this post


Link to post
Share on other sites

@Peejay,

great!

what would be interesting for me is: do you think that the performance in SnipWire dashboard/backend is OK or do I need to find another way to fetch Snipcart data?

— Martin

Share this post


Link to post
Share on other sites

@Gadgetto,

For now the performance is OK! I'm still in testing mode. In two weeks I put the site live and when I have some orders I let you know how the performance is!

Pj

Share this post


Link to post
Share on other sites
21 minutes ago, Peejay said:

@Gadgetto,

For now the performance is OK! I'm still in testing mode. In two weeks I put the site live and when I have some orders I let you know how the performance is!

Pj

Thanks for reporting back!

I just published a new version on GitHub which has some great performance improvements and a lot of other new features!

The orders list is now loaded in 1 - 1.5 seconds (instead of 4 seconds).
The dashboard is also affected by these changes and should load much faster now!

  • Like 3

Share this post


Link to post
Share on other sites

Hi Martin,

that looks very promising! Unfortunately I can't get the module to work properly. I'm using the last dev version of processire. I get the following error when I try to install the sample products:
Raw data option with CURL not supported for GET 
In /wire/core/WireHttp.php line 642

Then I get when saving a product:
Snipcart product with SKU [1032] could not be fetched. [500 Internal Server Error: ]

I tried it in different environments, but in MAMP I also get these errors.

Share this post


Link to post
Share on other sites
6 hours ago, Noboru said:

Hi Martin,

that looks very promising! Unfortunately I can't get the module to work properly. I'm using the last dev version of processire. I get the following error when I try to install the sample products:
Raw data option with CURL not supported for GET 
In /wire/core/WireHttp.php line 642

Then I get when saving a product:
Snipcart product with SKU [1032] could not be fetched. [500 Internal Server Error: ]

I tried it in different environments, but in MAMP I also get these errors.

Hi @Noboru

I have a clue what's causing this problem. I need a little time. I'll contact you when I have fixed that.

In the meantime you could comment out the following lines in file SnipWire.module.php (should be line 96-98)

$this->addHookAfter('Pages::saved', $this, 'publishSnipcartProduct');
$this->addHookAfter('Pages::unpublished', $this, 'unpublishSnipcartProduct');
$this->addHookAfter('Pages::trashed', $this, 'unpublishSnipcartProduct');

-- Martin

  • Like 1

Share this post


Link to post
Share on other sites

@Noboru,

I just tried to reproduce the problem but couldn't. I installed ProcessWire 3.0.147 on a fresh MAMP host and installed SnipCart on the naked system. Also installed the additional resources package from within SnipWire settings - and it worked like expected.

Could you please provide more infos regarding your setup? PHP version, CURL version, additional installed modules, ...?

Share this post


Link to post
Share on other sites

I have a general question regarding required PW version for my upcoming SnipWire module:

SnipWire is a huge module which touches big parts of the PW core API. As a sample - only the WireHttp class had at least 10 fixes and improvements since v 3.0.123 which are mandatory for SnipWire to work properly.

I'm planning to release the module with a minimum requirement of PW version around 3.0.148  (which should represent the coming master version). Do you think this is a good idea or should I stay at - let's say 3.0.123 and struggle with many workarounds to stay downwards compatible?

Share this post


Link to post
Share on other sites

I would say that this answers your question 🙂

13 minutes ago, Gadgetto said:

SnipWire is a huge module which touches big parts of the PW core API. As a sample - only the WireHttp class had at least 10 fixes and improvements since v 3.0.123 which are mandatory for SnipWire to work properly.

Don't make more work for yourself, both in coding and in support.

 

  • Like 1

Share this post


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

 

Don't make more work for yourself, both in coding and in support.

Completely agree. The module will only profit from you enjoying working on it, so go easy on yourself and make use of available core features where necessary. Besides, ProcessWire is ridiculously easy to keep updated, so I don't feel like you're leaving anybody behind.

  • Like 1

Share this post


Link to post
Share on other sites
2 hours ago, d'Hinnisdaël said:

Completely agree. The module will only profit from you enjoying working on it, so go easy on yourself and make use of available core features where necessary. Besides, ProcessWire is ridiculously easy to keep updated, so I don't feel like you're leaving anybody behind.

Exactly, I am always on the latest dev version whenever I need to work on a site as it is so easy to update, and it is always stable in my eyes.

Share this post


Link to post
Share on other sites
4 hours ago, Gadgetto said:

I'm planning to release the module with a minimum requirement of PW version around 3.0.148

+1 🙂

Share this post


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

my upcoming SnipWire module

BTW, when can we expect that to happen? Sounds like sooner than the end of December maybe? Is it going to be the first production ready version?

Thanks for sharing all your hard work, and do not forget to ship it with a "Donation button".

  • Like 3

Share this post


Link to post
Share on other sites
9 hours ago, Gadgetto said:

@Noboru,

I just tried to reproduce the problem but couldn't. I installed ProcessWire 3.0.147 on a fresh MAMP host and installed SnipCart on the naked system. Also installed the additional resources package from within SnipWire settings - and it worked like expected.

Could you please provide more infos regarding your setup? PHP version, CURL version, additional installed modules, ...?

Hi @Gadgetto,

I'm using MAMP Pro 5.5.1 with PHP 7.3.8 (tried it with 7.1.31 with the same result), 
 

/Applications/MAMP/Library/bin/curl --version
curl 7.65.1 (x86_64-apple-darwin13.4.0) libcurl/7.65.1 OpenSSL/1.0.2o zlib/1.2.8 nghttp2/1.29.0
Release-Date: 2019-06-05
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp 
Features: AsynchDNS HTTP2 HTTPS-proxy IPv6 Largefile libz NTLM NTLM_WB SSL TLS-SRP UnixSockets

It's also an naked PW 3.0.147 without any other modules.

Its the same result like on my webhost (curl 7.19.7 , PHP 7.3.12).

More testing on webserver (because webhooks and full configuration):
If I set the price to a value without a comma everything works as expected (SnipWire log: Fetched Snipcart product with SKU [1116] / ID [xxx-xxx-xxx-xxx]. 

But if the product price is for example 11.50, I get Snipcart product with SKU [1116] could not be fetched. [500 Internal Server Error: ]

I've tried different settings for decimal separator in app.snipcart.com Regional Settings.

The Markup for the Add-to-cart-Button looks like this:

 

<button class="snipcart-add-item" title="Add to cart" data-item-name="Axolotl Juicer" data-item-id="1116" data-item-price="11,5" data-item-url="https://roland.zumpixel.de/shop/axolotl-juicer/" data-item-description="Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur." data-item-image="https://xxx.xx.de/site/assets/files/1116/beer3.65x65-hidpi.jpg" data-item-metadata="{&quot;id&quot;:1116,&quot;created&quot;:1576098063,&quot;modified&quot;:1576185868,&quot;published&quot;:1576098063,&quot;created_users_id&quot;:41,&quot;modified_users_id&quot;:41}" data-item-quantity="1" data-item-quantity-step="1" data-item-stackable="true" data-item-taxable="true" data-item-taxes="20% VAT" data-item-has-taxes-included="true" data-item-shippable="true">Add to cart</button>

 

Armin

Edited by Noboru
more details

Share this post


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

Hi @Gadgetto,

I'm using MAMP Pro 5.5.1 with PHP 7.3.8 (tried it with 7.1.31 with the same result), 
 


/Applications/MAMP/Library/bin/curl --version
curl 7.65.1 (x86_64-apple-darwin13.4.0) libcurl/7.65.1 OpenSSL/1.0.2o zlib/1.2.8 nghttp2/1.29.0
Release-Date: 2019-06-05
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp 
Features: AsynchDNS HTTP2 HTTPS-proxy IPv6 Largefile libz NTLM NTLM_WB SSL TLS-SRP UnixSockets

It's also an naked PW 3.0.147 without any other modules.

Its the same result like on my webhost (curl 7.19.7 , PHP 7.3.12).

More testing on webserver (because webhooks and full configuration):
If I set the price to a value without a comma everything works as expected (SnipWire log: Fetched Snipcart product with SKU [1116] / ID [xxx-xxx-xxx-xxx]. 

But if the product price is for example 11.50, I get Snipcart product with SKU [1116] could not be fetched. [500 Internal Server Error: ]

I've tried different settings for decimal separator in app.snipcart.com Regional Settings.

The Markup for the Add-to-cart-Button looks like this:

 


<button class="snipcart-add-item" title="Add to cart" data-item-name="Axolotl Juicer" data-item-id="1116" data-item-price="11,5" data-item-url="https://roland.zumpixel.de/shop/axolotl-juicer/" data-item-description="Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur." data-item-image="https://xxx.xx.de/site/assets/files/1116/beer3.65x65-hidpi.jpg" data-item-metadata="{&quot;id&quot;:1116,&quot;created&quot;:1576098063,&quot;modified&quot;:1576185868,&quot;published&quot;:1576098063,&quot;created_users_id&quot;:41,&quot;modified_users_id&quot;:41}" data-item-quantity="1" data-item-quantity-step="1" data-item-stackable="true" data-item-taxable="true" data-item-taxes="20% VAT" data-item-has-taxes-included="true" data-item-shippable="true">Add to cart</button>

 

Armin

Regarding the CURL error in WireHttp - could you please provide the exact steps until the error occurres (starting from module installation?

The other problem: The data-item-price property is definitely wrong. It should be 11.5 not 11,5. I’ll need to check the float sanitizer. What is your locale setting?

BTW, Its really great to get SnipWire tested - this helps me a lot! Thanks @Noboru

Share this post


Link to post
Share on other sites
3 hours ago, szabesz said:

BTW, when can we expect that to happen? Sounds like sooner than the end of December maybe? Is it going to be the first production ready version?

Thanks for sharing all your hard work, and do not forget to ship it with a "Donation button".

It’s hard to tell when the first release version will be ready. I’m currently struggling with the custom taxes provider which will allow a very flexible VAT handling for all countries worldwide. I’m in contact with the Snipcart team, because I’m having problems with shipping taxes ...

When the taxes provider is finished, the biggest part is done and I should be able to release a first beta.

And thanks for the hint with the donation button! 👍

  • Like 3

Share this post


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

...
The Markup for the Add-to-cart-Button looks like this:


<button class="snipcart-add-item" title="Add to cart" data-item-name="Axolotl Juicer" data-item-id="1116" data-item-price="11,5" data-item-url="https://roland.zumpixel.de/shop/axolotl-juicer/" data-item-description="Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur." data-item-image="https://xxx.xx.de/site/assets/files/1116/beer3.65x65-hidpi.jpg" data-item-metadata="{&quot;id&quot;:1116,&quot;created&quot;:1576098063,&quot;modified&quot;:1576185868,&quot;published&quot;:1576098063,&quot;created_users_id&quot;:41,&quot;modified_users_id&quot;:41}" data-item-quantity="1" data-item-quantity-step="1" data-item-stackable="true" data-item-taxable="true" data-item-taxes="20% VAT" data-item-has-taxes-included="true" data-item-shippable="true">Add to cart</button>

 

FYI - @Noboru and I am just trying to solve the problem via PN chat (in German language). After I have fixed this, I'll post back the infos here!

  • Like 2

Share this post


Link to post
Share on other sites

With the help of @Noboru I could fix some bugs in the "Extended Resources" installer and with float values in prices. Some rare problems could be fixed and the installer is more stable now.

A big problem is the integrated taxes-provider regarding shipping-.taxes. I'm in contact with the Snipcart team to make this as flexible as possible. This isn't easy as we have very different taxes system around the countries of the world.

  • Like 4

Share this post


Link to post
Share on other sites

@Gadgetto this module looks fantastic! I'm looking at using SnipCart to create an ecommerce site because it seems very user friendly (important for when I pass this site off) and it has support for some of the features I need.

One of those features is subscriptions. Do you have advice for setting up monthly subscriptions vs one-time purchases? I'm new to both your module and SnipCart and I didn't see anything obvious after the initial install and a bit of poking about in the admin but I do see it in the Module's page under Setup and references to subscriptions in the module files.

Am I overlooking something, or do I just need to add custom fields to the snipcart-product template (and output them in the markup) to correspond to the button attributes listed in https://docs.snipcart.com/v3/setup/products ?

Thanks!

Share this post


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

@Gadgetto this module looks fantastic! I'm looking at using SnipCart to create an ecommerce site because it seems very user friendly (important for when I pass this site off) and it has support for some of the features I need.

One of those features is subscriptions. Do you have advice for setting up monthly subscriptions vs one-time purchases? I'm new to both your module and SnipCart and I didn't see anything obvious after the initial install and a bit of poking about in the admin but I do see it in the Module's page under Setup and references to subscriptions in the module files.

Am I overlooking something, or do I just need to add custom fields to the snipcart-product template (and output them in the markup) to correspond to the button attributes listed in https://docs.snipcart.com/v3/setup/products ?

I'm glad you like SnipWire! 🙂

Important: SnipWire is not yet ready for production environments!

Subscriptions are on my backlog and will be definitely in the first release!

  • Like 1

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 MoritzLost
      TrelloWire
      This is a module that allows you to automatically create Trello cards for ProcessWire pages and update them when the pages are updated. This allows you to setup connected workflows. Card properties and change handling behaviour can be customized through the extensive module configuration. Every action the module performs is hookable, so you can modify when and how cards are created as much as you need to. The module also contains an API-component that makes it easy to make requests to the Trello API and build your own connected ProcessWire-Trello workflows.
      Features
      All the things the module can do for you without any custom code: Create a new card on Trello whenever a page is added or published (you can select applicable templates). Configure the target board, target list, name and description for new cards. Add default labels and checklists to the card. Update the card whenever the page is updated (optional). When the status of the card changes (published / unpublished, hidden / unhidden, trashed / restored or deleted), move the card to a different list or archive or delete it (configurable). You can extend this through hooks in many ways: Modifiy when and how cards are created. Modify the card properties (Target board & list, title, description, et c.) before they are sent to Trello. Create your own workflows by utilizing an API helper class with many convenient utility methods to access the Trello API directly. Feedback & Future Plans
      Let me know what you think! In particular:
      If you find any bugs report them here or on Github, I'll try to fix them. This module was born out of a use-case for a client project where we manage new form submissions through Trello. I'm not sure how many use-cases there are for this module. If you do use it, tell me about it! The Trello API is pretty extensive, I'll try to add some more helper methods to the TrelloWireApi class (let me know if you need anything in particular). I'll think about how the module can support different workflows that include Twig – talk to me if you have a use-case! Next steps could be a dashboard to manage pages that are connected to a Trello card, or a new section in the settings tab to manage the Trello connection. But it depends on whether there is any interest in this 🙂 Links
      Repository on Github Complete module documentation (getting started, configuration & API documentation) TrelloWire in the modules directory Module configuration

    • By bernhard
      #######################
      Please use the new RockFinder2
      #######################
      WHY?
      This module was built to fill the gap between simple $pages->find() operations and complex SQL queries.
      The problem with $pages->find() is that it loads all pages into memory and that can be a problem when querying multiple thousands of pages. Even $pages->findMany() loads all pages into memory and therefore is a lot slower than regular SQL.
      The problem with SQL on the other hand is, that the queries are quite complex to build. All fields are separate tables, some repeatable fields use multiple rows for their content that belong to only one single page, you always need to check for the page status (which is not necessary on regular find() operations and therefore nobody is used to that).
      In short: It is far too much work to efficiently and easily get an array of data based on PW pages and fields and I need that a lot for my RockGrid module to build all kinds of tabular data.

      Basic Usage

       
      Docs & Download
      https://modules.processwire.com/modules/rock-finder/
      https://github.com/BernhardBaumrock/RockFinder
       
      Changelog
      180817, v1.0.6, support for joining multiple finders 180810, v1.0.5, basic support for options fields 180528, v1.0.4, add custom select statement option 180516, change sql query method, bump version to 1.0.0 180515, multilang bugfix 180513, beta release <180513, preview/discussion took place here: https://processwire.com/talk/topic/18983-rocksqlfinder-highly-efficient-and-flexible-sql-finder-module/
    • By MoritzLost
      Process Cache Control
      This module provides a simple solution to clearing all your cache layers at once, and an extensible interface to perform various cache-related actions.
      The simple motivation behind this module was that I was tired of manually clearing caches in several places after deploying a change on a live site. The basic purpose of this module is a simple Clear all caches link in the Setup menu which clears out all caches, no matter where they hide. You can customize what exactly the module does through it's configuration menu:
      Expire or delete all cache entries in the database, or selectively clear caches by namespace ($cache API) Clear the the template render cache. Clear out specific folders inside your site's cache directory (/site/assets/cache) Clear the ProCache page render cache (if your site is using ProCache) Refresh version strings for static assets to bust client-side browser caches (this requires some setup, see the full documentation for details). This is the basic function of the module. However, you can also add different cache management action through the API and execute them through the module's interface. For this advanced usage, the module provides:
      An interface to see all available cache actions and execute them. A system log and logging output on the module page to see verify what the module is doing. A CacheControlTools class with utility functions to clear out different caches. An API to add cache actions, execute them programmatically and even modify the default action. Permission management, allowing you granular control over which user roles can execute which actions. The complete documentation can be found in the module's README.
      Plans for improvements
      If there is some interest in this, I plan to expand this to a more general cache management solution. I particular, I would like to add additional cache actions. Some ideas that came to mind:
      Warming up the template render cache for publicly accessible pages. Removing all active user sessions. Let me know if you have more suggestions!
      Links
      https://github.com/MoritzLost/ProcessCacheControl ProcessCacheControl in the Module directory CHANGELOG in the repository Screenshots


    • By Macrura
      PrevNextTabs Module
      Github: https://github.com/outflux3/PrevNextTabs
      Processwire helper modules for adding page navigation within the editor.
      Overview
      This is a very simple module that adds Previous and Next links inline with the tabs on the page editor. Hovering over the tab shows the title of the previous or next page (using the admin's built in jqueryUI tooltips.)
      Usage
      This module is typically used during development where you or your editors need to traverse through pages for the purpose of proofing, flagging and/or commenting. Rather than returning to the page tree or lister, they can navigate with these links.
      Warnings
      If you are using PW version 2.6.1 or later, the system will prevent you from leaving the page if you have unsaved edits.
      For earlier versions, to avoid accidentally losing changes made to a page that might occur if a user accidentally clicks on one of these, make sure to have the Form Save Reminder module installed.
      http://modules.processwire.com/modules/prev-next-tabs/
×
×
  • Create New...