Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Items stored incorrectly in Drip for cart or order endpoints #80

Open
noctivityinc opened this issue Aug 17, 2022 · 6 comments
Open

Items stored incorrectly in Drip for cart or order endpoints #80

noctivityinc opened this issue Aug 17, 2022 · 6 comments

Comments

@noctivityinc
Copy link

When using the create_cart_activity_event or create_order_activity_event and passing an array of items, which is basically an array of ruby hashes, as per the API documents to drip, they are not stored as an object and, as such, we can't properly use them in our emails. When I try to use them in an abandon template, for example, all the wrong data is pulled.

How do we pass an item array to CORRECTLY store in Drip? Here is an example of how the data is recorded and you can clearly see that the Items field is simply a dump of the Ruby Hash, not a reusuable object. I also tried passing an array of JSON objects but the response said that it was expecting an object to be passed, which doesn't make a lot of sense.

Screen Shot 2022-08-17 at 3 33 43 PM

@noctivityinc noctivityinc changed the title Items stored incorrect in Drip for cart or order endpoints Items stored incorrectly in Drip for cart or order endpoints Aug 17, 2022
@iantance
Copy link
Contributor

@noctivityinc Can you say more about how you'd like to use the objects in the items array? You're right that those are stored as ruby hashes. Those are then made available in emails via liquid.

You can loop over the objects in the array like this:

{% for product in event.products %}
 {{ product.name }}
{% endfor %}

That will show the names of each product.

You can also access items by index like this:

{{ event.products[0].name}}

That will show the name of the first product in the array.

@noctivityinc
Copy link
Author

@iantance ok take a look a this. The items object in Drip for this one user is this:

[{"categories"=>["Motorcycle"], "image_url"=>"https://dmvcheatsheets-assets.s3.amazonaws.com/assets/assets/data/148/original/page_4.png", "name"=>"Alabama DMV Motorcycle Cheat Sheet and Online Practice Test Bundle", "price"=>"19.95", "product_id"=>"384", "product_tag"=>"Alabama Motorcycle Written Test", "product_url"=>"http://dmvcs.local:3000/exams/alabama-motorcycle-written-test/products/alabama-dmv-motorcycle-cheat-sheet-and-online-practice-test-bundle", "product_variant_id"=>"384"}]

Then I try to use Drip's email editor:
Screen Shot 2022-08-17 at 5 06 42 PM

But when I preview it for that user, look at what I see:
Screen Shot 2022-08-17 at 5 07 11 PM

So basically the data from the item's object is not being used to populate the email correctly, indicating something is wrong somewhere.

@noctivityinc
Copy link
Author

@iantance also, what is this event.products object? There is no mention of this in the API documentation. Am I missing something?

@iantance
Copy link
Contributor

@noctivityinc Sorry, that should have been event.items.

When previewing an email, there's no event around for us to use when rendering the email. So you won't see liquid that uses event render in previews.

The exception is that we do include some sample data when previewing our abandoned cart blocks. We pull some cart events randomly from your account to populate the items, but as you noticed they will not correspond to a particular subscriber. I believe that's what you are seeing in that last screenshot.

In general, those abandoned content blocks aren't using the data from the event you see in the UI (they don't use event.items). They are hitting a separate service to pull the most recent version of the card, based on the cart_id in the triggering event.

@noctivityinc
Copy link
Author

noctivityinc commented Aug 18, 2022 via email

@iantance
Copy link
Contributor

If your workflow is turned on, you could test it live by make an API call to simulate the initial cart event.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants