extcode / cart

Cart is a small but powerful extension which "solely" adds a shopping cart to your TYPO3 installation. The extension allows you to create coupons, products with or without variants, special prices.
GNU General Public License v2.0
57 stars 51 forks source link

[BUG] "Document expired" in multistep checkout when using browser back button #518

Closed rintisch closed 5 months ago

rintisch commented 5 months ago

Bug Report

Current Behavior Steps to reproduce:

  1. Using the multistep checkout as implemented.
  2. Fill the cart with one or more products.
  3. Go to the cart and fill all steps till you are on the summary page.
  4. Use the back button of the browser.
  5. See error: "Document expired" (in Firefox) or "Confirm Form Resubmission" (in Chrome)

The same happens when making step 1-3 as described above and then:

  1. Use back button of the form to get to step 3 again.
  2. Use back button of the browser (which should then show step 4 again)
  3. See error: "Document expired"

Expected behavior/output User shall never see "Document expired" page.

Environment

rintisch commented 5 months ago

This behaviour is not a bug in EXT:form but a safetyguard from the browser.

Warning: My solution is for sure NOT best practice and NOT optimal. But it's the lowest hanging fruit at the moment.

I circumvented this problem by adding the following JS to the steps 2 - 4 (Step2.html, Step3.html, Step4.html):

if ( window.history.replaceState ) {
  window.history.replaceState( null, null, document.referrer );
}

Might be a good idea got add a hint about the problem and maybe even adding this (for sure) suboptimal solution.

EDIT: After some more investigation I implemented a proper solution by using the PRG pattern.