Skip to content

Instantly share code, notes, and snippets.

@peterberkenbosch
Last active August 29, 2015 14:07
Show Gist options
  • Save peterberkenbosch/39522be9ef991ec87ed9 to your computer and use it in GitHub Desktop.
Save peterberkenbosch/39522be9ef991ec87ed9 to your computer and use it in GitHub Desktop.
push current order to wombat after_commit
Spree::Order.class_eval do
after_commit :wombat_push_spree_orders
def wombat_push_spree_orders
if self.state == "complete"
payload_builder = Spree::Wombat::Config[:payload_builder]["Spree::Order"]
payload = ActiveModel::ArraySerializer.new([order],
each_serializer: payload_builder[:serializer].constantize,
root: payload_builder[:root]
).to_json
Spree::Wombat::Client.push(payload)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment