Skip to content
This repository was archived by the owner on Oct 6, 2026. It is now read-only.
This repository was archived by the owner on Oct 6, 2026. It is now read-only.

How to create a FulfillmentEvent #361

Closed

Description

@lswamy

I can create and update fulfillments through the api to add a tracking number to the order when it ships. However the order status does not update for the customer, it just says order is confirmed and come back for updates.
The docs indicate that creating a FulfillmentEvent will update the order status page.

https://shopify.dev/docs/admin-api/rest/reference/shipping-and-fulfillment/fulfillmentevent

How can I accomplish this with the python api?

Thanks

Activity

  1. tanema commented on Feb 26, 2020

    @tanema

    Currently there is no fulfillment event resource in the library. Nor does the Fulfillments model have the events mixin. You could, however, extend the Event model or create your own model in your codebase to support this until support is added. Just inherit from ShopifyResource

  2. lswamy commented on Mar 3, 2020

    @lswamy
    Author

    Thanks for the response.
    I created my own model, but I'm not too familiar with pyactiveresource so it may not be correct. It appears to work for my purpose. If this looks good you can close the ticket.

    import shopify
    
    class FulfillmentEvent(shopify.ShopifyResource):
        _prefix_source = "/orders/$order_id/fulfillments/$fulfillment_id"
        _singular = "event"
        _plural = "events"
    
        @classmethod
        def _prefix(cls, options={}):
            order_id = options.get("order_id")
            fulfillment_id = options.get('fulfillment_id')
            if order_id:
                return "%s/orders/%s/fulfillments/%s" % (
                    cls.site, order_id, fulfillment_id)
            else:
                return cls.site
    
    event = FulfillmentEvent({'order_id': order_id, 'fulfillment_id': fulfillment_id})
    event.status = "in_transit"
    event.save()
  3. rlepore commented on Jan 21, 2021

    @rlepore

    @tanema It doesn't look like this is added yet so I've been running some tests using a custom FulfillmentEvent resources like above. I noticed an issue when the resources returns an error. For example, if you send an invalid status the client throws an unhandled Exception. It looks like the pyactiveresource library can't parse the response properly.

    Here is the stacktrace along with the error:

      File "/lib/python3.7/site-packages/pyactiveresource/activeresource.py", line 453, in create
        resource.save()
      File "/lib/python3.7/site-packages/pyactiveresource/activeresource.py", line 850, in save
        self.errors.from_json(err.response.body)
      File "/lib/python3.7/site-packages/pyactiveresource/activeresource.py", line 132, in from_json
        self.from_array(errors)
      File "/lib/python3.7/site-packages/pyactiveresource/activeresource.py", line 82, in from_array
        attr_name = message.split()[0]
    AttributeError: 'dict' object has no attribute 'split'
    

    I also printed out the response in pyactiveresource which is below.

    {'base': {'shop_id': {'db_id': xxxxx}, 'fulfillment_event_input': {'city': None, 'country': None, 'province': None, 'zip': None, 'estimated_delivery_at': None, 'happened_at': None, 'fulfillment_id': {'db_id': xxxxxx}, 'message': None, 'status': 'test', 'latitude': None, 'longitude': None}, 'api_client_id': xxxxxx, 'fulfillment_context': 'fulfillment_events_controller', 'update_shipment_status': True}, 'attribute': 'fulfillment_event_input.status', 'raw_type': 'inclusion', 'type': 'inclusion', 'options': {'message': 'is not a valid status', 'value': 'test'}}
    

    As you can see in the options object, the status is invalid but the library can't parse it properly.

    Is there a way to fix this? Not sure if there is a known way to handle this or if there is something else that I need to do when creating a custom resource like above.

    //cc @mllemango

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions