Arsenal21 / stripe-payments

Stripe Payments Plugin for WordPress
11 stars 8 forks source link

Conflict with caching plugins when same shortcode with different price is used on different pages #19

Closed erommel closed 6 years ago

erommel commented 6 years ago

https://wordpress.org/support/topic/plugin-functions-only-on-devices/

Quoting myself:

Looks like caching plugins are the reason why products with same name but different price are having the same price.

For example, if you have several buttons on your site with same name but different price, like [accept_stripe_payment name="My product" price="9.95" button_text="Buy Now"] [accept_stripe_payment name="My product" price="14.95" button_text="Buy Now"]

and caching plugin is enabled, it caches the price for one of the products and uses it for other product.

Solution: use different names for your buttons. Example: [accept_stripe_payment name="My product 1" price="9.95" button_text="Buy Now"] [accept_stripe_payment name="My product 2" price="14.95" button_text="Buy Now"]

Caching plugins are caching transients, so if user first accessed the page with 9.95 price and then accessed page with 14.95 price, Stripe payment popup will be showing 9.95 price.

While having same product name for different prices is kinda weird, the plugin still should be able to handle it properly. I'm thinking of adding a unique ID for each payment button to be used in transient name so each payment button will be unique and won't mess up even if transient is cached.

Arsenal21 commented 6 years ago

Not super worried about it as going forward, the following is going to be what we will push the users to use more and more: https://stripe-plugins.com/creating-product-stripe-payments-plugin/

However, its never a bad idea to improve stuff.

erommel commented 6 years ago

Thing is, it can also affect products too. Plus some people do like to just use payment buttons, not the products. At least I can see use cases for both things :-)

Anyway, will do some testing with caching plugins. The trick is that when using caching plugins, you need to be logged out from WP as most caching plugins aren't caching content for admin user, for example.

Arsenal21 commented 6 years ago

True. Here is one way to deal with it, when the payment is being processed, the plugin can set a cookie (at the init stage). Then in the caching plugin's settings the user can say "If this cookie is present then do not serve cached page to this visitor.

Here is the instruction that I give to users for WP eStore and W3 Total Cache plugin compatibility. WP eStore sets the "cart_in_use" cookie.

Step 1) Go to the "Page Cache" menu in your W3 Total Cache plugin.

Step 2) Add the following line in the "Rejected Cookies" field under the "Page Cache" settings menu of the W3 Total Cache plugin and all done:

cart_in_use

erommel commented 6 years ago

This looks to be dealt with, more or less. So closing this issue for now.