Skip to main content

Hello guys,

I have a Zap that creates a Coupon in a WooCommerce website.

I need a custom meta data, and luckily Zapier allows that.

The problem is the format of the data.

The field is serialized, so when I add the entry I need:

a:1:{i:0;a:4:{s:10:"product_id";s:4:"2087";s:8:"quantity";s:1:"1";s:15:"discount_amount";s:3:"100";s:13:"discount_type";s:7:"percent";}}

 

It turns into this in the database:

s:136:"a:1:{i:0;a:4:{s:10:"product_id";s:4:"2087";s:8:"quantity";s:1:"1";s:15:"discount_amount";s:3:"100";s:13:"discount_type";s:7:"percent";}}";

 

It's considered a string and serialized again.

 

I can't find the right format to use, anyone can help with that?

 

 

Thanks

Daniele

Hi @wp-ok!

Thanks for the question 👍

Zapier’s Formatter allows for the conversion of Line Item fields to individual fields: https://zapier.com/help/create/format/convert-line-items-into-text-strings

However, that may not help out here and you may need a Code step. The best place to ask for help with your code is http://stackoverflow.com. Just tag your question with a “Zapier” tag and usually there will be folks who are willing to help you out. You can see all the questions that have already been asked here: https://stackoverflow.com/questions/tagged/zapier

Alternatively, where is the data coming from, which app, do you have the option to change the formatting of the data in the trigger app, to get it into a format you can use in the Create Coupon action in WooCommerce?