Prevent Refresh from Adding Another Product in WooCommerce

Update: this issue has been resolved. WooCommerce now replaces the `add-to-cart` query arg with `added-to-cart` on success.

Prevent items from being mistakenly added to the cart multiple times.

Mountain America Jerky uses the WooCommerce eCommerce plugin for WordPress, and they were having an issue: when users added a product to their cart then refreshed, the item was being added again. Also, when customers added items to their cart, then hit back, they got the dreaded “Confirm Form Resubmission” notice.

To solve this issue, I added a redirection when users added products to their cart. The code hooks into WooCommerce’s `woocommerce_add_to_cart_action` function, located in `/woocommerce/woocommerce-functions.php`.

Here’s the code that you should add to your theme’s `functions.php` file, or to your own custom plugin:

add_action('add_to_cart_redirect', 'resolve_dupes_add_to_cart_redirect');
 
function resolve_dupes_add_to_cart_redirect($url = false) {
 
     // If another plugin beats us to the punch, let them have their way with the URL
     if(!empty($url)) { return $url; }
 
     // Redirect back to the original page, without the 'add-to-cart' parameter.
     // We add the `get_bloginfo` part so it saves a redirect on https:// sites.
     return get_bloginfo('wpurl').add_query_arg(array(), remove_query_arg('add-to-cart'));
 
}

I hope this helps someone else with the same issue!

Edit Product Link for Shopp Plugin

Shopp PluginIf you use the Shopp plugin for WordPress, you’ve likely found something frustrating: you click on the “Edit Post” link, and you get to edit the Store page, not the product in Shopp.

Here’s a quick fix: add the following to your theme’s functions.php file: Continue reading “Edit Product Link for Shopp Plugin”

Recover your password from Interspire Shopping Cart

Where did my Interspire password go?
I develop my websites locally, so sending Lost Password emails never works. When I forget what my password is, it’s quite the hassle.

I’m developing an Interspire Shopping Cart website, and lo and behold, I lost the password.

Here’s how to recover your password from Interspire Shopping Cart: Continue reading “Recover your password from Interspire Shopping Cart”

Tableless, accessible, nearly validating osCommerce — Rewriting the beast

Rocky Mountain Baggers

osCommerce accessibility stinks

osCommerce default installation is a huge mess for accessibility. Every piece of code that the platform spits out has endless tables and poorly coded HTML — finding your way through the code is like trying to clear brush.

The simple solution to osCommerce accessibility is to install the Simple Template System and put together a XHTML/CSS’ed out template.  That only solves one part of the problem, however, because your wonderful template is going to be wrapping around a whole slew of undesirable code.

Over a year ago, a client of mine wanted an osCommerce website. I wanted to create a masterpiece of accessibility. I tackled osCommerce head-on and re-wrote most of the code that creates the HTML.  It was a nightmare, but I created a nearly validating eCommerce website with osCommerce.

The experience was so scarring that I haven’t yet written about it 🙂 Nearly every file was affected, so upgrading it would be a nightmare, but it’s truly an effort of love.

KWD presents: a nearly validating, tableless osCommerce website

Continue reading “Tableless, accessible, nearly validating osCommerce — Rewriting the beast”

Standards-Compliant Shopping Cart with XHTML & CSS!

I’ve been looking for a shopping cart like this for a long time

One of my clients is looking to move from osCommerce to a more user-friendly solution, and I really want to use a shopping cart that is XHTML and standards-compliant…Something that validates and looks pretty with stylesheets off, has a full feature set, and a great admin panel.

I was quite pleasantly surprised when I discovered Tradingeye. They have a well-coded shopping cart solution as well as a CMS. Very, very interesting.  Looks like a pleasure to develop for; like WordPress for eCommerce. Check out their Shopping cart demo. Continue reading “Standards-Compliant Shopping Cart with XHTML & CSS!”

Amazon Marketplace to the rescue

I have lots of DVDs that have only watched once.   I have many books that I will never read again.  I wanted to sell them for money.  Should be easy, right?  Well it turns out, it is!  Amazon Marketplace is a simple solution. Continue reading “Amazon Marketplace to the rescue”