Jump to content
Tyssen

Module to integrate with Snipcart webhooks

Recommended Posts

I have a PW site which is integrated with Snipcart and now the owners want to add stock management.

Because each item comes in different sizes and colours, I'm using a repeater field with each row containing a size column.

The guys at Snipcart have written a blog post on how to achieve basically what I need in a plugin for Craft CMS. I need that converted into a module for PW and instead of updating an individual field, it's updating a column in a repeater field.

Anyone able to help me out with that?

Share this post


Link to post
Share on other sites

So are you wanting to manage your inventory through snipcart or processwire? Where are you currently managing your quantity?

Share this post


Link to post
Share on other sites

Sorry, just realised I wrote my original post with I'm using a repeater field with each row containing a size column instead of quantity column, so yeah, managing inventory in PW.

  • Like 1

Share this post


Link to post
Share on other sites

Well I am interested to see what people have to say, I have looked at snipcart in the past for a project and really like what it can do. I would imagine that you would want to either write a bit of code to intercept an ajax call on your checkout page or when you add an item to your shopping cart to remove one from the quantity of that item. You could also write a module that took care of that throughout your site.  Where are you stuck?

Share this post


Link to post
Share on other sites

I'm stuck at the 'never having written a module and not really having the skills to do so' part.

If you look at the blog post I've linked to, a webhook which points at some code on your site is fired from within SnipCart on the order.completed event.

Share this post


Link to post
Share on other sites

Well as this is a one off solution and you don't feel comfortable with modules yet why don't you try to just create a blank template that takes post requests. You could also do this with a module and there are some great examples from people whom have done the same thing, but a template should be a pretty simple way to implement the webhook. 

Using a template approach you could do something like this. I am just looking at the documentation and this looks to be how one would go about it. If you don't get anyone to sign on I think you should post some questions in the regular forum and really nice snazzy people will help you make exactly what you want. :)

if($input->post->eventName){
  //parse your json and update based on your data
}else{
    header('HTTP/1.1 400 Bad Request');
    //do you need to return from a template if it is already set? I don't know I am just copying. 
    return;
}

Share this post


Link to post
Share on other sites

If you don't get anyone to sign on I think you should post some questions in the regular forum and really nice snazzy people will help you make exactly what you want.

I was hoping that this being the jobs forum, that someone might get in contact about taking on the job for me (paid of course). But if no-one does I'll have to explore other options.

  • Like 1

Share this post


Link to post
Share on other sites

True, but I was interested in what you are hoping to develop and as this is processwire, there are more people here who would rather help you do it for free than take your money. Well if you decide to do it yourself I think you should check out clsource's rest helper class that he made. It seems to really cover almost all your bases and then some. 

https://processwire.com/talk/topic/7159-rest-helper-for-processwire/

Share this post


Link to post
Share on other sites

The main issue is, if I do this myself, I have no idea how long it would take me to do as I'd be learning as I go and I have to give the client a price before I can even start. Would feel more comfortable speaking to someone who can accurately estimate up front.

  • Like 1

Share this post


Link to post
Share on other sites

I decided to give it a go myself after all and now have it working fine. I ended up in doing it in a template instead of creating a module as you suggested.

Share this post


Link to post
Share on other sites

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By bernhard
      Some of you might have followed the development of this module here: https://processwire.com/talk/topic/15524-previewdiscussion-rockdatatables/ . It is the successor of "RockDataTables" and requires RockFinder to get the data for the grid easily and efficiently. It uses the open source part of agGrid for grid rendering.
       
      WHY?
      ProcessWire is awesome for creating all kinds of custom backend applications, but where it is not so awesome in my opinion is when it comes to listing this data. Of course we have the built in page lister and we have ListerPro, but none of that solutions is capable of properly displaying large amounts of data, for example lists of revenues, aggregations, quick and easy sorts by the user, instant filter and those kind of features. RockGrid to the rescue 😉 
       
      Features/Highlights:
      100k+ rows Instant (client side) filter, search, sort (different sort based on data type, eg "lower/greater than" for numbers, "contains" for strings) extendable via plugins (available plugins at the moment: fullscreen, csv export, reload, batch-processing of data, column sum/statistics, row selection) all the agGrid features (cell renderers, cell styling, pagination, column grouping etc) vanilla javascript, backend and frontend support (though not all plugins are working on the frontend yet and I don't plan to support it as long as I don't need it myself)  
      Limitations:
      While there is an option to retrieve data via AJAX the actual processing of the grid (displaying, filtering, sorting) is done on the client side, meaning that you can get into troubles when handling really large datasets of several thousands of rows. agGrid should be one of the most performant grid options in the world (see the official example page with a 100k row example) and does a lot to prevent problems (such as virtual row rendering), but you should always have this limitation in mind as this is a major difference to the available lister options that do not have this limitation.
      Currently it only supports AdminThemeUikit and I don't plan to support any other admin theme.
       
      Download: https://gitlab.com/baumrock/FieldtypeRockGrid
      Installation: https://gitlab.com/baumrock/RockGrid/wikis/Installation
      Quikckstart: https://gitlab.com/baumrock/RockGrid/wikis/quickstart
      Further instructions: https://gitlab.com/baumrock/RockGrid/wikis/quickstart#further-instructions
      German Translation File: site--modules--fieldtyperockgrid--fieldtyperockgrid-module-php.json
      Changelog: https://gitlab.com/baumrock/FieldtypeRockGrid/raw/master/changelog.md
       
      Module status: alpha, License: MIT
      Note that every installation and uninstallation sends an anonymous google analytics event to my google analytics account. If you don't want that feel free to remove the appropriate lines of code before installation/uninstallation.
       
      Contribute:
      You can contribute to the development of this and other modules or just say thank you by
      testing, reporting issues and making PRs at gitlab liking this post buying me a drink: paypal.me/baumrock/5 liking my facebook page: facebook.com/baumrock hiring me for pw work: baumrock.com  
      Support: Please note that this module might not be as easy and plug&play as many other modules. It needs a good understanding of agGrid (and JavaScript in general) and it likely needs some looks into the code to get all the options. Please understand that I can not provide free support for every request here in the forum. I try to answer all questions that might also help others or that might improve the module but for individual requests I offer paid support (please contact me via PM).
       
      Use Cases / Examples:
      Colored grid cells, Icons, Links etc. The Grid also has a "batcher" feature built in that helps communicating with the server via AJAX and managing resource intensive tasks in batches:

      Filters, PW panel links and instant reload on panel close:

      You can combine the grid with a chart library like I did with the (outdated) RockDataTables module:

    • By kongondo
      Announcing the current status, planned release, roadmap and preview of Padloper 2.
      Status
      Feature freeze. Full multilingual support. Only PHP 7.2+ supported. Support for ProcessWire 3.0 only. Backend support for modern browsers only (that support JavaScript ES6 modules). Current Work
      Finish work on admin/backend. Work on installer and uninstaller (including configurable availability of some features). Work on UI/UX improvements. Start work on documentation with special focus on technical documentation. Continue work on Padloper API and data/model component. Roadmap
      Please note that these ARE NOT hard and fast targets. The roadmap may have to be adjusted to accommodate technical and non-technical constraints.
      Q1 2021
      Inbuilt support for (latest) PayPal (full rewrite, no external modules required). Additional work on Padloper API. Invite a limited number of early alpha testers (fully-priced product). Soft and closed release of Padloper 2.
      Q2 2021
      Start work on relaunch of Padloper website. Inbuilt support for Stripe (no external modules required). Future Plans
      Support for more Payment Gateways. Support for order, customers, etc imports and exports. Support for AdminThemeReno and AdminThemeDefault. Separate fully-featured frontend shop module. Consider support for multiple currencies. FAQ
      1. Have you abandoned this project? 
      No.
      2. When will Padloper 2 be released?
      First early alpha release is scheduled for Q1 2021. This target may change depending on circumstances! Access will be by invite only for this first release.
      3. What is the pricing model of Padloper 2? 
      Three licences: Single Site, Developer and Agency licences (12 months’ updates and VIP support).
      4. How much will Padloper 2 Cost?
      No price has been set yet. It will cost more than Padloper 1.
      5. Can we upgrade from Padloper 1?
      No.
      6. Will existing users of Padloper 1 get a discount for Padloper 2?
      No, this will not be possible. Apologies for the earlier announcement. It was unrealistic and unworkable.
      7. Can we pay for Padloper 2 in advance?
      No.
      8. Does Padloper 2 render markup/templates in the frontend?
      No. Access to all data you need to build your shop’s frontend is via the Padloper API.
      9. Can we keep sending you ‘Are we there yet’ messages?
      No, please.
       
      Preview
      Here is a video preview of the current state of the backend/admin of Padloper 2. Please note the following:
      This is early alpha. There are bugs! It even includes WIP/notes!! FOUC, misaligned things, etc. The video shows the near-raw implementation of Vuetify UI. The UI/UX improvements work is yet to start. What you see here is the development version.  Some of the incomplete features may not be available in the early releases. Most of the features you see will be optional to install.  

       
    • By fruid
      I'm having troubles with the taxes in SnipWire. Here's what how I set it up
      I put the net-price in the product price field
      In SnipWire settings I selected:
      Taxes Provider: Integrated (SnipWire) (not sure about this)
      Taxes included in prices: false
      Taxes configuration: Tax name: vat_10, Rate: 0.10, Shipping: false (not sure about this)
      Shipping Taxes Handling: Apply a fixed tax rate (not sure about this)
      in snipcart_item_taxes field settings:
      which types of taxes should be listed as options? Product taxes
      With these setting, the select-field snipcart_item_taxes doesn't show any options.
      Nothing seems to change anything, except when I change the types of taxes in the field setting to shipping taxes (or all types) which I find quite confusing. If I try that though, the taxes still don't apply to the products. Not on the product directly before adding to the basket – which it should – nor in the basket before returning the total sum. 
      In the snipcart.com account I can also see the 0.10 tax rate for products somewhere but that doesn't change anything either. 
      To my understanding, the poduct itself should be taxed and the shipping should be taxed as well, with or without the same rate, I'm not sure. As of now, I don't see any.
      Is that one of those things that will only work when the shop is live? Because I actually have a local and a live installation in development, both don't do as they should.
      I recently tried to install v3 of SnipWire, but that caused a lot of issues, one of which was/is the price format which didn't allow for commas as decimal separator thus multiplying the prices by 100. I changed the version back to v2 but the wrong prices persist in the snipcart.com-account indexed products and I can't seem to re-index the prices. Not sure if that issue is related.
      Thanks for help!
    • By joshua
      As we often use Matomo (former known as Piwik) instead of Google Analytics we wanted to embed Matomo not only in the template code but also via the ProcessWire backend.
      That's why I developed a tiny module for the implementation.
      Right now it's not heavily tested, so I would call it an "alpha" status.
      The module provides the possibility to connect to an existing Matomo installation with the classical site tracking and also via the Matomo Tag Manager.
      If you have also PrivacyWire installed, you can tell MatomoWire to only load the script, if the user has accepted cookies via PrivacyWire.
      To offer an Opt-Out solution you can choose between the simple Opt-Out iFrame, delivered by your Matomo installation, or a button to choose cookies via PrivacyWire.
      You'll find the current (alpha) state in this git repo: https://github.com/blaueQuelle/matomowire
      As soon as it's better tested, I'll add it to the module repo.
      I'm looking forward to hear your feedback!
    • By FireWire
      Hello community!

      I want to share a new module I've been working on that I think could be a big boost for multi-language ProcessWire sites.

      Some background, I was looking for a way for our company website to be efficiently translated as working with human translators was pretty laborious and a lack of updating content created a divergence between languages. I, and several other devs here, have talked about translation integrations and have recognized the power that DeepL has. DeepL is an AI deep learning powered service that delivers translation quality beyond any automated service available. After access to the API was opened up to the US, I built Fluency, a DeepL translation integration for ProcessWire.
      Fluency brings automated translation to every multi-language field in the admin, and also provides a translation tool allowing the user to translate their text to any language without it being inside a template's field. With Fluency you can:
      Translate any plain textarea or text input Translate any CKEditor content (yes, with markup) Translate page names for fully localized URLs on every page Translate your in-template translation function wrapped strings Translate modules DeepL offers translations to the following languages: English (US), English (UK), German, French, Spanish, Portuguese (EU), Portuguese (Brazil, Italian, Dutch, Polish, Russian, Japanese, Chinese (Simplified)
      Installation and usage is completely plug and play. Whether you're building a new multi-language site, need to update a site to multi-language, or simply want to stop manually translating a site and make any language a one-click deal, it could not be easier to do it. Fluency works by having you match the languages configured in ProcessWIre to DeepL's. You can have your site translating to any or all of the languages DeepL translates to in minutes (quite literally).
      Let's break out the screenshots...
      When the default language tab is shown, a message is displayed to let users know that translation is available. Clicking on each tab shows a link that says "Translate from English". Clicking it shows an animated overlay with the word "Translating..." cycling through each language and a light gradient shift. Have a CKEditor field? All good. Fluency will translated it and use DeepL's ability to translate text within HTML tags. CKEditor fields can be translated as easily and accurately as text/textarea fields.

      Repeaters and AJAX created fields also have translation enabled thanks to a JavaScript MutationObserver that searches for multi-language fields and adds translation as they're inserted into the DOM. If there's a multi-language field on the page, it will have translation added.

      Same goes for image description fields. Multi-language SEO friendly images are good to go.

      Creating a new page from one of your templates? Translate your title, and also translate your page name for native language URLs. (Not available for Russian, Chinese, or Japanese languages due to URL limitations). These can be changed in the "Settings" tab for any page as well so whether you're translating new pages or existing pages, you control the URLs everywhere.

      Language configuration pages are no different. Translate the names of your languages and search for both Site Translation Files (including all of your modules)

      Translate all of the static text in your templates as well. Notice that the placeholders are retained. DeepL is pretty good at recognizing and keeping non-translatable strings like that. If it is changed, it's easy to fix manually.

      Fluency adds a "Translate" item to the CMS header. When clicked this opens up a modal with a full translation tool that lets the user translate any language to any language. No need to leave the admin if you need to translate content from a secondary language back to the default ProcessWire language. There is also a button to get the current API usage statistics. DeepL account owners can set billing limitations via character count to control costs. This may help larger sites or sites being retrofitted keep an eye on their usage. This tool is available for all users with the page-edit permission.

      It couldn't be easier to add Fluency to your new or existing website. Simply add your API key and you're shown what languages are currently available for translation from/to as provided by DeepL. This list and all configuration options are taken live from the API so when DeepL releases new languages you can add them to your site without any work. No module updates, just an easy configuration. Just match the language you configured in ProcessWire to the DeepL language you want it to be associated with and you're done. Fluency also allows you to create a list of words/phrases that will not be translated which can prevent items such as brands and company names from being translated when they shouldn't

       
      Limitations:
      No "translate page" - Translating multiple fields can be done by clicking multiple translation links on multiple fields at once but engineering a "one click page translate" is not feasible from a user experience standpoint. The time it takes to translate one field can be a second or two, but cumulatively that may take much longer (CKEditor fields are slower than plain text fields). There may be a workaround in the future but it isn't currently on the roadmap. No "translate site" - Same thing goes for translating an entire website at once. It would be great, but it would be a very intense process and take a very (very) long time. There may be a workaround in the future but it isn't on the roadmap. No current support for Inline CKEditor fields - Handling for CKEditor on-demand hasn't been implemented yet, this is planned for a future release though and can be done. I just forgot about it because I've never really used that feature personally.. Alpha release - This module is in alpha. Releases should be stable and usable, but there may be edge case issues. Test the module thoroughly and please report any bugs via a Gitlab issue on the repository or respond here. Please note that the browser plugin for Grammarly conflicts with Fluency (as it does with many web applications). To address this issue it is recommended that you disable Grammarly when using Fluency, or open the admin to edit pages in a private window where Grammarly may not be loaded. This is an issue that may not have a resolution as creating a workaround may not be possible. If you have insight as to how this may be solved please visit the Gitlab page and file a bugfix ticket.
      Requirements:
      ProcessWire  3.0+ UIKit Admin Theme That's Fluency in a nutshell. A core effort in this module is to create it so that there is nothing DeepL related hard-coded in that would require updating it when DeepL offers new languages. I would like this to be a future-friendly module that doesn't require developer work to keep it up-to-date.
      It's Free
      This is my first real module and I want to give it back to the community as thanks. This is the best CMS I've worked with (thank you Ryan & contributors) and a great community (thank you dear reader). The only cost to use this is a subscription fee for the DeepL Pro API. Find out more and sign up here.
      Download & Feedback
      Download the latest version here
      https://gitlab.com/SkyLundy/fluency-processwire/-/archive/master/fluency-processwire-master.zip
      Gitlab repository:
      https://gitlab.com/SkyLundy/fluency-processwire
      File issues and feature requests here (your feedback and testing is greatly appreciated):
      https://gitlab.com/SkyLundy/fluency-processwire/-/issues
       
      Thank you! ¡Gracias! Ich danke Ihnen! Merci! Obrigado! Grazie! Dank u wel! Dziękuję! Спасибо! ありがとうございます! 谢谢你!

×
×
  • Create New...