Using WordPress as e-Commerce without plugin

Since a lot of web designers are so crazy about WordPress, I am too, excited to explore and learn about how it work.

Recently while I was looking around for tutorial on WordPress theme, I find a few and connected them, then “A-Ha!” moment was on, and I went straight to give it a test. I collected a few tutorial and created this little theme that can easily become e-Commerce with a PayPal button without any plugin. Just some hack here and there :)

Nettuts+ Paypal payment form
First tutorial I found was creating a PayPal payment form from Nettuts+. In order for the consumer to pay, I placed the payment form on single.php which shows on every entries (take it as product pages). Below is the form I edited from Nettuts+ tutorial so it doesn’t have a drop-down select option.

Code placement

<div style="clear: both; padding: 20px; border: 1px solid #eee;">
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="[email protected]">
<input type="hidden" name="item_name" value="My item">
<input type="hidden" name="item_number" value="00012">
<p>USD10 per pax
<input type="hidden" name="amount" value="10">
<input type="hidden" name="no_shipping" value="0">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="lc" value="AU">
<input type="hidden" name="bn" value="PP-BuyNowBF">
<input type="hidden" name="return" value="http://www.google.com.my/">
<input type="submit" value="Buy now!"></p>
</form>
</div>

In order to make the price editable to each entry/product. I use custom field. You can check the tutorial from Desizn Tech. Simple yet functioning. When I say functioning, it means if an entry doesn’t have a custom field, the form will not show up.

PHP to check if "Price" custom field is available. Then shows
<?php if (get_post_meta($post->ID, 'price', true) { ?>
<div style="clear: both; padding: 20px; border: 1px solid #eee;">
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">

Your PayPal ID
<input type="hidden" name="business" value="[email protected]">
<input type="hidden" name="item_name" value="My item">
<input type="hidden" name="item_number" value="00012">      

If custom field for "Price" is available, it will then print here
<p>USD<?php echo get_post_meta($post->ID, "price", $single = true); ?> per pax
<input type="hidden" name="amount" value="10">
<input type="hidden" name="no_shipping" value="0">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="lc" value="AU">
<input type="hidden" name="bn" value="PP-BuyNowBF">

Your returned URL, more check on Nettuts+
<input type="hidden" name="return" value="http://www.google.com.my/">
<input type="submit" value="Buy now!"></p>
</form>
</div>
If custom field is not available, it show nothing
<?php } else { } ?>

Custom field
So the custom field will be called “price“.

Payment form
Done! Now, every time you want to post a product, make sure the category is correct and you’re good to go. However, this is limited to payment and product. It is best for download-able product… For blogger who also run e-Commerce on the same time, this is a good to go :)