Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

passing a variable to paypal's shopping cart

Featured Replies

I have just added a shopping cart button from PayPal to my FMP website. My problem is, that I dont know the proper syntax for sending a variable or token over to the description of the item that goes into the shopping cart.

The name of the description of the item in my database is called "asset code". I attempted to place [FMP-Field:+Asset+code] directly into the link but it does not show in Paypals cart. In fact, the only thing that seems to show is if you hard code a description.

PayPal's shopping cart button looks like this:

<a href="#" onClick="window.open('https://www.paypal.com/cart/add=1&[email protected]&item_name=[FMP-Field:+Asset+code]&item_number=[FMP-Field:+Asset+code]&amount=23&undefined_quantity=0&no_shipping=0&no_note=0','cartwin','width=600,height=400,scrollbars,location,resizable,status');"><img src="" border="0"></a>

The [FMP-Field] tag should look like this:

[FMP-Field:asset code]

Hope this helps.

Garry

  • Author

Garry,

First let me say that I really appreciate your help.

I changed the syntax as per your instructions but it still appears blank in paypals description. I have pasted the code below. Keep in mind that the paypal shopping cart button directs you to their server and takes the information that you send it and displays it on their own webpage. Is it possible that their server does not recognize the fmp variables? Or should it make no difference since the value of the variable becomes a constant before its passed? Anyway, here is the code:

<p><a href="#" onClick="window.open('https://www.paypal.com/cart/add=1&[email protected]&item_name=[FMP-Field:asset code]&item_number=[FMP-Field:asset code]&amount=23&undefined_quantity=0&no_shipping=0&no_note=0','cartwin','width=600,height=400,scrollbars,location,resizable,status');"><img src="" border="0"></a></p>

Have look at this anchor in the source code, after it has been returned to your browser after a post action, by using view source.

Have the replacement tags ( ie [FMP-Field:asset code]) been successfully replaced with the values from your database record? or are they blank (eg ...... item_number=&amount......).

This might give you a better idea where the problem is coming from ...

you are correct in assuming that the FMP tags will have no effect on the paypal server as these are an instruction to FMPro to insert values from the record that has been either added, found or edited in your database and the data is inserted before the page is returned to you ... if everything is working correctly that is smile.gif

  • Author

Ok, I did that (good idea!). It seems that the info that I pass to paypal ends up in a javascript array. The FMP variables appear blank in the array. The fields that I hardcoded did appear in the array. So I guess I need to look at some Java code that will store the [FMP-Field:asset code] into a variable that I can pass into paypal's shopping cart button.

Does anyone know how to do this?

You can assign FM data to Javascript variables like this:

var assetcode = "[FMP-Field: asset code]" ;

The following is, in fact, Javascript:

onClick="window.open('https://www.paypal.com/cart/add=1&[email protected]&item_name=[FMP-Field:asset code]&item_number=[FMP-Field:asset code]&amount=23&undefined_quantity=0&no_shipping=0&no_note=0','cartwin','width=600,height=400,scrollbars,location,resizable,status');"><img
So you can convert it to:
onClick="window.open('https://www.paypal.com/cart/add=1&[email protected]&item_name=' + assetcode + '&item_number=' + assetcode + '&amount=23&undefined_quantity=0&no_shipping=0&no_note=0','cartwin','width=600,height=400,scrollbars,location,resizable,status');"><img

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.