简体   繁体   中英

AMP pages server by Google on checkout

I have a big problem with product amp pages when the page is served by google cache. The user can add the product to the basket with a call like this:

action-xhr="https://sample.com/index.php?route=checkout/cart/add".

The backend is Opencart(php), and the product added to cart, no problem, but when the user go to checkout page (no AMP page, and not served by Google cache) there are no products on the shopping cart. I guess it will be because when the article is added it is in a domain (google) and the payment page is in another domain, mine.

Is there any way to fix this? I don't understand that google wants to provide a better user experience, and makes it so difficult to create a simple product page

Sorry you're hitting problems.

Here is the most relevant guide for your situation. In short, you want to transfer some kind of identifier from the AMP version of the page to your backend, and use that to sync the user state.

Without more information on your seutp, it is hard to get more specific.

source: work at Google on AMP

Are you looking for a way to make sure the user's cart is retained, whether they try to add to cart on an AMP cache or on your origin?

If so, there's a nice way described in detail here:

https://blog.amp.dev/2020/06/16/amp-camp-cross-origin-user-state-in-amp/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM