Skip to content
Community forum

Adding my own fields to the cart and order

SolvedSupero SupportSupero team asked

Common question, written up by the Supero team.

I need a gift_wrap flag on the cart. Do I add it to the platform cart schema, or keep a separate table next to it? And once it's in my own schema, how does checkout_cart know to use that schema?

Link

1 answer

Accepted answer
Accepted answer

Make your own schema extend the base and add the field there:

json
{"name": "luxe_cart", "parent_type": "tenant", "extends": "cart:base_cart",
 "attributes": [{"name": "gift_wrap", "type": "boolean", "default-value": false}]}

Your schema inherits the base's status, timestamps and totals. Operations work out which schema to act on from the extending_schema inputs. Cart, order, approval, inventory, loyalty_points and document_signature each take two, a header and a line schema (cart_item_extending_schema for the cart). Register them once in the browser client instead of passing them on every call:

js
client.transactional.registerExtensions({
  cart:  { extending_schema: 'myns:luxe_cart', cart_item_extending_schema: 'myns:luxe_cart_item',
           customer_extending_schema: 'myns:luxe_customer' },
  order: { extending_schema: 'myns:luxe_order', order_item_extending_schema: 'myns:luxe_order_item' }
});

add_to_cart needs the customer schema as well. In Python, register_extensions takes a tuple for the two-schema services. The service has to be imported into the project before any of this works.

Supero Integrations teamSupero team answered
Link

Your answer

Adding my own fields to the cart and order | Supero Community