Help needed with syntax for repeating within js - PayPal Checkout Cart

Thanks Brian. This is actually the solution I was using previously but I wanted to use the latest PayPal Checkout integration but hit a wall with the repeat syntax within js code instead of html.

No problem, if you work out the .js way you can always share it back :grinning:

1 Like

I sure will. Hoping one of the Wappler team can chip in and give me the steer I need.

sadly my .js is quite weak. I actually bought some books on it the other day to get up to speed!

1 Like

Can anyone help with this? How to make part of the js script loop is what I need help with.

“items” in your JavaScript is expecting an array, so you can point to any array in your dmx app.

“items”: dmx.app.data.myarray 

To find the actual path to your array, you can execute dmx.app.data in the dev console and find your array.

Just make sure the array has the exact elements the js needs. You can always insert into a datastore in order to get the element names correct, and then point the js to that.

1 Like

Wow, massive thanks Ken. It looks like you’ve absolutely nailed it. I was stuck in the rut of having loops to add the data and completely overlooked the fact that it’s an array.

I will do as you suggest and let you know how it goes.

Cheers, Jon.

Hi Ken

I thought you’d cracked it and it was going to be easy but I just can’t get it to work.

“items”: dmx.app.data.datastore1
or
“items”: dmx.app.data.datastore1.data

are both failing. I’ve populated the datastore with the same structure but it just isn’t liking it.

Screenshot 2022-02-19 at 14.34.18

Are you able to offer me any steer or advice on how to get it to work?

It looks as those you have the correct array going in.

Aside from general troubleshooting, timing is often an issue with scripts if they run on page load. Make sure the script actually has all the data when it is running.

Thanks Ken. I am pretty confident it has all the data. The datastore is populated using a Page Flow on page load and I’ve disabled that so it uses the data already in there in case it was a delay issue but still no joy.

After poking around in the Wappler code, try dmx.app.datastore_datastore1.data

Thanks Brian. That doesn’t show any data I’m afraid.

It seems that dmx.app.data.datastore1.data is where it is but, for some reason, PayPal doesn’t like it.

I’ve had to abort the js route and go back to the form method you posted earlier in this thread. It’s a shame but at least it works.

Cheers again, much appreciated.

1 Like

Hi Brian. Has PayPal just changed how their https://sandbox.paypal.com/cgi-bin/webscr process so you can no longer pay by card but instead have to have a PayPal account? I finished my integration last weekend but now it looks to be different when clicking the submit button and going to PayPal’s site.

I’m curious to know if you’re having the same issue.

Cheers, Jon.

Just checked and yes, that appears to be the case now.
Off out now (wife’s birthday) but will look into it when i get a chance

1 Like

Have just checked the site i sent live last week and cards can still be taken on live site, not looked at sandbox

I can confirm that on testing the card payments option does not appear in the sandbox version however it does function normally when using PayPal in live situation

1 Like

Fantastic. Thanks Brian.

if it helps with syntax i have found (for a datastore named datastore1)

 document.write(this.localStorage.datastore_datastore1);

outputs the datastores json

Thanks Brian. Yep, that’s what I found, too. But PayPal Checkout isn’t liking it for some reason which is why I gave up going down that route.

If anyone from Wappler is able to give a brief piece of documentation on how to use the new PayPal Checkout it would be very helpful. I know PayPal isn’t the preferred platform, and I’m not expecting functionality like that which is available for Stripe, but just a steer on how to integrate data from a Data Store to PayPal Checkout would be extremely helpful. I don’t choose PayPal but I have been instructed to use it by the client.

yes, documentation is really confusing