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?
Adding my own fields to the cart and order
Common question, written up by the Supero team.
1 answer
Make your own schema extend the base and add the field there:
{"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:
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.
Your answer
Know the answer? Sign in to post it. It takes an email address and a 6-digit code.
Sign in to answer