I am looking to create a dynamic Add-to-Cart button. The problem is that I need my server to dynamically create the "add-to-cart" URL.
Currently, I have a static example built here at this link.
You'll notice at the bottom of the page is a pay-per-post function, and an "Unlock Full Article" button. I would like this button to act as an add-to-cart button. The only problem I am having thus far, is how to dynamically create the correct URL extension?
Here is the static URL:
That post ID needs to be dynamically created based on the page. I thought to try this:
https://example.com/insider/?add-to-cart=<?php echo the_ID(); ?>
but it explicitly echoes this in-page.
Is there a way to customize this dynamically and use the_ID() function to get the id of each post this button is on?