Jump to content

Module to integrate with Snipcart webhooks


Tyssen
 Share

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?

Link to comment
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?

Link to comment
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.

Link to comment
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;
}
Link to comment
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
Link to comment
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/

Link to comment
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
Link to comment
Share on other sites

 Share

×
×
  • Create New...