My previous post asks the same question, but I'm trying to be more concise here and look for a fresh take on how to do it (since my previous method, again shown on the previous post, isn't working out). I've created a product data-type called "room-rental" that lets users select dates they'd like to rent a room. On its product page, they can select from a calendar which dates to rent, and the product's daily rate will sum up the total cost below. So, two main variables here: selected_dates (an array of the dates in a 'yy-mm-dd' format) total_cost (an integer summing the total cost) So the question: How can I redirect to the check-out page while also carrying these two variables over? Purpose of total cost: This is what determines the amount of money the user is going to pay. Purpose of selected dates: Once the user pays for their room rental, the list of selected days will be submitted to one of our databases (I'm using MySQL via phpMyAdmin) and we'll take note of the start and end date. This will then be picked up from code I've already got that'll determine our unavailable_dates, and future users can't select those dates until the booking is complete. If you wanna see my previous attempt, go to this link (I was trying to use AJAX and what not, resulting in going to the cart-page and having nothing load due to some error stating the data was null, which it wasn't) https://stackoverflow.com/staging-ground/78898376
Jese Leos
August 22, 2024
Verified user
You can always use transient with short expiration date. Before redirection: set_transient( 'myprefix_selected_dates', $selected_dates, 10 ); // 10 - means that it will be removed after 10 seconds. set_transient Docs After redirection: // get data $dates = get_transient( 'myprefix_selected_dates' ); // We set expiration date, but it is nice to clear to be sure. delete_transient( 'myprefix_selected_dates' ); if ( false !== $dates ) { // Do something } get_transient Docs delete_transient Docs