Shopping Cart: Am I ready for payment gateway?

Brad,

I will try and guide you through the checkout server action which includes the query. There are 3 tables in my database (you can rename/adjust) - Product, Order, Order_Lines

Server action called checkout.php:

  1. DB connection
  2. DB Insert

Inserts the user identity and also the current date/time to the order table.

  1. Repeat

Under globals $_POST I have an array called record. Within this, there are variables for: productID and QTY. The repeat expression is based on this array, the most important variable is the productID.

Within this repeat steps we have the Database Query which queries the price field from my Products table. The condition set is something like, product.id = productID (from our record array).

The second step within the repeat is a database insert to the Order_Lines table. This inserts the productID, QTY, and price from the query in the previous step. It also needs to insert the orderID which in my case is something like {{$parent.insert1.identity}}

That’s it for the repeat step.

  1. Database Query (again but different)

This queries the price field from the Order_Lines table with a condition set where the Order_Lines.orderID = {{insert1.identity}}. Under the price column you need to select SUM from Aggregate column and I give it an alias of TotalPrice.

Check output too.

That should be it. You’ve now got your queries setup and you can follow the rest of the tutorial and setup the stripe API action.

2 Likes