Shopping Cart: Am I ready for payment gateway?

Ok, how do I include quantity in the query? There is no field for quantity?

You send the id to the query, return the id and price and then use the quantity for the calculations for your API checkout :slight_smile:

1 Like

Am I querying the data store or the products table? There is no quantity in the products table?

Sorry, that I am just not getting it. I do appreciate your help and patience.

i am sure if someone can just get me pointed in the right direction with this query the rest of the tutorial will make sense.

Brad, you use the data store to filter the products query. You do this in the server action.

  • filter the query by product is
  • return the product and price from the query
  • use the returned result to send to the checkout step in a formula like product price multiplied by the quantity.
1 Like

Ok, maybe I am making this more difficult than it needs to be. If I am not worried about people changing the prices in the browser do I even need the query? Is that the purpose of the query? If I can skip the query and just get the values from the local storage for. the api that might make things simpler?

Yes the serverside part is exactly for this. And you should not be not worried :slight_smile:

1 Like

So I can skip the query all together and get data to the API directly from the local storage? My user base is all local in our small theatre community and everyone knows everyone. I am not worried about anyone changing prices.

Well you can do this. However I wonā€™t be the person recommending you to not secure your site :slight_smile:

1 Like

Iā€™m not convinced that using your local storage directly is actually making the process easier anyway. You still need to get that data to SC so doing it the way @Teodor is suggesting is, in my view, much the same amount of work.

No, I certainly would not come back on you for that. :laughing: I understand the risks fully. Obviously doing it correctly would be the way to go. Iā€™m just not smart enough. :unamused:

It might be considering I have no idea how to do the query step. A sample query using my screenshotted data would be ideal. But I donā€™t expect someone to do the work for me.

So I assume youā€™re sending the local storage data to SC via post/get arrays?

No idea. Havenā€™t got past the very first step in the tutorial. The Query.

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

Thanks @max_gb. I will work through this and see if it helps. Correct me if Iā€™m wrong, your method requires a user to be logged in? You are also recording orders in the database? Can it be done without storing the orders?

This part is confusing to me?

{{$parent.insert1.identity}}

Thank you again so much for your help!

Yes well spotted. On this site users have to be logged in but you can skip the user identity insert.

You must insert though a new record into the Order table at the beginning so your line items in the array can be linked to the order id.

Good news and bad news.

Bad News: I have given up on the project and have to explain why I canā€™t provide them what I once was able to. :frowning:

Good News: There is a world wide pandemic and we wonā€™t need to sell tickets for awhile.

Much like waiting for a vaccine, I hope the Wappler team can integrate a payment gateway into Wappler before the pandemic is over. Thanks to @Teodor and @max_gb for their help and time. I feel bad for having wasted your time. It was very much appreciated though. I owe you. :beers:

Have you tried hiring someone from the forum so they build it for you or teach you how to do it? This was hard to read and watch. I feel sorry for everyone involved! Including you of course.

We are a non profit theatre and without funds coming in from productions and sponsors due to the pandemic we have no budget for it.

1 Like

Hey I want to buy a ticket - come on! :slight_smile: will keep the 1,5meter distance!

The show must go on!

2 Likes