What would be the best way to do this with a cart

I have a POS system I am working on and I’ve hit a wall so I’m looking for suggestions

I have the products all working, no issues.
However there are also gift cards available of which a unique number needs to be stored with the name and phone number.
Heres the confusion:
I need to add the value of the gift card into the cart, when clicking the pay button I need it to store the voucher information into a table (only if there is a voucher in there) otherwise I just need to process the payment.
I’m thinking to store the information into Datastore (voucher) and Datastore (cart) but how on earth would I get these 2 to merge?

Any suggestions would be welcome

I built something similar recently for selling tickets online online but also needed to sell memberships.

I have a repeat that inserts each line in the checkout into a table called order_lines. This stores the ticket information, price, qty etc.

If it’s a membership, then the condition filters this out and also adds a new record into a Memberships table.

Cart is stored in data store, just simply the product id, qty, and any variables. Then there is a hidden form on the checkout page that sends this to my server action.

I also have another integer field called item_type. If it’s a 1 then I know it’s a ticket, if it’s a 2 then I know it’s a membership and this is what the condition filters on in my server action.

How about just adding the voucher as a line in the cart but with a negative price? You could create some extra fields in your data store for the voucher code and phone number which just remain empty for all the rows of products but can be used when the row is a voucher. Would that work for you?

problem is that the gift voucher would need to be stored in one table and also in the sales table. this is where I have the issue.

Hi @gunnery, i think what u need to do is use Workflow. Check this post: Introduction to App Connect Flow

Btw u can use the Dynamic Event “Click” on your pay button and submit 2 or more forms at the same time, so u can store data simultaneously in 2 or more data bases, data store, etc.

Or you can have two database inserts in your server connect script.