noob question: I'm building a checkout system for an online commerce site. I'm getting the bug where clicking on the "place order" button multiple times will place the order multiple times. I have an idea to load between the button-click page and place-order page with a page that waits several seconds before launching using javascript the place-order page.
My question is: what are some of the policies online for dealing with this particular scenario?
The recommended practice is to:
Include a unique id on the order page
Disable the order button once it has been clicked
Check for the unique id in your serverside processing (make sure to handle race conditions)
There are lots of specific details to consider, but these heavily depend on your platform/framework of choice.
Related
The title may be a bit awful as I'm really not sure how to describe what I'm trying to achieve without using lots of words.
I'm currently building an events website. This website has the option for users to create their own events which can be added to a big list of upcoming events that other users have submitted.
What I want to do is be able to have a user create an event and have the details of the event stored in an SQL database (which I've successfully done), I want to be able to then have a large list of events on a separate page the details of which are pulled from the server dynamically using PHP and SQL (I've also successfully done this). The part I am struggling with however is being able to create unique pages (or a single dynamic page) that displays a more detailed look at the event, such as age restrictions etc etc, which cannot be displayed on the big list which displays all the available events.
I figured that this could be done using a unique eventID, which is something the SQL database already includes and autoincrements with each new event entry. What I'm really not sure about is how I'd be able to pass that eventID through the link to the more detailed page so that the detailed page can be created displaying all of the details of the event.
I'm not even sure if this idea will work at all. Would having a page with a unique URL that is created on event submission that has a more in-depth look at the details of the event be a better idea? How would I go about creating unique URL webpages that correspond to each event on event submission?
I'm really not sure how I need to go about this at all, so I need some help and pointing in the right direction.
Here's a kind of TLDR:
1) Events website
2) All events on the website are displayed on a single page that has minimal detail about each event (title, date, location) BUT has a link to a page that displays the event in more detail.
3) User can select an event from the list and click on that event's unique HTML link to more detailed page
4) More detailed page displays event in more detail by pulling event's unique information from the database
Feel free to ask any questions at all as I know this probably isn't the easiest idea to get across
When creating the links from the general listing page to the detail page, simply include the id in the link. For example:
<A HREF="mysite.com/detail.php?id=3>Big Event</A>
In detail.php then, you'll find the id in $_GET['id'].
I have a couple of pages where the user can add and remove stuff in order to update the results. i.e. in a "ShoppingList"-page where the user can add/remove drinks in order to see what ingredients they need.
Each of these drinks is stored in a cookie, with PHP, so the user have the ability to navigate and explore the site, and then return without having to add the drinks again...
When the user do this, adds/removes drinks, the entire page is reloaded.
Drinks are added to a cookie immediately, before any html and stuff, then refreshed once again in order to build the php.mysql.query based on the values now stored in the cookie.
I think this is a lot of unnecesary reloading and stuff. It should be something more like just refreshing the actual content that needs to change, and not reloading everything else - Lots of unnecesary mysql requests just to add/remove a drink from the shoppinglist. And this of course slows site down..
Whenever the page is loaded, I need to check the cookie in order to present the correct results. Then, when a user adds/removes a drink, I would like to do this in the background (update the cookie and update the result). Hopefylly this could speed up the user experience.
I have a site up'n'running here - as a "prototype" : http://barkeeper.thomaskile.me/?side=handleliste (norwegian site, but google translate sort of gives you an idea of what it says. just tested it..)
This same thing goes for all three pages on my site so far..
Any suggestion on how to accomplish this? Is it som sort of jquery.AJAX-thing? If so. WHere do I start any sort of ajax-thing. Not sure how that works in practice when the user doesn't do anything (on page load)...
This is usually done by manipulating DOM.
Remove the element from one list and create it in another list.
Checkout jQuery - the javascript library.
I have an application in which I display a form so a user can search for client records based on last name. After entering search parameters, the record or records (there could be multiple clients with the same last name) are displayed. I then want the user to be able to select a client record, possibly with a radio button, and hit one of two buttons: Display details, or Create Reservation. The Display Details button should cause a new display with details of the selected record. The Create Reservation button should cause a new form, with its own handling, to be displayed.
Now, I know I can set things up according to this login
<?php
if (display button was pressed)
{
php code to retrieve more data and display details
}
else if (create reservation button was pressed)
{
php code to generate and display the reservation form, with appropriate handling
}
?>
display the original form with the search results
The problem is, I end up with really ugly, hard to read code because the php code to generate and display the reservation form is lengthy, and needs its own validation, database interaction, and form handling. The code, to my Java-oriented eye, looks ugly and non-modular. Plus, the code for handling the reservation form is icky, with lots of flag setting to determine if we are in form entry mode or form handling mode. I would like a much cleaner way to do this. So my question is, what is the best practice for handling the situation where there are multiple buttons and the action associated with each button is complex?
I could call a function, obviously, but I still end up with the ugly flags determining which state the script is in (are we displaying the reservation form or handling it?). I could create another php file and include it, but the ugliness persists. Or, I could use header, and pass the client record id in a session variable to the new php script. But that would mean a second, unnecessary retrieve from the database to get the client information again.
All the code examples I see on the web show very simple processing after a form button is pressed. What is the best way to do complex processing and displaying a second form based on a button press?
Have you considered using a framework like Laravel for your site. It would seem to me that you must be doing this "manually". With the complexities you described, having a system with routes and "build-in" functionality (like Eloquent ORM) might serve to simplify things for you.
I would go for using ajax and a rich jQuery plugin (or some other framework) to do what you want.
Basically you will handle lists and the functionality that you mentioned with the php reading data and jQuery scripts to dysplay it. And the information that you have to show would be through ajax. Or when you want to edit.
Here is a cleaner example of what you need:
http://jqueryui.com/dialog/#modal-form
I am generating add to cart buttons from a mans site separate from magento. for some reason when you click the add the cart button, it does not recognize a session so the enable cookies page show. if you refresh the page and on afterward , it works. how can i activate the session when using a external add the cart button.
Without seeing the code it is hard to know precisely, but in general terms, you need to look at the procedure which checks the session and explicitly initialise the magento session when the button is clicked.
One thing to note: If the buttons are on another domain, you may have problems with the session being transferred from one to another, which will make PCI compliance a little more tricky.
My advice would be to take a look at the API to see how you can connect into your Magento application in a clean way.
Thanks in advance for your help. I'm completely stumped on how I can do this.
Here is my issue.
I have a node type show;
Each show has a number of performance dates and times.
When the user clicks "purchase tickets" from a show's page, I need to show them a single page, where the following happens:
The top of the page has a calendar that has dates and times available for this show highlighted. The user can then pick a date and time for this show that he wants to see. He can pick multiple dates and times.
Once he picks and date and time, I add them to a "cart" using ajax. The user can then enter the number of tickets that he wants for each performance.
Finally, on the bottom of the page he enters his checkout information (name, address, credit card etc) and is then pointed to a confirmation page. This is not done by ajax. Finally he authorizes the transaction and check out. (I'm using UberCart, but nothing else tied in, so I can switch if needed).
This is driving me nuts. I have no idea how to pull this off. Not even where to get started. Can someone please help?
What you want to do, is going to be quite hard and wont work well with ubercart, since you want to make a single add to cart and checkout page.
Ubercart will by default allow users to add items to their cart, and would also by default create a checkout flow, but you want something complete different than what ubercart offers. You might want to rethink your approach and either choose a flow that works better with ubercart or choose a different solution that by default works better with what you want (if there is such a thing).
What you can do
To do what you describe, you would need to create a custom page, that shows the calendar with the shows, some javascript to hand the ajax and a checkout form.
Behind the scenes you need to generate the calendar with the appropriate days (the date module might help you), respond to the ajax requests and add items to the basket, handle the checkout flow/order status and redirect to payment form or handle payment as well.
All of this would need to happen in a custom module, you would need to use hook_menu to create the page, that would take the product node as argument. You can use that in your callback function to generate the calendar. You would also need to create a callback for the ajax and add the actual javascript to do all the magic.