{"id":243,"date":"2011-07-26T21:22:45","date_gmt":"2011-07-26T21:22:45","guid":{"rendered":"http:\/\/www.extradrm.com\/?p=243"},"modified":"2011-07-26T21:22:45","modified_gmt":"2011-07-26T21:22:45","slug":"wp-shopping-cart-and-wp-super-cache","status":"publish","type":"post","link":"https:\/\/www.extradrm.com\/?p=243","title":{"rendered":"WP Shopping Cart and WP Super Cache"},"content":{"rendered":"<p>If you are using the <a href=\"http:\/\/wordpress.org\/extend\/plugins\/wp-super-cache\/\" target=\"_blank\">WP Super Cache<\/a> plugin on your WordPress blog together with some WordPress Shopping Cart plugin (eg. <a href=\"http:\/\/www.tipsandtricks-hq.com\/?p=768\" target=\"_blank\">Simple WordPress PayPal Shopping Cart<\/a>) then there is a good chance that you are experiencing some funny behavior (eg. the shopping cart doesn\u2019t show the products after item addition) with your shopping cart plugin.<\/p>\n<h3>The Problem<\/h3>\n<p>The reason behind this is that the WP Super Cache is a static caching plugin. It generates HTML files that are served directly by Apache without processing PHP scripts. So when a visitor on your blog adds a product to the shopping cart and is wondering why it\u2019s not being displayed in the basket is probably because he\/she is still loading the static HTML (cached) file of that page.<\/p>\n<h3>The Workaround<\/h3>\n<p>You basically need to tell the WP Super Cache plugin to not cache certain pages (pages where you are displaying the shopping cart eg. checkout page).<\/p>\n<p>Super Cache allows you to specify a string that forces a page not to be cached. For example, if your URLs include year and you do not want to cache last year posts, it\u2019s enough to specify the year, i.e. \u2018\/2008\/\u2019. WP-Cache will search if that string is part of the URI and if so, it will not cache that page.<\/p>\n<p>So in your case you can use a unique string like \u2018wp-shopping\u2019 (eg. www.your-domain.com\/your-page-title-wp-shopping) in the URL of the pages where you have the shopping cart displayed so those pages are not cached. Then enter that string (wp-shopping) in the Rejected URIs field of the WP Super Cache settings.<\/p>\n<p><a href=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2011\/07\/shopping-cart-wp-super-cache-workaround.jpg\"><img loading=\"lazy\" class=\"size-medium wp-image-244 alignleft\" title=\"shopping-cart-wp-super-cache-workaround\" src=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2011\/07\/shopping-cart-wp-super-cache-workaround-300x136.jpg\" alt=\"\" width=\"300\" height=\"136\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>If you are displaying the Category in the URL then you can create a special category called \u2018NoCaching\u2019 and add the posts\/pages (that you do not want Super Cache to cache) to that category. This way your URL will look similar to the following:<\/p>\n<p>www.your-domain.com\/NoCaching\/checkout-page<br \/>\nwww.your-domain.com\/NoCaching\/all-products-page<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you are using the WP Super Cache plugin on your WordPress blog together with some WordPress Shopping Cart plugin (eg. Simple WordPress PayPal Shopping Cart) then there is a good chance that you&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":2842,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[31],"tags":[133,134],"youtube_video":null,"_links":{"self":[{"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/posts\/243"}],"collection":[{"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=243"}],"version-history":[{"count":0,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/posts\/243\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/media\/2842"}],"wp:attachment":[{"href":"https:\/\/www.extradrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=243"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=243"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=243"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}