I’ve seen many clients and websites avoid shopping carts like the plague because most of the third-party, off-the-shelf shopping carts can be intimidating, complex and confusing. Shopping Carts don’t have to be scary. Especially if you only have a couple of items to sell.
If you only have a ‘Buy Now’ button for each item – whether it goes to PayPal or to your merchant account – then your customers may not want to keep buying. It’s much easier to place the items, even if it’s just a couple, into a shopping cart and buy at once. You only want your customers to ‘think’ about paying once. The more chance they have to ‘think’ about it, the less likely they will be to keep forking out money.
I always advise my clients to either have a shopping cart or offer their products/services in bundles or packages, if there is any chance that their customer might consider buying more than one of their products or services at the same time. (By the way, don’t look at my site – I’m working on it – but, I’m often too busy working on my client’s sites that my site gets put off until last. I’ll get there.)
You don’t need the third party software – even if it’s free. It will probably be over kill and have a lot of options that you don’t need. It has to be everything for everybody. You just need something that does what you need to do and nothing more.
We will be utilizing the cookie functionality of your customer’s browser. There’s always a chance that your customer will have cookies turned off, but now days, most everyone has them turned on. There’s also a chance that they will delete their cookies if they shop and then go away for a while, but that’s a small risk to take for the option of having a quick, easy shopping cart. You could always require the customer to login and then save the cart to the database so it will be there when they return, but every step you make a customer take is another chance to lose them before they click that ‘pay now’ button.
With a shopping cart, you only need one payment page that has the total they owe you. They can shop all day without thinking about paying, except that one final time for the total of all the things they are purchasing from you.
Here’s how to build an easy shopping cart in WordPress. In this example I have 3 CD’s that I’m trying to sell. I could have easily made these into packages, but even with just three items, I would have needed 7 packages to get every combination (CD1, CD2, CD3, CD1 & CD2, CD1 & CD3, CD2 & CD3, all three). You don’t want them to have too many choices. They get confused and may leave. It’s easier to just store the items they want AND the quantities of each in their shopping cart (cookies). They don’t have to sign up and they can mix and match CD’s as they please.
// <?php if ($_POST['submit']) { //after the page has been submitted $cd1 = $_POST['cd1']; // get the values passed from the form $cd2 = $_POST['cd2']; $cd3 = $_POST['cd3']; setcookie('cd1', $cd1, time()+31536000); //set the quantities in the cookies for each CD - set the expiration date for the cookie setcookie('cd2', $cd2, time()+31536000); setcookie('cd3', $cd3, time()+31536000); } else { // this has not been submitted, let's start the form. $item = $_GET['item']; // which item are we adding to the cart? if (!$quantity = $_COOKIE[$item]) { // see if there is a cookie for that item already $quantity = 0; // if not, let's set the quantity to zero } $quantity++; // let's add another to the quantity, setcookie($item, $quantity, time()+31536000); // set the new cookie quantity $cd1 = $_COOKIE['cd1']; // get the other two item quantities so we can put them in the form $cd2 = $_COOKIE['cd2']; $cd3 = $_COOKIE['cd3']; if ($item == 'cd1') $cd1 = $quantity; // replace the current item with the new quantity if ($item == 'cd2') $cd2 = $quantity; if ($item == 'cd3') $cd3 = $quantity; } if ($cd1 || $cd2 || $cd3): ?> //If we have a cd in the cart <form action="/cart" method="post"> // show the form <table width="80%"> <tr> <th width="15%" align="left">Item</th> <th width="5%" align="center">Quantity</th> <th width="10%" align="right">Total</th> </tr> <?php if ($cd1): ?> // if there is a CD1 in the cart, show it <tr> <td>CD 1</td> <td align="center"><input type="text" name="cd1" value="<?php echo $cd1; ?>" size="3" /></td> <td align="right"><?php echo number_format($cd1 * 15,2); ?></td> // calculate and show the price </tr> <?php endif; ?> <?php if ($cd2): ?> // if there is a CD2 in the cart, show it <tr> <td>CD 2</td> <td align="center"><input type="text" name="cd2" value="<?php echo $cd2; ?>" size="3" /></td> <td align="right"><?php echo number_format($cd2 * 15,2); ?></td> // calculate and show the price </tr> <?php endif; ?> <?php if ($cd3): ?> <tr> <td>CD3</td> <td align="center"><input type="text" name="meditation" value="<?php echo $meditation; ?>" size="3" /></td> <td align="right"><?php echo number_format($meditation * 15,2);?></td> //calculate and show the price </tr> <?php endif; ?> <?php if ($cd1 || $cd2 || $cd3): ?> // show the total <tr> <td> </td> <td> </td> <td align="right">$0.00</td> </tr> <?php endif; ?> </table> // allow them to update the quantities - this loads this page and adds the new quantity to the cookie at the top of the script <input type="submit" style="-webkit-border-radius: 10px;border-radius: 10px;line-height: 26px;text-shadow: 1px 1px 0 rgba(255,255,255,0.3);-webkit-box-shadow: inset 0 1px 0 0 rgba(255,255,255,0.4), 1px 1px 1px rgba(0,0,0,0.1);box-shadow: inset 0 1px 0 0 rgba(255,255,255,0.4), 1px 1px 1px rgba(0,0,0,0.1);padding: 6px 14px;font-weight: bold !important;font-size: 11px !important;margin: 0 5px 8px 0;background: linear-gradient(to bottom, #88bdff 0%,#60a7ff 100%); cursor:pointer; border: 1px solid #3e8ff4; color: #23528c" name="submit" value="Update Quantities" /> // or checkout - go to our payment form [button link="/checkout"]Checkout[/button] </form> <?php else: ?> // There isn't anything in the cart Your cart is empty. <?php endif; ?> <br clear="all" /> <?php if (!$cd1): ?> // Let's give them a chance to add CD1 to their cart if they haven't already - upsell, upsell, upsell! <div style="float:left; padding:30px; width: 210px"> <a href="/cd1"> <img src="http://example.com/wp-content/uploads/2013/08/cd1-150x150.png" alt="CD 1" width="150" height="150" class="alignnone size-medium wp-image-290" /> </a> <br /><br />CD I<br /><br /> <a href="/cart?item=cd1&action=add" alt="Add to cart" title="Add to cart"> <span style="font-size:20px">Add to Cart</span> </a> <br /> <span style="font-size: 24px">$15.00</span> </div> <?php endif; ?> <?php if (!$cd2): ?> // Let's give them a chance to add CD2 to their cart if they haven't already - upsell, upsell, upsell! <div style="float:left; padding:30px; width: 210px"> <a href="/cd2"> <img src="http://example.com/wp-content/uploads/2013/08/cd2-150x150.png" alt="CD 2" width="150" height="150" class="alignnone size-medium wp-image-290" /> </a> <br /><br />CD2<br /><br /> <a href="/cart?item=cd2&action=add" alt="Add to cart" title="Add to cart"> <span style="font-size:20px">Add to Cart</span> </a> <br /> <span style="font-size: 24px">$15.00</span> </div> <?php endif; ?> <?php if (!$cd3): ?> // Let's give them a chance to add CD3 to their cart if they haven't already - upsell, upsell, upsell! <div style="float:left; padding:30px; width: 210px"> <a href="/cd3"> <img src="http://example.com/wp-content/uploads/2013/08/cd3-150x150.png" alt="CD3" width="150" height="150" class="alignnone size-medium wp-image-290" /> </a> <br /><br />CD3<br /><br /> <a href="/cart?item=cd3&action=add" alt="Add to cart" title="Add to cart"> <span style="font-size:20px">Add to Cart</span> </a> <br /> <span style="font-size: 24px">$15.00</span> </div> <br clear="all" /> <?php endif; ?> //
That’s it! Just store the quantities for each CD in a cookie and add to it each time they add another to the cart. Or allow them to edit the quantities on the page. When they are ready they will click the checkout button and go to the payment page where the sale is complete!
I put this code in a /cart WordPress page using the ‘PHP Code for Posts’ plugin. Happy Selling!