How to pass parameters to a page and use the value passed in an If clause?

I’d like to make two buttons visible or invisible depending on a parameter I send to a page. For example, I’d like a “buy now” button to Amazon or to Shopify depending on a parameter that I pass.

I’m guessing I need to define a global variable, set its value based on the parameter passed, then in an if statement do something like the following:

GlobalVariableName = ParameterPassed;

if (GlobalVariableName==“Shopify”)
{
$w( “#myAmazonButton” ).hide();
} else
{
$w( “#myShopifyButton” ).hide();
}
Would someone guide me through the API to achieve this simple block of code? (It’s been a couple of years since I coded actively, so please forgive any obvious errors in the example above)

Your Description is a little bit confusing.
Try to describe a little bit more detailed and as most as possible in a simple logical way.

For example:

  1. I have a page called “xyz”
  2. On this page i have a button.
  3. When i press this button…
  4. …then this and that should happen.
    5 and so on…

I just understood that you want to hide buttons, that all i could understand while reading your issue.

But perhaps it is also due to lack of knowledge of my english language-skills. :grin:

If it is about passing info from one page to the next (=maintaining state), this subject is well covered in the docs and even more here in this very forum: search and you shall find.
But in short, there are 2 ways: writing/reading back from local storage or adding/reading/deleting query parameters to the URL.

That’s not what I am going for. I need to pass a parameter directly to the landing page (from outside the site when the page is invoked), and then use that information to make a button on that page visible or not.

If you know how to capture the query variable and use it, that would be helpful.

I have a dynamic page that has two buttons.

  1. Buy on Amazon
  2. Buy Now (a buy now button from Shopify)

Depending on whether a parameter is passed to the page (from outside the site when the page is invoked) I need to hide() one of the buttons.

I need to parse the query parameters to see if a variable has been passed so that I can make one of the buttons hidden.

That’s what I am trying to do. :slight_smile:

https://www.wix.com/corvid/reference/wix-location/query

Thank you. Yes, I saw that, but in the end I decided to make copies of my dynamic pages and put the different button on the duplicates. It was more work because of what you have to do to “duplicate” a dynamic page. :frowning: