Try our conversational search powered by Generative AI!

Creating meta fields for serialized carts



I am working on a project that currently uses non-serialized carts, I now need to Enable the serialized carts and make the necessary changes. I am folllowing the below mentioned developer guide article on serialized cart implementation: 

The current site (non-serialized) uses a lot of meta fields across a number of classes (ordergroup, orderform, linetitem, shipment, address). I dont think this should be an issue while migrating to seriazlised carts. As I see that that the classes can be extended like the example mentioned in the developer guide arctile below:

So I can use meta fields with serialzed carts right? just that the manner of setting/accessing the metafields is different from the legacy way. 

Jul 15, 2019 5:39

Hi Siddharth

You can put whatever property you want in the Properties list of your SerializableCart. It is just a Hashtable of object. So no need or way to define custom MetaFields for a SerializableCart.

However, when you convert the SerializableCart to a PurchaseOrder, the property names and types have to match the known MetaFields on the PuchaseOrder MetaClass (and related types). So best to use the same property keys as the MetaField names.

Jul 15, 2019 6:40
Siddharth Gupta - Jul 15, 2019 23:42
Thank you Stefan!

If you've already been using non serialzed when converting to serialized everything should work fine as you've obviously already got all the fields set up for non-serialized/purchase orders. It just used JSON serialization, a few points to cadveat to be wary of

  1. When moving to the future be careful what types you use. Types like Money work fine in serialized carts but not so much with POs. Be careful of the types you use that they work still in the purchase order.
  2. If you have any searching code that searches by metafield using the helper methods these do not work when using serializable carts. I had to write my own SQL queries
Jul 15, 2019 17:51
Siddharth Gupta - Jul 15, 2019 23:42
Thank you Scott!
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.