<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Okada Design Blog &#187; shopping cart</title>
	<atom:link href="http://www.okadadesign.no/blog/tag/shopping-cart/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.okadadesign.no/blog</link>
	<description>Welcome to Okada Design Web Development Blog</description>
	<lastBuildDate>Wed, 11 Jan 2012 23:21:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Kaimonokago version 1.1.4 Beta released</title>
		<link>http://www.okadadesign.no/blog/kaimono-kago/kaimonokago-version-1-1-4-beta-released/</link>
		<comments>http://www.okadadesign.no/blog/kaimono-kago/kaimonokago-version-1-1-4-beta-released/#comments</comments>
		<pubDate>Tue, 05 Apr 2011 19:31:39 +0000</pubDate>
		<dc:creator>shinokada</dc:creator>
				<category><![CDATA[Kaimono Kago]]></category>
		<category><![CDATA[shopping cart]]></category>

		<guid isPermaLink="false">http://www.okadadesign.no/blog/?p=2729</guid>
		<description><![CDATA[ <p>The version 1.1.4 has multi-language module for the front-end shop. You can add any number of languages as you like. After adding languages in the languages module, you are able to input other languages to pages, products, menus and category. After adding languages in the backend, you need to add a directory and [...]
Related posts:<ol>
<li><a href='http://www.okadadesign.no/blog/codeigniter/kaimono-kago-v-1-1-1-beta-released/' rel='bookmark' title='Kaimono Kago v 1.1.1 Beta released'>Kaimono Kago v 1.1.1 Beta released</a></li>
<li><a href='http://www.okadadesign.no/blog/codeigniter/shopping-cart-v1-1-beta-updates/' rel='bookmark' title='Shopping Cart v1.1 Beta updates'>Shopping Cart v1.1 Beta updates</a></li>
<li><a href='http://www.okadadesign.no/blog/codeigniter/how-to-add-course-and-booking-module-to-kaimonokago-cms/' rel='bookmark' title='How to add Course and Booking module to Kaimonokago CMS'>How to add Course and Booking module to Kaimonokago CMS</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.okadadesign.no%2Fblog%2Fkaimono-kago%2Fkaimonokago-version-1-1-4-beta-released%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.okadadesign.no%2Fblog%2Fkaimono-kago%2Fkaimonokago-version-1-1-4-beta-released%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><img src="http://www.okadadesign.no/blog/wp-content/uploads/2011/04/icon_128.png" alt="" title="icon_128" width="128" height="128" class="alignleft size-full wp-image-2731" />The version 1.1.4 has multi-language module for the front-end shop. You can add any number of languages as you like. After adding languages in the languages module, you are able to input other languages to pages, products, menus and category. After adding languages in the backend, you need to add a directory and a file for the system languages. For example modules/welcome/language/french/kaimonokago_lang.php. </p>
<p>Another new features</p>
<ul>
<li>Slideshow module to control the front-end slideshow.</li>
<li>Common functions, such as change status, delete etc are moved to kaimonokago modules</li>
</ul>
<h4 class="download"><a href="https://github.com/shinokada/Kaimonokago">Download from github</a></h4>
<p>Related posts:<ol>
<li><a href='http://www.okadadesign.no/blog/codeigniter/kaimono-kago-v-1-1-1-beta-released/' rel='bookmark' title='Kaimono Kago v 1.1.1 Beta released'>Kaimono Kago v 1.1.1 Beta released</a></li>
<li><a href='http://www.okadadesign.no/blog/codeigniter/shopping-cart-v1-1-beta-updates/' rel='bookmark' title='Shopping Cart v1.1 Beta updates'>Shopping Cart v1.1 Beta updates</a></li>
<li><a href='http://www.okadadesign.no/blog/codeigniter/how-to-add-course-and-booking-module-to-kaimonokago-cms/' rel='bookmark' title='How to add Course and Booking module to Kaimonokago CMS'>How to add Course and Booking module to Kaimonokago CMS</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.okadadesign.no/blog/kaimono-kago/kaimonokago-version-1-1-4-beta-released/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Kaimono Kago update</title>
		<link>http://www.okadadesign.no/blog/codeigniter/kaimono-kago-update/</link>
		<comments>http://www.okadadesign.no/blog/codeigniter/kaimono-kago-update/#comments</comments>
		<pubDate>Wed, 19 May 2010 10:21:16 +0000</pubDate>
		<dc:creator>shinokada</dc:creator>
				<category><![CDATA[Codeigniter]]></category>
		<category><![CDATA[Kaimono Kago]]></category>
		<category><![CDATA[BackendPro]]></category>
		<category><![CDATA[shopping cart]]></category>

		<guid isPermaLink="false">http://www.okadadesign.no/blog/?p=1983</guid>
		<description><![CDATA[ <p></p> <p>Kaimono Kago is a shopping cart built on Codeigniter. I have minor updates and it is ready to download. Kaimono Kago v1.1.3 Beta.</p> &#160; <p>Related posts: Kaimono Kago: New name for our shopping cart Kaimono Kago: Installation added Kaimono Kago v 1.1.1 Beta released </p>
Related posts:<ol>
<li><a href='http://www.okadadesign.no/blog/codeigniter/kaimono-kago-new-name-for-our-shopping-cart/' rel='bookmark' title='Kaimono Kago: New name for our shopping cart'>Kaimono Kago: New name for our shopping cart</a></li>
<li><a href='http://www.okadadesign.no/blog/codeigniter/kaimono-kago-installation-added/' rel='bookmark' title='Kaimono Kago: Installation added'>Kaimono Kago: Installation added</a></li>
<li><a href='http://www.okadadesign.no/blog/codeigniter/kaimono-kago-v-1-1-1-beta-released/' rel='bookmark' title='Kaimono Kago v 1.1.1 Beta released'>Kaimono Kago v 1.1.1 Beta released</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.okadadesign.no%2Fblog%2Fcodeigniter%2Fkaimono-kago-update%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.okadadesign.no%2Fblog%2Fcodeigniter%2Fkaimono-kago-update%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><img src="http://www.okadadesign.no/blog/wp-content/uploads/2010/04/shopping_cart1.jpg" alt="" title="shopping_cart" width="200" height="200" class="alignleft size-full wp-image-1796" /></p>
<p>Kaimono Kago is a shopping cart built on Codeigniter.<br />
I have minor updates and it is ready to download.<br />
Kaimono Kago v1.1.3 Beta.</p>
<div class="clearboth">&nbsp;</div>
<p>Related posts:<ol>
<li><a href='http://www.okadadesign.no/blog/codeigniter/kaimono-kago-new-name-for-our-shopping-cart/' rel='bookmark' title='Kaimono Kago: New name for our shopping cart'>Kaimono Kago: New name for our shopping cart</a></li>
<li><a href='http://www.okadadesign.no/blog/codeigniter/kaimono-kago-installation-added/' rel='bookmark' title='Kaimono Kago: Installation added'>Kaimono Kago: Installation added</a></li>
<li><a href='http://www.okadadesign.no/blog/codeigniter/kaimono-kago-v-1-1-1-beta-released/' rel='bookmark' title='Kaimono Kago v 1.1.1 Beta released'>Kaimono Kago v 1.1.1 Beta released</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.okadadesign.no/blog/codeigniter/kaimono-kago-update/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Kaimono Kago v 1.1.1 Beta released</title>
		<link>http://www.okadadesign.no/blog/codeigniter/kaimono-kago-v-1-1-1-beta-released/</link>
		<comments>http://www.okadadesign.no/blog/codeigniter/kaimono-kago-v-1-1-1-beta-released/#comments</comments>
		<pubDate>Tue, 13 Apr 2010 19:07:22 +0000</pubDate>
		<dc:creator>shinokada</dc:creator>
				<category><![CDATA[Codeigniter]]></category>
		<category><![CDATA[Kaimono Kago]]></category>
		<category><![CDATA[BackendPro]]></category>
		<category><![CDATA[shopping cart]]></category>

		<guid isPermaLink="false">http://www.okadadesign.no/blog/?p=1843</guid>
		<description><![CDATA[ <p>Some updates and two more slideshows are added for the front page.</p> <p>Related posts: Kaimonokago version 1.1.4 Beta released Adding Slideshows Setting to Kaimono Kago Kaimono Kago update </p>
Related posts:<ol>
<li><a href='http://www.okadadesign.no/blog/kaimono-kago/kaimonokago-version-1-1-4-beta-released/' rel='bookmark' title='Kaimonokago version 1.1.4 Beta released'>Kaimonokago version 1.1.4 Beta released</a></li>
<li><a href='http://www.okadadesign.no/blog/codeigniter/adding-slideshows-setting-to-kaimono-kago/' rel='bookmark' title='Adding Slideshows Setting to Kaimono Kago'>Adding Slideshows Setting to Kaimono Kago</a></li>
<li><a href='http://www.okadadesign.no/blog/codeigniter/kaimono-kago-update/' rel='bookmark' title='Kaimono Kago update'>Kaimono Kago update</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.okadadesign.no%2Fblog%2Fcodeigniter%2Fkaimono-kago-v-1-1-1-beta-released%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.okadadesign.no%2Fblog%2Fcodeigniter%2Fkaimono-kago-v-1-1-1-beta-released%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Some updates and two more slideshows are added for the front page.</p>
<p>Related posts:<ol>
<li><a href='http://www.okadadesign.no/blog/kaimono-kago/kaimonokago-version-1-1-4-beta-released/' rel='bookmark' title='Kaimonokago version 1.1.4 Beta released'>Kaimonokago version 1.1.4 Beta released</a></li>
<li><a href='http://www.okadadesign.no/blog/codeigniter/adding-slideshows-setting-to-kaimono-kago/' rel='bookmark' title='Adding Slideshows Setting to Kaimono Kago'>Adding Slideshows Setting to Kaimono Kago</a></li>
<li><a href='http://www.okadadesign.no/blog/codeigniter/kaimono-kago-update/' rel='bookmark' title='Kaimono Kago update'>Kaimono Kago update</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.okadadesign.no/blog/codeigniter/kaimono-kago-v-1-1-1-beta-released/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Kaimono Kago: Installation added</title>
		<link>http://www.okadadesign.no/blog/codeigniter/kaimono-kago-installation-added/</link>
		<comments>http://www.okadadesign.no/blog/codeigniter/kaimono-kago-installation-added/#comments</comments>
		<pubDate>Wed, 07 Apr 2010 19:56:05 +0000</pubDate>
		<dc:creator>shinokada</dc:creator>
				<category><![CDATA[Codeigniter]]></category>
		<category><![CDATA[BackendPro]]></category>
		<category><![CDATA[shopping cart]]></category>

		<guid isPermaLink="false">http://www.okadadesign.no/blog/?p=1838</guid>
		<description><![CDATA[ Kaimono Kago v1.1c Beta <p>Installation is added.</p> How to install <p>1. Download the zip file and unzip it.</p> <p>2. Tranfer the unzipped files in your server.</p> <p>3. Visit http://www.yourwebsite.com/install. If it is in your local server, visit http://127.0.0.1/kaimonokago/install or http://localhost/kaimonokago/install.</p> <p>4. Fill up all necessary information. For your Encryption Key, visit http://www.ideaspace.net/misc/hash/ or [...]
Related posts:<ol>
<li><a href='http://www.okadadesign.no/blog/codeigniter/kaimono-kago-new-name-for-our-shopping-cart/' rel='bookmark' title='Kaimono Kago: New name for our shopping cart'>Kaimono Kago: New name for our shopping cart</a></li>
<li><a href='http://www.okadadesign.no/blog/codeigniter/kaimono-kago-update/' rel='bookmark' title='Kaimono Kago update'>Kaimono Kago update</a></li>
<li><a href='http://www.okadadesign.no/blog/codeigniter/kaimono-kago-v-1-1-1-beta-released/' rel='bookmark' title='Kaimono Kago v 1.1.1 Beta released'>Kaimono Kago v 1.1.1 Beta released</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.okadadesign.no%2Fblog%2Fcodeigniter%2Fkaimono-kago-installation-added%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.okadadesign.no%2Fblog%2Fcodeigniter%2Fkaimono-kago-installation-added%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<h3>Kaimono Kago v1.1c Beta</h3>
<p>Installation is added.</p>
<h3>How to install</h3>
<p>1. <a href="http://sourceforge.net/projects/kaimonokago/">Download the zip file</a> and unzip it.</p>
<p>2. Tranfer the unzipped files in your server.</p>
<p>3. Visit http://www.yourwebsite.com/install.<br />
If it is in your local server, visit http://127.0.0.1/kaimonokago/install or http://localhost/kaimonokago/install.</p>
<p>4. Fill up all necessary information. For your Encryption Key, visit http://www.ideaspace.net/misc/hash/<br />
or http://www.whatsmyip.org/hash_generator/ to generate at least 32 characters long code.</p>
<p>5. For your reCaptcha, visit http://recaptcha.net/ to get your keys.</p>
<p>6. After successful installation delete the installation folder.</p>
<p>7. Visit http://www.yourwebsite.com for index page.</p>
<p>8. Visit http://www.yourwebsite.com/index.php/auth to login the back-end.</p>
<p>Related posts:<ol>
<li><a href='http://www.okadadesign.no/blog/codeigniter/kaimono-kago-new-name-for-our-shopping-cart/' rel='bookmark' title='Kaimono Kago: New name for our shopping cart'>Kaimono Kago: New name for our shopping cart</a></li>
<li><a href='http://www.okadadesign.no/blog/codeigniter/kaimono-kago-update/' rel='bookmark' title='Kaimono Kago update'>Kaimono Kago update</a></li>
<li><a href='http://www.okadadesign.no/blog/codeigniter/kaimono-kago-v-1-1-1-beta-released/' rel='bookmark' title='Kaimono Kago v 1.1.1 Beta released'>Kaimono Kago v 1.1.1 Beta released</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.okadadesign.no/blog/codeigniter/kaimono-kago-installation-added/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Kaimono Kago: New name for our shopping cart</title>
		<link>http://www.okadadesign.no/blog/codeigniter/kaimono-kago-new-name-for-our-shopping-cart/</link>
		<comments>http://www.okadadesign.no/blog/codeigniter/kaimono-kago-new-name-for-our-shopping-cart/#comments</comments>
		<pubDate>Sun, 04 Apr 2010 15:18:20 +0000</pubDate>
		<dc:creator>shinokada</dc:creator>
				<category><![CDATA[Codeigniter]]></category>
		<category><![CDATA[BackendPro]]></category>
		<category><![CDATA[shopping cart]]></category>

		<guid isPermaLink="false">http://www.okadadesign.no/blog/?p=1779</guid>
		<description><![CDATA[ <p> We have more than 2000 downloads since we released Shopping Cart v1.0. This shopping cart is built on Codeigniter. We use BackendPro for the administration and Ajax file manager for file management. </p> <p>We thought it is a good idea to give a name to this shopping cart. The name is KAIMONO [...]
Related posts:<ol>
<li><a href='http://www.okadadesign.no/blog/codeigniter/kaimono-kago-update/' rel='bookmark' title='Kaimono Kago update'>Kaimono Kago update</a></li>
<li><a href='http://www.okadadesign.no/blog/codeigniter/kaimono-kago-installation-added/' rel='bookmark' title='Kaimono Kago: Installation added'>Kaimono Kago: Installation added</a></li>
<li><a href='http://www.okadadesign.no/blog/codeigniter/adding-slideshows-setting-to-kaimono-kago/' rel='bookmark' title='Adding Slideshows Setting to Kaimono Kago'>Adding Slideshows Setting to Kaimono Kago</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.okadadesign.no%2Fblog%2Fcodeigniter%2Fkaimono-kago-new-name-for-our-shopping-cart%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.okadadesign.no%2Fblog%2Fcodeigniter%2Fkaimono-kago-new-name-for-our-shopping-cart%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><img src="http://www.okadadesign.no/blog/wp-content/uploads/2010/04/shopping_cart.jpg" alt="" title="shopping_cart" width="200" height="200" class="alignleft size-full wp-image-1781" /><br />
We have more than 2000 downloads since we released Shopping Cart v1.0.<br />
This shopping cart is built on Codeigniter. We use BackendPro for the administration and Ajax file manager for file management. </p>
<p>We thought it is a good idea to give a name to this shopping cart.<br />
The name is KAIMONO KAGO which means &#8216;shopping basket&#8217; in Japanese.<br />
Well it is not a big difference in terms of meaning but at least you and we will know what we are talking about.</p>
<p>We also moved from Box.net to Sourceforge.net and you can download file from <a href="https://sourceforge.net/projects/kaimonokago/" target="_blank" >https://sourceforge.net/projects/kaimonokago/</a>.</p>
<p>We added a license document and a updates text in the download files and you can read it here as well.</p>
<div class="clearboth"></div>
<p><span id="more-1779"></span><br />
We appreciate any feed-backs or comment on Kaimono Kago. </p>
<p>The above icon is from a free icon set made by <a href="http://playground.ebiene.de/2316/free-ecommerce-icons/">playground.ebiene.de/</a></p>
<p>You can find great free shopping icons from the followings.</p>
<p><a href="http://bestdesignoptions.com/?p=1904">http://bestdesignoptions.com/?p=1904</a><br />
<a href="http://webdesignledger.com/freebies/the-best-e-commerce-icons-all-in-one-place">http://webdesignledger.com/freebies/the-best-e-commerce-icons-all-in-one-place</a></p>
<p>Related posts:<ol>
<li><a href='http://www.okadadesign.no/blog/codeigniter/kaimono-kago-update/' rel='bookmark' title='Kaimono Kago update'>Kaimono Kago update</a></li>
<li><a href='http://www.okadadesign.no/blog/codeigniter/kaimono-kago-installation-added/' rel='bookmark' title='Kaimono Kago: Installation added'>Kaimono Kago: Installation added</a></li>
<li><a href='http://www.okadadesign.no/blog/codeigniter/adding-slideshows-setting-to-kaimono-kago/' rel='bookmark' title='Adding Slideshows Setting to Kaimono Kago'>Adding Slideshows Setting to Kaimono Kago</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.okadadesign.no/blog/codeigniter/kaimono-kago-new-name-for-our-shopping-cart/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Shopping cart v1.1 Part 18: shopping cart</title>
		<link>http://www.okadadesign.no/blog/codeigniter/shopping-cart-v1-1-part-18-shopping-cart/</link>
		<comments>http://www.okadadesign.no/blog/codeigniter/shopping-cart-v1-1-part-18-shopping-cart/#comments</comments>
		<pubDate>Mon, 15 Mar 2010 13:53:37 +0000</pubDate>
		<dc:creator>shinokada</dc:creator>
				<category><![CDATA[Codeigniter]]></category>
		<category><![CDATA[BackendPro]]></category>
		<category><![CDATA[shopping cart]]></category>

		<guid isPermaLink="false">http://www.okadadesign.no/blog/?p=1641</guid>
		<description><![CDATA[ <p> Every &#8216;BUY&#8217; button under a product is linked to cart method with it&#8217;s id. This adds details of the product to our shopping cart.</p> <p> A link &#8216;SHOPPING CART&#8217; at the top right and this will take a customer to our shopping cart page. The link is pages/cart and redirected to cart [...]
Related posts:<ol>
<li><a href='http://www.okadadesign.no/blog/codeigniter/codeigniter-shopping-cart-v1-1-part-7-orders-module/' rel='bookmark' title='Codeigniter shopping cart v1.1 Part 7: orders module'>Codeigniter shopping cart v1.1 Part 7: orders module</a></li>
<li><a href='http://www.okadadesign.no/blog/codeigniter/codeigniter-shopping-cart-v1-1-part-12-product-page/' rel='bookmark' title='Shopping cart v1.1 Part 12: product page'>Shopping cart v1.1 Part 12: product page</a></li>
<li><a href='http://www.okadadesign.no/blog/codeigniter/codeigniter-shopping-cart-v1-1-part-16-registration-page-and-customer-log-in-page/' rel='bookmark' title='Shopping cart v1.1 Part 16: Registration page and customer log in page'>Shopping cart v1.1 Part 16: Registration page and customer log in page</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.okadadesign.no%2Fblog%2Fcodeigniter%2Fshopping-cart-v1-1-part-18-shopping-cart%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.okadadesign.no%2Fblog%2Fcodeigniter%2Fshopping-cart-v1-1-part-18-shopping-cart%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><img src="http://www.okadadesign.no/blog/wp-content/uploads/2010/02/cart200x200.jpg" alt="" title="cart200x200" width="200" height="200" class="alignleft size-full wp-image-1648" /><br />
Every &#8216;BUY&#8217; button under a product is linked to cart method with it&#8217;s id. This adds details of the product to our shopping cart.</p>
<div class="clearboth"></div>
<p><span id="more-1641"></span><br />
<img src="http://www.okadadesign.no/blog/wp-content/uploads/2010/02/cart.jpg" alt="" title="cart" width="540" height="468" class="alignleft size-full wp-image-1649" /><br />
A link &#8216;SHOPPING CART&#8217; at the top right and this will take a customer to our shopping cart page. The link is pages/cart and redirected to cart method.</p>
<p>If a customer has any products in the shopping cart, it displays the details as you see on the left image.<br />
We display names, number of orders, subtotal of each product and total price.</p>
<p>A shipping charge will be calculated and added under the order details.</p>
<p>On the left column, each product has a delete button. This will recalculate subtotal and total cost and returns the result.</p>
<p>A customer can change the number of order and by clicking &#8216;UPDATE&#8217; button, it will return the subtotal and total price. </p>
<p>&#8216;GO to Checkout&#8217; button will take a customer to a checkout page.</p>
<div class="clearboth"></div>
<p>As I mentioned it before, the following code creates each product with a link to cart.  </p>
<pre class="brush: php; title: ; notranslate">
echo '&lt;a href=&quot;' . site_url().&quot;/&quot;.lang('webshop_folder'). '/cart/'.$image['id']. '&quot;&gt;&lt;p class=&quot;addtocart&quot;&gt;'.lang('webshop_buy').'&lt;/p&gt;&lt;/a&gt;&lt;/div&gt;';
</pre>
<h3>Controllers: Calculating shipping price</h3>
<p>This code is geared for Norwegian shipping rules, so you need to change according to your shipping method.</p>
<pre class="brush: php; title: ; notranslate">
function shippingprice(){
		// You need to modify this. This is for Norwegian system. At the moment, if a max of individual product is more
		// than 268 kr, then shipping price will be 65 kr otherwise 0 kr or 25 kr.
		$maxprice = 0;
		if(isset($_SESSION['cart'])){
		foreach ($_SESSION['cart'] as $item) {
					    if ($item['price'] &gt; $maxprice) {
					        $maxprice = $item['price'];
					    }
					}
		$data['maxprice']=$maxprice;
		$shippingprice = 0;
		if ($maxprice &gt; 268 ){
			  $shippingprice = 65.0;
		}elseif($maxprice == 0){
			  $shippingprice = 0;
		}else{
			  $shippingprice = 25.0;
		}
		$_SESSION['shippingprice'] = $shippingprice;
		$data['shippingprice']=$shippingprice;
		return $data;
		}
  	}
</pre>
<h3>cart method</h3>
<pre class="brush: php; title: ; notranslate">
function cart($productid=0){
		$shippingprice = $this-&gt; shippingprice();
		$data['shippingprice']=$shippingprice['shippingprice'];
		if ($productid &gt; 0){
			$fullproduct = $this-&gt;MProducts-&gt;getProduct($productid);
			$this-&gt;MOrders-&gt;updateCart($productid,$fullproduct);
			redirect( lang('webshop_folder').'/product/'.$productid, 'refresh');
		}else{
			$data['title'] = lang('webshop_shop_name').&quot; | &quot;. &quot;Shopping Cart&quot;;

			if (isset($_SESSION['cart'])){
				$data['page'] = $this-&gt;config-&gt;item('backendpro_template_shop') . 'shoppingcart';
				$data['module'] = lang('webshop_folder');
				$this-&gt;load-&gt;view($this-&gt;_container,$data);
			}else{
				flashMsg('info',lang('orders_no_item_yet'));
				// $this-&gt;session-&gt;set_flashdata('msg',lang('orders_no_item_yet'));
				$data['page'] = $this-&gt;config-&gt;item('backendpro_template_shop') . 'shoppingcart';
				$data['module'] = lang('webshop_folder');
				$this-&gt;load-&gt;view($this-&gt;_container,$data);
			}
		}
  }

  	function ajax_cart(){
	  	// this is called by assets/js/shopcustomtools.js
	  	// this is used when a customer click a update button in /index.php/webshop/cart page
	   	$this-&gt;MOrders-&gt;updateCartAjax($this-&gt;input-&gt;post('ids'));
  	}

	function ajax_cart_remove(){
		// this is called by assets/js/shopcustomtools.js
	  	// this is used when a customer click a delete button in /index.php/webshop/cart page
	   	$this-&gt;MOrders-&gt;removeLineItem($this-&gt;input-&gt;post('id'));
	}
</pre>
<h3>view shoppingcart</h3>
<p>modules/webshop/views/shop/shoppingcart.php</p>
<pre class="brush: php; title: ; notranslate">
&lt;h1&gt;&lt;?php echo lang('general_shopping_cart'); ?&gt;&lt;/h1&gt;
&lt;div id='pleft'&gt;
&lt;?php
if ($this-&gt;session-&gt;flashdata('msg')){
	echo &quot;&lt;div class='status_box'&gt;&quot;;
	echo $this-&gt;session-&gt;flashdata('msg');
	echo &quot;&lt;/div&gt;&quot;;
}
?&gt;
&lt;?php echo form_open(lang('webshop_folder').'/checkout'); ?&gt;
&lt;table border='1' cellspacing='0' cellpadding='5' width='90%'&gt;
&lt;?php
if(isset($_SESSION['totalprice'])){
	$data['totalprice'] = $_SESSION['totalprice'];
	}

if (isset($_SESSION['cart'])){
	foreach ($_SESSION['cart'] as $PID =&gt; $row){
		$data = array(
				'name' =&gt; &quot;li_id[$PID]&quot;,
				'value'=&gt;$row['count'],
				'id' =&gt; &quot;li_id_$PID&quot;,
				'class' =&gt; 'process',
				'size' =&gt; 5
		);

		echo &quot;&lt;tr valign='top'&gt;\n&quot;;
		echo &quot;&lt;td&gt;&quot;. form_input($data).&quot;&lt;/td&gt;\n&quot;;
		echo &quot;&lt;td id='li_name_&quot;.$PID.&quot;'&gt;&quot;. $row['name'].&quot;&lt;/td&gt;\n&quot;;
		echo &quot;&lt;td id='li_price_&quot;.$PID.&quot;'&gt;&quot;.lang('webshop_currency_symbol'). $row['price'].&quot;&lt;/td&gt;\n&quot;;
		echo &quot;&lt;td id='li_total_&quot;.$PID.&quot;'&gt;&quot;.lang('webshop_currency_symbol').number_format($row['price'] * $row['count'], 2,'.',',').&quot;&lt;/td&gt;\n&quot;;
		echo &quot;&lt;td&gt;&lt;input type='button' name='delete' value='&quot;.lang('webshop_delete').&quot;' onclick='jsRemoveProduct($PID)'&gt;&lt;/td&gt;\n&quot;;
		echo &quot;&lt;/tr&gt;\n&quot;;
	}
	$TOTALPRICE = $_SESSION['totalprice'];
	$TOTALPRICE = number_format($TOTALPRICE,2,'.',',');
	$total_data = array('name' =&gt; 'total', 'id'=&gt;'total', 'value' =&gt; $TOTALPRICE);
	echo &quot;&lt;tr valign='top'&gt;\n&quot;;
	echo &quot;&lt;td colspan='3'&gt;&quot;.lang('orders_total_price').&quot;&lt;/td&gt;\n&quot;;
	echo &quot;&lt;td colspan='2'&gt;&quot;.lang('webshop_currency_symbol').&quot;$TOTALPRICE &quot;.form_hidden($total_data).&quot;&lt;/td&gt;\n&quot;;

	echo &quot;&lt;/tr&gt;\n&quot;;

	echo &quot;&lt;tr valign='top'&gt;\n&quot;;
	echo &quot;&lt;td colspan='3'&gt;&amp;nbsp;&lt;/td&gt;\n&quot;;
	echo &quot;&lt;td colspan='2'&gt;&lt;input type='button' name='update' value='&quot;.lang('webshop_update').&quot;' onclick='jsUpdateCart()'/&gt;&lt;/td&gt;\n&quot;;
	echo &quot;&lt;/tr&gt;\n&quot;;	

	echo &quot;&lt;tr valign='top'&gt;\n&quot;;
	echo &quot;&lt;td colspan='3'&gt;&amp;nbsp;&lt;/td&gt;\n&quot;;
	$data = array(
    'name'        =&gt; 'submit',
    'value'       =&gt; lang('webshop_checkout'),
    );
	echo &quot;&lt;td colspan='2'&gt;&quot;.form_submit($data).&quot;&lt;/td&gt;\n&quot;;
	echo &quot;&lt;/tr&gt;\n&quot;;
}else{
	//just in case!
	echo &quot;&lt;tr&gt;&lt;td id='tdmes'&gt;&quot; . lang('webshop_no_items_to_show') . &quot;&lt;/td&gt;&lt;/tr&gt;\n&quot;;
}//end outer if count
?&gt;
&lt;/table&gt;
&lt;?php echo form_close(); ?&gt;
&lt;br /&gt;
&lt;?php
	if($shippingprice&gt;0){
		echo &quot;&lt;div class='status_box'&gt;&lt;h2&gt;&quot;;
	echo lang('webshop_shipping_charge');
	if (isset($shippingprice)){
	echo &quot; &quot;. lang('webshop_currency_symbol').&quot;$shippingprice&quot;;
	}else{
		echo &quot;0 &quot;. lang('webshop_currency');
	}
	echo &quot; &quot; . lang('webshop_will_be_added');
	echo &quot;&lt;/h2&gt;&lt;/div&gt;&quot;;
	}
	?&gt;

&lt;div id='ajax_msg'&gt;&lt;/div&gt;
&lt;/div&gt;
</pre>
<p>Related posts:<ol>
<li><a href='http://www.okadadesign.no/blog/codeigniter/codeigniter-shopping-cart-v1-1-part-7-orders-module/' rel='bookmark' title='Codeigniter shopping cart v1.1 Part 7: orders module'>Codeigniter shopping cart v1.1 Part 7: orders module</a></li>
<li><a href='http://www.okadadesign.no/blog/codeigniter/codeigniter-shopping-cart-v1-1-part-12-product-page/' rel='bookmark' title='Shopping cart v1.1 Part 12: product page'>Shopping cart v1.1 Part 12: product page</a></li>
<li><a href='http://www.okadadesign.no/blog/codeigniter/codeigniter-shopping-cart-v1-1-part-16-registration-page-and-customer-log-in-page/' rel='bookmark' title='Shopping cart v1.1 Part 16: Registration page and customer log in page'>Shopping cart v1.1 Part 16: Registration page and customer log in page</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.okadadesign.no/blog/codeigniter/shopping-cart-v1-1-part-18-shopping-cart/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Shopping cart v1.1 Part 17: Newsletter</title>
		<link>http://www.okadadesign.no/blog/codeigniter/codeigniter-shopping-cart-v1-1-part-17-newsletter/</link>
		<comments>http://www.okadadesign.no/blog/codeigniter/codeigniter-shopping-cart-v1-1-part-17-newsletter/#comments</comments>
		<pubDate>Mon, 08 Mar 2010 11:07:24 +0000</pubDate>
		<dc:creator>shinokada</dc:creator>
				<category><![CDATA[Codeigniter]]></category>
		<category><![CDATA[BackendPro]]></category>
		<category><![CDATA[shopping cart]]></category>

		<guid isPermaLink="false">http://www.okadadesign.no/blog/?p=1572</guid>
		<description><![CDATA[ <p> Newsletter is one of effective marketing tool for a web shop. I am going to cover subscribe and unsubscribe function in this article.</p> <p></p> Download Page Modifying right.php <p> We need to add &#8216;subscribe to&#8217; and &#8216;unsubscribe from&#8217; our newsletter link in the right column.</p> <p>We add the following after login status [...]
Related posts:<ol>
<li><a href='http://www.okadadesign.no/blog/codeigniter/codeigniter-shopping-cart-v1-1-part-15-contact-page-and-sending-email-message/' rel='bookmark' title='Shopping cart v1.1 Part 15: contact page and sending email message'>Shopping cart v1.1 Part 15: contact page and sending email message</a></li>
<li><a href='http://www.okadadesign.no/blog/codeigniter/codeigniter-shopping-cart-v1-1-part-5-subscribers-module/' rel='bookmark' title='Codeigniter shopping cart v1.1 Part 5: subscribers module'>Codeigniter shopping cart v1.1 Part 5: subscribers module</a></li>
<li><a href='http://www.okadadesign.no/blog/codeigniter/codeigniter-shopping-cart-v1-1-part-16-registration-page-and-customer-log-in-page/' rel='bookmark' title='Shopping cart v1.1 Part 16: Registration page and customer log in page'>Shopping cart v1.1 Part 16: Registration page and customer log in page</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.okadadesign.no%2Fblog%2Fcodeigniter%2Fcodeigniter-shopping-cart-v1-1-part-17-newsletter%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.okadadesign.no%2Fblog%2Fcodeigniter%2Fcodeigniter-shopping-cart-v1-1-part-17-newsletter%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><img src="http://www.okadadesign.no/blog/wp-content/uploads/2010/03/subscribe200x200.jpg" alt="" title="subscribe200x200" width="200" height="200" class="alignleft size-full wp-image-1606" /><br />
Newsletter is one of effective marketing tool for a web shop. I am going to cover subscribe and unsubscribe function in this article.</p>
<div class="clearboth"></div>
<p><span id="more-1572"></span></p>
<h4 class="download"><a href="http://www.okadadesign.no/blog/?page_id=1061#ci11">Download Page</a></h4>
<h3>Modifying right.php</h3>
<p><img src="http://www.okadadesign.no/blog/wp-content/uploads/2010/03/newsletter.jpg" alt="" title="newsletter" width="188" height="92" class="alignleft size-full wp-image-1612" /><br />
We need to add &#8216;subscribe to&#8217; and &#8216;unsubscribe from&#8217; our newsletter link in the right column.</p>
<div class="clearboth"></div>
<p>We add the following after login status div.<br />
system/application/views/shop/right.php</p>
<pre class="brush: php; title: ; notranslate">
// add this after login status
&lt;div id=&quot;newsletter&quot; class=&quot;signtop paddingright&quot;&gt;
				&lt;b&gt;&lt;?php
					echo lang('subscribe_newsletter').&quot;&lt;br /&gt;\n&quot;;
					echo anchor(base_url().&quot;index.php/&quot;.lang('webshop_folder').&quot;/subscribe/&quot;, lang('subscribe_subscribe'));
					echo &quot;&lt;br /&gt;\n&quot;;
					echo anchor(base_url().&quot;index.php/&quot;.lang('webshop_folder').&quot;/unsubscribe/&quot;, lang('subscribe_unsubscribe'));

				?&gt;&lt;/b&gt;&lt;br /&gt;
			&lt;/div&gt;
</pre>
<h4>CSS</h4>
<pre class="brush: css; title: ; notranslate">

/* newsletter */

#newsletter{
	background-color:#E4E0EF;
	margin-top: 5px;
}
</pre>
<h4>Language</h4>
<p>Let&#8217;s add some texts to our language file.<br />
modules/webshop/language/english/webshop_lang.php</p>
<pre class="brush: php; title: ; notranslate">
// modules/webshop/controllers/subscribe function
$lang['subscribe_newsletter'] = 'Newsletter';
$lang['subscribe_subscribe'] = 'Subscribe';
$lang['subscribe_unsubscribe'] = 'Unsubscribe';
$lang['subscribe_name'] = 'Name';
$lang['subscribe_registed_before'] = 'Your email is already in our list.';
$lang['subscribe_thank_for_subscription'] = 'Thanks for subscribing our newsletter!';
$lang['subscribe_you_been_subscribed'] = 'You have been unsubscribed!';
$lang['subscribe_need_login'] = 'You need to login first';
$lang['subscribe_you_been_unsubscribed'] = 'You have been unsubscribed from Newsletter';
</pre>
<h3>subscribe method</h3>
<p>In our subscribe method, we are going to use recaptcha as you see the above image. We set a recaptcha as we did in <a href="http://www.okadadesign.no/blog/?p=1458">&#8216;Contact us&#8217;</a> and <a href="http://www.okadadesign.no/blog/?p=1559">&#8216;Registration&#8217;</a> pages.<br />
Setting rules and fields and validate. If validation is FALSE, then outputs errors.<br />
If validation is ok,  we use MSubscribers->checkSubscriber function to check if the email exists in our database. This model function returns TRUE or FALSE as you see below.<br />
If it is TRUE, the email exists in our database, so we set a message to tell you are registered and redirect.<br />
Otherwise we create a new subscriber with MSubscribers->createSubscriber function.<br />
We set a message and redirect.</p>
<p>modules/subscribers/models/msubscribers.php</p>
<pre class="brush: php; title: ; notranslate">
function checkSubscriber($email){
		$numrow = 0;
		$this-&gt;db-&gt;select('id');
		$this-&gt;db-&gt;where('email',db_clean($email));
		$this-&gt;db-&gt;limit(1);
		$Q = $this-&gt;db-&gt;get('omc_subscribers');
		if ($Q-&gt;num_rows() &gt; 0){
			$numrow = TRUE;
			return $numrow;
		}else{
			$numrow = FALSE;
			return $numrow;
		}
	}
</pre>
<p>modules/webshop/controllers/webshop.php</p>
<pre class="brush: php; title: ; notranslate">
function subscribe(){
		$data['title']=lang('webshop_shop_name').&quot; | &quot;.'Subscribe to our News letter';

		$captcha_result = '';
		$data['cap_img'] = $this-&gt;_generate_captcha();
		if ($this-&gt;input-&gt;post('name')){
			$rules['name'] = 'required';
			$rules['email'] = 'required|valid_email';
			$rules['recaptcha_response_field'] = 'trim|required|valid_captcha';

			$this-&gt;validation-&gt;set_rules($rules);

			$fields['email']	= lang('webshop_email');
			$fields['name']	= lang('subscribe_name');
			$fields['recaptcha_response_field']	= 'Recaptcha';

			$this-&gt;validation-&gt;set_fields($fields);

					if ($this-&gt;validation-&gt;run() == FALSE)
					{
						// if false outputs errors
						$this-&gt;validation-&gt;output_errors();
					}
					else
					{
						$email = $this-&gt;input-&gt;post('email');
						// otherwise check if the customer's email is in the database
						$numrow = $this-&gt;MSubscribers-&gt;checkSubscriber($email);
						if ($numrow == TRUE){
						// you have registered before, set the message and redirect to login page.
						flashMsg('info',lang('subscribe_registed_before'));
						redirect( lang('webshop_folder').'/subscribe','refresh');
						}
						$this-&gt;MSubscribers-&gt;createSubscriber();
						flashMsg('success',lang('subscribe_thank_for_subscription'));
						redirect( lang('webshop_folder').'/subscribe','refresh');
					}
		}
		$data['page'] = $this-&gt;config-&gt;item('backendpro_template_shop') . 'subscribe';
		$data['module'] = lang('webshop_folder');
		$this-&gt;load-&gt;view($this-&gt;_container,$data);
  	}
</pre>
<h3>view subscribe</h3>
<pre class="brush: php; title: ; notranslate">

&lt;?php print displayStatus();?&gt;
&lt;?php
if ($this-&gt;session-&gt;flashdata('subscribe_msg')){
	echo &quot;&lt;div class='status_box'&gt;&quot;;
	echo $this-&gt;session-&gt;flashdata('subscribe_msg');
	echo &quot;&lt;/div&gt;&quot;;
}
?&gt;

&lt;?php echo form_open($this-&gt;lang-&gt;line('webshop_folder').&quot;/subscribe&quot;); ?&gt;
&lt;h1&gt;
&lt;?php echo form_fieldset('Subscribe To Our Newsletter'); ?&gt;
&lt;/h1&gt;
&lt;h5&gt;*Name&lt;/h5&gt;
&lt;input type=&quot;text&quot; name=&quot;name&quot; id=&quot;name&quot; value=&quot;&lt;?php echo set_value('name'); ?&gt;&quot; size=&quot;40&quot; /&gt;

&lt;h5&gt;*Email&lt;/h5&gt;
&lt;input type=&quot;text&quot; name=&quot;email&quot; id=&quot;email&quot; value=&quot;&lt;?php echo set_value('email'); ?&gt;&quot; size=&quot;40&quot; /&gt;

&lt;h5&gt;*Are you human?&lt;/h5&gt;
&lt;?php echo &quot;&lt;p&gt;$cap_img&lt;/p&gt;&quot; ;?&gt;

&lt;div&gt;&lt;input type=&quot;submit&quot; value=&quot;Subscribe&quot; /&gt;&lt;/div&gt;
&lt;?php echo form_fieldset_close(); ?&gt;

&lt;?php echo form_close(); ?&gt;
</pre>
<h3>unsubscribe function</h3>
<p><img src="http://www.okadadesign.no/blog/wp-content/uploads/2010/03/unsubscribe.jpg" alt="" title="unsubscribe" width="342" height="279" class="alignleft size-full wp-image-1635" /><br />
Unsubscribe page has &#8216;Email&#8217; and Recapcha field to fill in.</p>
<p>If email field is not filled out, it must be the first visit to the page. Set a recapcha and other valiables.<br />
Otherwise a customer must have filled out email field, so set rules and fields.<br />
Run validation.<br />
If the validation is FALSE, outputs errors and redirect to the same page.<br />
If it is ok, remove the subscriber from out database and set a success message and redirect.</p>
<div class="clearboth"></div>
<pre class="brush: php; title: ; notranslate">
function unsubscribe($email=''){
  		if (!$this-&gt;input-&gt;post('email')){
  			$data['title']=lang('webshop_shop_name').&quot; | &quot;.'Unsubscribe our Newsletter';
  			$captcha_result = '';
			$data['cap_img'] = $this-&gt;_generate_captcha();
  			$data['page'] = $this-&gt;config-&gt;item('backendpro_template_shop') . 'unsubscribe';
			$data['module'] = lang('webshop_folder');
			$this-&gt;load-&gt;view($this-&gt;_container,$data);
  		}else{

  			$rules['email'] = 'trim|required|max_length[254]|valid_email';
			$rules['recaptcha_response_field'] = 'trim|required|valid_captcha';

			$this-&gt;validation-&gt;set_rules($rules);

			$fields['email']	= lang('webshop_email');
			$fields['recaptcha_response_field']	= 'Recaptcha';

			$this-&gt;validation-&gt;set_fields($fields);

			if ($this-&gt;validation-&gt;run() == FALSE)
					{
						// if false outputs errors
						$this-&gt;validation-&gt;output_errors();
						redirect( lang('webshop_folder').'/unsubscribe','refresh');
					}
					else
					{
						$email = $this-&gt;input-&gt;post('email');
						$this-&gt;MSubscribers-&gt;removeSubscriber($email);
						flashMsg('success',lang('subscribe_you_been_unsubscribed'));
						redirect( lang('webshop_folder').'/index','refresh');
					}
  		}
  	}
</pre>
<h3>view unsubscribe</h3>
<pre class="brush: php; title: ; notranslate">
&lt;?php print displayStatus();?&gt;
&lt;?php
if ($this-&gt;session-&gt;flashdata('subscribe_msg')){
	echo &quot;&lt;div class='status_box'&gt;&quot;;
	echo $this-&gt;session-&gt;flashdata('subscribe_msg');
	echo &quot;&lt;/div&gt;&quot;;
}
?&gt;

&lt;?php echo form_open($this-&gt;lang-&gt;line('webshop_folder').&quot;/unsubscribe&quot;); ?&gt;
&lt;h1&gt;
&lt;?php echo form_fieldset('Unsubscribe Our Newsletter'); ?&gt;
&lt;/h1&gt;

&lt;h5&gt;*Email&lt;/h5&gt;
&lt;input type=&quot;text&quot; name=&quot;email&quot; id=&quot;email&quot; value=&quot;&lt;?php echo set_value('email'); ?&gt;&quot; size=&quot;40&quot; /&gt;

&lt;h5&gt;*Are you human?&lt;/h5&gt;
&lt;?php echo &quot;&lt;p&gt;$cap_img&lt;/p&gt;&quot; ;?&gt;

&lt;div&gt;&lt;input type=&quot;submit&quot; value=&quot;Subscribe&quot; /&gt;&lt;/div&gt;
&lt;?php echo form_fieldset_close(); ?&gt;

&lt;?php echo form_close(); ?&gt;
</pre>
<p>Related posts:<ol>
<li><a href='http://www.okadadesign.no/blog/codeigniter/codeigniter-shopping-cart-v1-1-part-15-contact-page-and-sending-email-message/' rel='bookmark' title='Shopping cart v1.1 Part 15: contact page and sending email message'>Shopping cart v1.1 Part 15: contact page and sending email message</a></li>
<li><a href='http://www.okadadesign.no/blog/codeigniter/codeigniter-shopping-cart-v1-1-part-5-subscribers-module/' rel='bookmark' title='Codeigniter shopping cart v1.1 Part 5: subscribers module'>Codeigniter shopping cart v1.1 Part 5: subscribers module</a></li>
<li><a href='http://www.okadadesign.no/blog/codeigniter/codeigniter-shopping-cart-v1-1-part-16-registration-page-and-customer-log-in-page/' rel='bookmark' title='Shopping cart v1.1 Part 16: Registration page and customer log in page'>Shopping cart v1.1 Part 16: Registration page and customer log in page</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.okadadesign.no/blog/codeigniter/codeigniter-shopping-cart-v1-1-part-17-newsletter/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Shopping cart v1.1 minor updates</title>
		<link>http://www.okadadesign.no/blog/codeigniter/shopping-cart-v1-1-minor-updates/</link>
		<comments>http://www.okadadesign.no/blog/codeigniter/shopping-cart-v1-1-minor-updates/#comments</comments>
		<pubDate>Wed, 03 Mar 2010 11:08:14 +0000</pubDate>
		<dc:creator>shinokada</dc:creator>
				<category><![CDATA[Codeigniter]]></category>
		<category><![CDATA[BackendPro]]></category>
		<category><![CDATA[shopping cart]]></category>

		<guid isPermaLink="false">http://www.okadadesign.no/blog/?p=1525</guid>
		<description><![CDATA[ <p>jquery ketchup-plugin</p> Codeigniter Language Helper <p>http://codeigniter.com/user_guide/helpers/language_helper.html</p> <p>We can simplify </p> echo $this-&#62;lang-&#62;line(); <p> to</p> echo lang('language_key', 'form_item_id'); <p>Updating Preferences/Settings</p> <p>Adding all the webshop languages in the back-end so that it will be automatically used.</p> External link in menu $uri = $menu['page_uri']; $external_link = 'http'; $pos = strpos($uri, $external_link); // Note our use of [...]
Related posts:<ol>
<li><a href='http://www.okadadesign.no/blog/codeigniter/minor-updates-for-portofolio-cms-with-codeigniter/' rel='bookmark' title='Minor Updates for Portofolio CMS with Codeigniter'>Minor Updates for Portofolio CMS with Codeigniter</a></li>
<li><a href='http://www.okadadesign.no/blog/codeigniter/codeigniter-shopping-cart-v1-1-part-3/' rel='bookmark' title='Codeigniter shopping cart v1.1 Part 3: menus module'>Codeigniter shopping cart v1.1 Part 3: menus module</a></li>
<li><a href='http://www.okadadesign.no/blog/web-development/codeigniter-shopping-cart/' rel='bookmark' title='Codeigniter shopping cart v1.0 code updates'>Codeigniter shopping cart v1.0 code updates</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.okadadesign.no%2Fblog%2Fcodeigniter%2Fshopping-cart-v1-1-minor-updates%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.okadadesign.no%2Fblog%2Fcodeigniter%2Fshopping-cart-v1-1-minor-updates%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><a href="http://demos.usejquery.com/ketchup-plugin/">jquery ketchup-plugin</a></p>
<h3>Codeigniter Language Helper</h3>
<p>http://codeigniter.com/user_guide/helpers/language_helper.html</p>
<p>We can simplify </p>
<pre class="brush: php; title: ; notranslate">
echo $this-&gt;lang-&gt;line();
</pre>
<p> to</p>
<pre class="brush: php; title: ; notranslate">
echo lang('language_key', 'form_item_id');
</pre>
<p>Updating Preferences/Settings</p>
<p>Adding all the webshop languages in the back-end so that it will be automatically used.</p>
<h3>External link in menu</h3>
<pre class="brush: php; title: ; notranslate">
$uri = $menu['page_uri'];
			$external_link   = 'http';
			$pos = strpos($uri, $external_link);

			// Note our use of ===.  Simply == would not work as expected
			// because the position of 'a' was the 0th (first) character.
			if ($pos === false) {
			    echo anchor (&quot;welcome/pages/&quot;.$menu['page_uri'], $menu['name']);
			} else {
			    echo anchor ($menu['page_uri'], $menu['name']);
			}
</pre>
<p>Related posts:<ol>
<li><a href='http://www.okadadesign.no/blog/codeigniter/minor-updates-for-portofolio-cms-with-codeigniter/' rel='bookmark' title='Minor Updates for Portofolio CMS with Codeigniter'>Minor Updates for Portofolio CMS with Codeigniter</a></li>
<li><a href='http://www.okadadesign.no/blog/codeigniter/codeigniter-shopping-cart-v1-1-part-3/' rel='bookmark' title='Codeigniter shopping cart v1.1 Part 3: menus module'>Codeigniter shopping cart v1.1 Part 3: menus module</a></li>
<li><a href='http://www.okadadesign.no/blog/web-development/codeigniter-shopping-cart/' rel='bookmark' title='Codeigniter shopping cart v1.0 code updates'>Codeigniter shopping cart v1.0 code updates</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.okadadesign.no/blog/codeigniter/shopping-cart-v1-1-minor-updates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Shopping cart v1.1 Part 16: Registration page and customer log in page</title>
		<link>http://www.okadadesign.no/blog/codeigniter/codeigniter-shopping-cart-v1-1-part-16-registration-page-and-customer-log-in-page/</link>
		<comments>http://www.okadadesign.no/blog/codeigniter/codeigniter-shopping-cart-v1-1-part-16-registration-page-and-customer-log-in-page/#comments</comments>
		<pubDate>Tue, 02 Mar 2010 10:48:37 +0000</pubDate>
		<dc:creator>shinokada</dc:creator>
				<category><![CDATA[Codeigniter]]></category>
		<category><![CDATA[BackendPro]]></category>
		<category><![CDATA[shopping cart]]></category>

		<guid isPermaLink="false">http://www.okadadesign.no/blog/?p=1559</guid>
		<description><![CDATA[ <p> Our customers uses this registration page to keep their information in our database. Once registered, this information will be displayed in a checkout page for a speedy process. This post covers the customer registration function, login and logout function. </p> <p></p> Download Page <p> All the fields are required and rules are [...]
Related posts:<ol>
<li><a href='http://www.okadadesign.no/blog/codeigniter/codeigniter-shopping-cart-v1-1-part-15-contact-page-and-sending-email-message/' rel='bookmark' title='Shopping cart v1.1 Part 15: contact page and sending email message'>Shopping cart v1.1 Part 15: contact page and sending email message</a></li>
<li><a href='http://www.okadadesign.no/blog/codeigniter/codeigniter-shopping-cart-v1-1-part-17-newsletter/' rel='bookmark' title='Shopping cart v1.1 Part 17: Newsletter'>Shopping cart v1.1 Part 17: Newsletter</a></li>
<li><a href='http://www.okadadesign.no/blog/codeigniter/codeigniter-shopping-cart-v1-1-part-10-front-page/' rel='bookmark' title='Shopping cart v1.1 Part 10: Front page'>Shopping cart v1.1 Part 10: Front page</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.okadadesign.no%2Fblog%2Fcodeigniter%2Fcodeigniter-shopping-cart-v1-1-part-16-registration-page-and-customer-log-in-page%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.okadadesign.no%2Fblog%2Fcodeigniter%2Fcodeigniter-shopping-cart-v1-1-part-16-registration-page-and-customer-log-in-page%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><img src="http://www.okadadesign.no/blog/wp-content/uploads/2010/02/webshop_registration200x200.jpg" alt="" title="webshop_registration200x200" width="200" height="200" class="alignleft size-full wp-image-1560" /><br />
Our customers uses this registration page to keep their information in our database. Once registered, this information will be displayed in a checkout page for a speedy process. This post covers the customer registration function, login and logout function.  </p>
<div class="clearboth"></div>
<p><span id="more-1559"></span></p>
<h4 class="download"><a href="http://www.okadadesign.no/blog/?page_id=1061#ci11">Download Page</a></h4>
<p><img src="http://www.okadadesign.no/blog/wp-content/uploads/2010/02/webshop_registration_big.jpg" alt="" title="webshop_registration_big" width="397" height="802" class="alignleft size-full wp-image-1561" /><br />
All the fields are required and rules are set in function registration. </p>
<div class="clearboth"></div>
<h3>function registration</h3>
<p>This function sets the recaptcha as we did in <a href="http://www.okadadesign.no/blog/?p=1458">the previous post</a>, then sets rules and fields. If the validation is false outputs errors and load the same page.<br />
Otherwise check if the customer&#8217;s email is in our database by using MCustomers&#8217;s checkCustomer function. If it returns TRUE, then set a flash message and redirect to login page.<br />
If it returns FALSE, then add the customer to our database and set a success message and redirect to login page. </p>
<p>Be aware that due to $rules['city'] = &#8216;trim|required|alpha_dash&#8217;; a customer has to enter &#8216;NewYork&#8217;, &#8216;New-York&#8217; or &#8216;New_York&#8217; instead of &#8216;New York. If you don&#8217;t like this rule, you need to take out &#8216;alpha_dash&#8217;</p>
<pre class="brush: php; title: ; notranslate">
function registration(){
	/* If you are using recaptcha, don't forget to configure modules/recaptcha/config/recaptcha.php
	 * Add your own key
	 * */
		$captcha_result = '';
		$data['cap_img'] = $this-&gt;_generate_captcha();

	if ($this-&gt;input-&gt;post('email')){

	 	$data['title'] = lang('webshop_shop_name').&quot; | &quot;.&quot;Registration&quot;;

		// set rules
		$rules['email'] = 'trim|required|matches[emailconf]|valid_email';
		$rules['emailconf'] = 'trim|required|valid_email';
		$rules['password'] = 'trim|required';
		$rules['customer_first_name'] = 'trim|required|min_length[3]|max_length[20]';
		$rules['customer_last_name'] = 'trim|required|min_length[3]|max_length[20]';
		$rules['phone_number'] = 'trim|required|min_length[8]|max_length[12]|numeric';
		$rules['address'] = 'trim|required';
		$rules['city'] = 'trim|required|alpha';
		$rules['post_code'] = 'trim|required|numeric';
		// if you want to use recaptcha, set modules/recaptcha/config and uncomment the following
		$rules['recaptcha_response_field'] = 'trim|required|valid_captcha';

		$this-&gt;validation-&gt;set_rules($rules);

		// set fields. This will be used for error messages
		// for example instead of customer_first_name, First Name will be used in errors
		$fields['email']	= lang('webshop_email');
		$fields['emailconf']	= lang('webshop_email_confirm');
		$fields['password']	= lang('webshop_pass_word');
		$fields['customer_first_name']	= lang('webshop_first_name');
		$fields['customer_last_name']	= lang('webshop_last_name');
		$fields['phone_number']	= lang('webshop_mobile_tel');
		$fields['address']	= lang('webshop_shipping_address');
		$fields['city']	= lang('webshop_city');
		$fields['post_code']	= lang('webshop_post_code');
		$fields['recaptcha_response_field']	= 'Recaptcha';

		$this-&gt;validation-&gt;set_fields($fields);

		// run validation
		if ($this-&gt;validation-&gt;run() == FALSE)
			{
				// if false outputs errors
				$this-&gt;validation-&gt;output_errors();
				// and take them to registration page to show errors
				$data['page'] = $this-&gt;config-&gt;item('backendpro_template_shop') . 'registration';
				$data['module'] = lang('webshop_folder');
				$this-&gt;load-&gt;view($this-&gt;_container,$data);
			}
			else
			{
				$e = $this-&gt;input-&gt;post('email');
				// otherwise check if the customer's email is in the database
				$numrow = $this-&gt;MCustomers-&gt;checkCustomer($e);
				if ($numrow == TRUE){
					// you have registered before, set the message and redirect to login page.
					flashMsg('info', lang('webshop_registed_before'));
					// $this-&gt;session-&gt;set_flashdata('msg', lang('webshop_registed_before'));
					redirect( lang('webshop_folder').'/login','refresh');
				}
			// a customer is new, so create the new customer, set message and redirect to login page.
			$this-&gt;MCustomers-&gt;addCustomer();
			flashMsg('success', lang('webshop_thank_registration'));
			// $this-&gt;session-&gt;set_flashdata('msg', lang('webshop_thank_registration'));
			redirect( lang('webshop_folder').'/login');
			}
	}// end of if($this-&gt;input-&gt;post('email'))

	$data['title'] = lang('webshop_shop_name').&quot; | &quot;. &quot;Registration&quot;;
	$data['page'] = $this-&gt;config-&gt;item('backendpro_template_shop') . 'registration';
	$data['module'] = lang('webshop_folder');
	$this-&gt;load-&gt;view($this-&gt;_container,$data);

  }
</pre>
<h3>view registration</h3>
<p>module/webshop/views/shop/registration.php</p>
<pre class="brush: php; title: ; notranslate">
 	&lt;div class=&quot;gallerimain&quot;&gt;
    	&lt;h1&gt;&lt;?php echo $title; ?&gt;&lt;/h1&gt;&lt;br /&gt;
	&lt;?php print displayStatus();?&gt;
		&lt;h2&gt;&lt;?php echo $this-&gt;lang-&gt;line('webshop_regist_plz_here'); ?&gt;&lt;/h2&gt;&lt;br /&gt;
		&lt;h2&gt;&lt;?php echo sprintf( $this-&gt;lang-&gt;line('genral_login_msg'), anchor( $this-&gt;lang-&gt;line('webshop_folder').'/login', $this-&gt;lang-&gt;line('genral_login') ) );?&gt;&lt;/h2&gt;
		&lt;br /&gt;

		&lt;?php
		if ($this-&gt;session-&gt;flashdata('msg')|| $this-&gt;session-&gt;flashdata('error')){
			echo &quot;&lt;div class='status_box'&gt;&quot;;
			echo $this-&gt;session-&gt;flashdata('msg');
			echo $this-&gt;session-&gt;flashdata('error');
			echo &quot;&lt;/div&gt;&quot;;
		}
		?&gt;
		&lt;?php echo validation_errors('&lt;div class=&quot;message error&quot;&gt;','&lt;/div&gt;'); ?&gt;

		&lt;?php echo form_open($this-&gt;lang-&gt;line('webshop_folder').&quot;/registration&quot;,array('class' =&gt; 'expose')); ?&gt;

		&lt;h3&gt;*&lt;?php echo $this-&gt;lang-&gt;line('webshop_email'); ?&gt;&lt;/h3&gt;
		&lt;input type=&quot;text&quot; name=&quot;email&quot; value=&quot;&lt;?php echo set_value('email'); ?&gt;&quot; size=&quot;40&quot; /&gt;

		&lt;h3&gt;*&lt;?php echo $this-&gt;lang-&gt;line('webshop_email_confirm'); ?&gt;&lt;/h3&gt;
		&lt;input type=&quot;text&quot; name=&quot;emailconf&quot; value=&quot;&lt;?php echo set_value('emailconf'); ?&gt;&quot; size=&quot;40&quot; /&gt;

		&lt;h3&gt;*&lt;?php echo $this-&gt;lang-&gt;line('webshop_pass_word'); ?&gt;&lt;/h3&gt;
		&lt;input type=&quot;password&quot; name=&quot;password&quot; value=&quot;&quot; size=&quot;20&quot; /&gt;

		&lt;h3&gt;*&lt;?php echo $this-&gt;lang-&gt;line('webshop_first_name'); ?&gt;&lt;/h3&gt;
		&lt;input type=&quot;text&quot; name=&quot;customer_first_name&quot; value=&quot;&lt;?php echo set_value('customer_first_name'); ?&gt;&quot; size=&quot;30&quot; /&gt;

		&lt;h3&gt;*&lt;?php echo $this-&gt;lang-&gt;line('webshop_last_name'); ?&gt;&lt;/h3&gt;
		&lt;input type=&quot;text&quot; name=&quot;customer_last_name&quot; value=&quot;&lt;?php echo set_value('customer_last_name'); ?&gt;&quot; size=&quot;30&quot; /&gt;

		&lt;h3&gt;*&lt;?php echo $this-&gt;lang-&gt;line('webshop_mobile_tel'); ?&gt;&lt;/h3&gt;
		&lt;input type=&quot;text&quot; name=&quot;phone_number&quot; value=&quot;&lt;?php echo set_value('phone_number'); ?&gt;&quot; size=&quot;15&quot; /&gt;

		&lt;h3&gt;*&lt;?php echo $this-&gt;lang-&gt;line('webshop_shipping_address'); ?&gt;&lt;/h3&gt;
		&lt;input type=&quot;text&quot; name=&quot;address&quot; value=&quot;&lt;?php echo set_value('address'); ?&gt;&quot; size=&quot;50&quot; /&gt;

		&lt;h3&gt;*&lt;?php echo $this-&gt;lang-&gt;line('webshop_post_code'); ?&gt;&lt;/h3&gt;
		&lt;input type=&quot;text&quot; name=&quot;post_code&quot; value=&quot;&lt;?php echo set_value('post_code'); ?&gt;&quot; size=&quot;8&quot; /&gt;

		&lt;h3&gt;*&lt;?php echo $this-&gt;lang-&gt;line('webshop_city'); ?&gt;&lt;/h3&gt;
		&lt;input type=&quot;text&quot; name=&quot;city&quot; value=&quot;&lt;?php echo set_value('city'); ?&gt;&quot; size=&quot;20&quot; /&gt;

		&lt;h3&gt;*Are you human?&lt;/h3&gt;&lt;?php echo &quot;&lt;p&gt;$cap_img&lt;/p&gt;&quot; ;?&gt;

		&lt;br /&gt;
		&lt;input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;&lt;?php echo $this-&gt;lang-&gt;line('webshop_register'); ?&gt;&quot; /&gt;

		&lt;?php echo form_close(); ?&gt;

&lt;/div&gt;
</pre>
<h3>login function</h3>
<p><img src="http://www.okadadesign.no/blog/wp-content/uploads/2010/03/login.jpg" alt="" title="login" width="383" height="288" class="alignleft size-full wp-image-1598" /><br />
A cutomer will be redirected to a login page.<br />
If email is filled, verify the customer by using MCustomers->verifyCustomer function.<br />
This verifyCustomer function as you see below, check if the customer exist in our database. If data exists, set the PHP session, customer_id, first name, last name and other details which the customer entered in the registration page previously.</p>
<p>Then in the controller, it checks if the PHP session &#8216;customer_id&#8217; exists. If so, set a flash message and redirect and display it. If not, set an error message and redirect. </p>
<div class="clearboth"></div>
<p>modules/customers/models/mcustomers.php</p>
<pre class="brush: php; title: ; notranslate">
function verifyCustomer($e,$pw){
		$this-&gt;db-&gt;where('email',db_clean($e,50));
		$this-&gt;db-&gt;where('password', db_clean(dohash($pw),16));
		$this-&gt;db-&gt;limit(1);
		$Q = $this-&gt;db-&gt;get('omc_customer');
		if ($Q-&gt;num_rows() &gt; 0){
			$row = $Q-&gt;row_array();
			$_SESSION['customer_id'] = $row['customer_id'];
			$_SESSION['customer_first_name'] = $row['customer_first_name'];
			$_SESSION['customer_last_name'] = $row['customer_last_name'];
			$_SESSION['phone_number'] = $row['phone_number'];
			$_SESSION['email'] = $row['email'];
			$_SESSION['address'] = $row['address'];
			$_SESSION['city'] = $row['city'];
			$_SESSION['post_code'] = $row['post_code'];
		}else{
			// $_SESSION['customer_id'] = 0; // this will eliminate error
		}
	}
</pre>
<p>webshop/controllers/webshop.php</p>
<pre class="brush: php; title: ; notranslate">
function login(){
		if ($this-&gt;input-&gt;post('email')){
			$e = $this-&gt;input-&gt;post('email');
			$pw = $this-&gt;input-&gt;post('password');
			$this-&gt;MCustomers-&gt;verifyCustomer($e,$pw);
			if (isset($_SESSION['customer_id'])){
				flashMsg('info',lang('login_logged_in'));
				redirect( lang('webshop_folder').'/login','refresh');
			}
			flashMsg('info',lang('login_email_pw_incorrect'));
			redirect( lang('webshop_folder').'/login','refresh');
		}
		$data['title'] = lang('webshop_shop_name').&quot; | &quot;.&quot;Customer Login&quot;;
		$data['page'] = $this-&gt;config-&gt;item('backendpro_template_shop') . 'customerlogin';
		$data['module'] = lang('webshop_folder');
		$this-&gt;load-&gt;view($this-&gt;_container,$data);
  }
</pre>
<h3>cutomerlogin.php</h3>
<pre class="brush: php; title: ; notranslate">
   &lt;div class=&quot;gallerimain&quot;&gt;
      &lt;h1&gt;&lt;?php echo $title;?&gt;&lt;/h1&gt;
      &lt;br /&gt;
&lt;?php
	if($this-&gt;data['customer_status']==1){
		echo &quot;&lt;h2&gt;&quot;.lang('customer_login_enjoy_shopping').&quot;&lt;/h2&gt;&quot;;
		echo &quot;&lt;br /&gt;&lt;h2&gt;&quot;.anchor( lang('webshop_folder').'/checkout', lang('general_check_out') ).&quot;&lt;/h2&gt;&lt;br /&gt;&quot; ;

	}else{
		echo &quot;&lt;h2&gt;&quot;.lang('customer_login_plz_login').&quot;&lt;/h2&gt;&lt;br /&gt;&quot;;
	}
?&gt;

&lt;?php
	if ($this-&gt;session-&gt;flashdata('msg')){
		echo &quot;&lt;div class='status_box'&gt;&quot;;
		echo $this-&gt;session-&gt;flashdata('msg');
		echo &quot;&lt;/div&gt;&quot;;
	}
?&gt;

&lt;?php
	$udata = array('name'=&gt;'email','id'=&gt;'email','size'=&gt;30);
	$pdata = array('name'=&gt;'password','id'=&gt;'password','size'=&gt;16);

	echo form_open($this-&gt;lang-&gt;line('webshop_folder').&quot;/login&quot;);
	echo &quot;&lt;p&gt;&lt;label for='email'&gt;&quot;. lang('orders_email'). &quot;&lt;/label&gt;&lt;br/&gt;&quot;;
	echo form_input($udata) . &quot;&lt;/p&gt;&quot;;
	echo &quot;&lt;p&gt;&lt;label for='password'&gt;Password&lt;/label&gt;&lt;br/&gt;&quot;;
	echo form_password($pdata) . &quot;&lt;/p&gt;&quot;;
	echo form_submit('submit','login');
	echo form_close();
?&gt;
&lt;/div&gt;
</pre>
<p>We need to add lang(&#8216;customer_login_enjoy_shopping&#8217;) etc to modules/webshop/language/english/webshop_lang.php</p>
<pre class="brush: php; title: ; notranslate">
// modules/webshop/views/customerlogin.php
$lang['customer_login_enjoy_shopping'] = 'Enjoy your shopping!';
$lang['customer_login_plz_login'] = 'Please login. This will fill up your details at check out automatically.';

// you can add more here.
</pre>
<p>When a customer is logged in, a message is displayed and login status and &#8216;Log out&#8217; link are displayed on the top-right column. </p>
<p><img src="http://www.okadadesign.no/blog/wp-content/uploads/2010/03/loggedin.jpg" alt="" title="loggedin" width="692" height="208" class="alignleft size-full wp-image-1601" /></p>
<div class="clearboth"></div>
<p>If you see the Shop_controller.php, you will see the code which controlling this function.<br />
system/application/libraries/Shop_controller.php</p>
<pre class="brush: php; title: ; notranslate">
// This part is used in all the pages so load it here
		// For customer login status
		if(isset($_SESSION['customer_first_name'])){
			$this-&gt;data['customer_status']=1;
			$this-&gt;data['loginstatus']=lang('general_hello').$_SESSION['customer_first_name'].&quot;. &quot;.lang('general_logged_in').&quot;&lt;br /&gt;
			&lt;a href=\&quot;index.php/&quot;.$this-&gt;lang-&gt;line('webshop_folder').&quot;/logout \&quot;&gt;Log out&lt;/a&gt;&quot;;
		}else{
			$this-&gt;data['customer_status']=0;
			$this-&gt;data['loginstatus']=&quot;You are not logged in. &lt;a href=\&quot;index.php/&quot;.$this-&gt;lang-&gt;line('webshop_folder').&quot;/login \&quot;&gt;&quot;.lang('general_login').&quot;&lt;/a&gt;
			&lt;br /&gt;&lt;a href=\&quot;index.php/&quot;.$this-&gt;lang-&gt;line('webshop_folder').&quot;/registration \&quot;&gt;&quot;.lang('general_register').&quot;&lt;/a&gt;&quot;;
		}
</pre>
<h3>logout function</h3>
<pre class="brush: php; title: ; notranslate">
function logout(){
		// this would remove all the variable in the session
		session_unset();

		//destroy the session
		session_destroy(); 

		redirect( lang('webshop_folder').'/index','refresh');
	 }
</pre>
<p>When a customer is logged out, the customer will be redirected to the index page.</p>
<p>Related posts:<ol>
<li><a href='http://www.okadadesign.no/blog/codeigniter/codeigniter-shopping-cart-v1-1-part-15-contact-page-and-sending-email-message/' rel='bookmark' title='Shopping cart v1.1 Part 15: contact page and sending email message'>Shopping cart v1.1 Part 15: contact page and sending email message</a></li>
<li><a href='http://www.okadadesign.no/blog/codeigniter/codeigniter-shopping-cart-v1-1-part-17-newsletter/' rel='bookmark' title='Shopping cart v1.1 Part 17: Newsletter'>Shopping cart v1.1 Part 17: Newsletter</a></li>
<li><a href='http://www.okadadesign.no/blog/codeigniter/codeigniter-shopping-cart-v1-1-part-10-front-page/' rel='bookmark' title='Shopping cart v1.1 Part 10: Front page'>Shopping cart v1.1 Part 10: Front page</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.okadadesign.no/blog/codeigniter/codeigniter-shopping-cart-v1-1-part-16-registration-page-and-customer-log-in-page/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Shopping cart v1.1 Part 15: contact page and sending email message</title>
		<link>http://www.okadadesign.no/blog/codeigniter/codeigniter-shopping-cart-v1-1-part-15-contact-page-and-sending-email-message/</link>
		<comments>http://www.okadadesign.no/blog/codeigniter/codeigniter-shopping-cart-v1-1-part-15-contact-page-and-sending-email-message/#comments</comments>
		<pubDate>Fri, 26 Feb 2010 07:32:32 +0000</pubDate>
		<dc:creator>shinokada</dc:creator>
				<category><![CDATA[Codeigniter]]></category>
		<category><![CDATA[BackendPro]]></category>
		<category><![CDATA[shopping cart]]></category>

		<guid isPermaLink="false">http://www.okadadesign.no/blog/?p=1458</guid>
		<description><![CDATA[ <p>Contact page allows visitors to send a message through a form. It has a reCaptcha in order to avoid spam. I will cover the contact page and sending email message to an administrator in this article.</p> <p></p> Download Page <p>The contact page uses a recaptcha which is built in the BackendPro.</p> recaptcha.php <p>Please [...]
Related posts:<ol>
<li><a href='http://www.okadadesign.no/blog/codeigniter/codeigniter-shopping-cart-v1-1-part-16-registration-page-and-customer-log-in-page/' rel='bookmark' title='Shopping cart v1.1 Part 16: Registration page and customer log in page'>Shopping cart v1.1 Part 16: Registration page and customer log in page</a></li>
<li><a href='http://www.okadadesign.no/blog/web-development/sending-email-from-localhost-using-msmtp-with-gmail/' rel='bookmark' title='Sending email from localhost using MSMTP with gmail'>Sending email from localhost using MSMTP with gmail</a></li>
<li><a href='http://www.okadadesign.no/blog/codeigniter/codeigniter-shopping-cart-v1-1-part-17-newsletter/' rel='bookmark' title='Shopping cart v1.1 Part 17: Newsletter'>Shopping cart v1.1 Part 17: Newsletter</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.okadadesign.no%2Fblog%2Fcodeigniter%2Fcodeigniter-shopping-cart-v1-1-part-15-contact-page-and-sending-email-message%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.okadadesign.no%2Fblog%2Fcodeigniter%2Fcodeigniter-shopping-cart-v1-1-part-15-contact-page-and-sending-email-message%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><img src="http://www.okadadesign.no/blog/wp-content/uploads/2010/02/webshop_contact_200x200.jpg" alt="" title="webshop_contact_200x200" width="200" height="200" class="alignleft size-full wp-image-1465" />Contact page allows visitors to send a message through a form. It has a reCaptcha in order to avoid spam. I will cover the contact page and sending email message to an administrator in this article.</p>
<div class="clearboth"></div>
<p><span id="more-1458"></span></p>
<h4 class="download"><a href="http://www.okadadesign.no/blog/?page_id=1061#ci11">Download Page</a></h4>
<p><a href="http://www.okadadesign.no/blog/wp-content/uploads/2010/02/webshop_contact.jpg"><img src="http://www.okadadesign.no/blog/wp-content/uploads/2010/02/webshop_contact-300x237.jpg" alt="" title="webshop_contact" width="300" height="237" class="alignleft size-medium wp-image-1281" /></a>The contact page uses a recaptcha which is built in the BackendPro.</p>
<div class="clearboth"></div>
<h3>recaptcha.php</h3>
<p>Please open modules/recaptcha/config/recaptcha.php.<br />
This folder comes with the BackendPro.</p>
<pre class="brush: php; title: ; notranslate">
// other codes here

$config['recaptcha'] = array(
    'public'=&gt;'YOUR PUBLIC KEY HERE',
    'private'=&gt;'YOUR PRIVATE KEY HERE',
    'RECAPTCHA_API_SERVER' =&gt;'http://api.recaptcha.net',
    'RECAPTCHA_API_SECURE_SERVER'=&gt;'https://api-secure.recaptcha.net',
    'RECAPTCHA_VERIFY_SERVER' =&gt;'api-verify.recaptcha.net',
    'theme' =&gt; 'white'
); 

// and more here.
</pre>
<p>You need to register at <a href="http://recaptcha.net/">http://recaptcha.net/</a> and obtain public and private key. You can use these code for your local development as well.<br />
You need to replace &#8216;public&#8217;=>&#8217;YOUR PUBLIC KEY HERE&#8217; and &#8216;private&#8217;=>&#8217;YOUR PRIVATE KEY HERE&#8217; with your keys.</p>
<h3>Function contact</h3>
<p>We add the following in modules/webshop/controllers/webshop.php</p>
<pre class="brush: php; title: ; notranslate">
function contact(){

		$data['title'] = $this-&gt;lang-&gt;line('webshop_shop_name').&quot; | &quot;.&quot;Contact us&quot;;
		$data['cap_img'] = $this-&gt;_generate_captcha();
		$data['page'] = $this-&gt;config-&gt;item('backendpro_template_shop') . 'contact';
		$data['module'] = $this-&gt;lang-&gt;line('webshop_folder');
		$this-&gt;load-&gt;view($this-&gt;_container,$data);
  	}

	function _generate_captcha(){
		$this-&gt;bep_assets-&gt;load_asset('recaptcha');
		$this-&gt;load-&gt;module_library('recaptcha','Recaptcha');
		return $this-&gt;recaptcha-&gt;recaptcha_get_html();
	}
</pre>
<p>function contact is nothing special, except calling function _generate_captcha function.</p>
<p>function _generate_captcha load module library &#8216;recaptcha&#8217; which comes with BackendPro and generates captcha automatically. </p>
<p>We will use this function _generate_captcha in registration page as well.</p>
<h3>Contact view</h3>
<pre class="brush: php; title: ; notranslate">
&lt;div id=&quot;content&quot;&gt;
	&lt;div id=&quot;omossleft&quot;&gt;
		&lt;div id=&quot;logo&quot;&gt;
		&lt;/div&gt;
		&lt;div class=&quot;contentleft&quot;&gt;
	&lt;?php print displayStatus();?&gt;
			&lt;?php
			if ($this-&gt;session-&gt;flashdata('subscribe_msg')){
				echo &quot;&lt;div class='status_box'&gt;&quot;;
				echo $this-&gt;session-&gt;flashdata('subscribe_msg');
				echo &quot;&lt;/div&gt;&quot;;
			}
			?&gt;

			&lt;div id=&quot;contactform&quot;&gt;
				&lt;?php echo form_open( $this-&gt;lang-&gt;line('webshop_folder').&quot;/message&quot;); ?&gt;
				&lt;?php echo form_fieldset('&lt;h3&gt;Send Message&lt;/h3&gt;'); ?&gt;

				&lt;p id=&quot;name&quot;&gt;
					&lt;label for=&quot;name&quot;&gt;*&lt;?php echo $this-&gt;lang-&gt;line('orders_name'); ?&gt;: &lt;/label&gt;
					&lt;input type=&quot;text&quot; name=&quot;name&quot; id=&quot;name&quot; value=&quot;&lt;?php echo set_value('name'); ?&gt;&quot; maxlength=&quot;30&quot; size=&quot;30&quot;  /&gt;

				&lt;/p&gt;

				&lt;p id=&quot;email&quot;&gt;
					&lt;label for=&quot;email&quot;&gt;*&lt;?php echo $this-&gt;lang-&gt;line('orders_email'); ?&gt;: &lt;/label&gt;
					&lt;input type=&quot;text&quot; name=&quot;email&quot; id=&quot;email&quot; value=&quot;&lt;?php echo set_value('email'); ?&gt;&quot; maxlength=&quot;30&quot; size=&quot;30&quot;  /&gt;

				&lt;/p&gt;

				&lt;p&gt;
					&lt;label for=&quot;message&quot;&gt;*&lt;?php echo $this-&gt;lang-&gt;line('contact_your_message'); ?&gt;: &lt;/label&gt;&lt;br /&gt;
					&lt;?php
					  $data = array(
				      'name'  =&gt; 'message',
				      'id'    =&gt; 'message',
				      'rows'  =&gt; '10',
				      'cols'  =&gt; '3',
				      'style' =&gt; 'width:60%',
				    );	

				echo form_textarea($data);
				?&gt;
				&lt;/p&gt;
				&lt;p&gt;*&lt;?php echo $this-&gt;lang-&gt;line('contact_captcha'); ?&gt;&lt;/p&gt;&lt;br /&gt;
				&lt;?php echo &quot;&lt;p&gt;$cap_img&lt;/p&gt;&quot; ;?&gt;
				&lt;div id=&quot;contactsubmit&quot;&gt;&lt;input type=&quot;submit&quot; value=&quot;&lt;?php echo $this-&gt;lang-&gt;line('contact_send'); ?&gt;&quot; /&gt;
				&lt;/div&gt;
				&lt;?php echo form_fieldset_close(); ?&gt;
				&lt;?php echo form_close(); ?&gt;
			&lt;/div&gt;
		&lt;/div&gt;
	&lt;/div&gt;
&lt;/div&gt;
</pre>
<p>As you can see the form will be sent to the message function.</p>
<pre class="brush: php; title: ; notranslate">
form_open( $this-&gt;lang-&gt;line('webshop_folder').&quot;/message&quot;)
</pre>
<p>So obviously the next one is function message.</p>
<h3>Controller: function message</h3>
<p>As you can see in the comments, the BackendPro is using Codeigniter&#8217;s validation library instead of Form validation library. The <a href="http://codeigniter.com/user_guide/libraries/validation.html">validation library is deprecated</a> and the author mentioned that he is going to update to <a href="http://codeigniter.com/user_guide/libraries/form_validation.html">CI&#8217;s Form validation library</a> in the next version.</p>
<p>Load the validation library in the constructor, define rules for each field, set rules.<br />
Then define each field and set these fields.<br />
Run validation, if it is FALSE, outputs errors and display another recaptcha and load the page.<br />
If validation has passed, store all the input values in variables.<br />
Get the admin email from preference.<br />
Load <a href="http://codeigniter.com/user_guide/libraries/email.html">Codeigniter&#8217;s email library</a>, and set email preferences including setting up from, to, subject and message, and send the email to admin.<br />
Set flash message and redirect to the contact page again and display the thank you message.</p>
<p>&#8211;UPDATE March 1st 2010&#8211;<br />
This should work for your local server. However your host may have different email protocols. Please read <a href="http://codeigniter.com/user_guide/libraries/email.html">more details here</a>.</p>
<pre class="brush: php; title: ; notranslate">
class Webshop extends Shop_Controller {

  function  Webshop(){
    parent::Shop_Controller();
    // load the validation library
		$this-&gt;load-&gt;library('validation');

  }

// other functions here

function message(){

		$rules['name'] = 'trim|required|max_length[32]';
		$rules['email'] = 'trim|required|max_length[254]|valid_email';
		$rules['message'] = 'trim|required';
		$rules['recaptcha_response_field'] = 'trim|required|valid_captcha';

		$this-&gt;validation-&gt;set_rules($rules);

		$fields['name']	= lang('general_name');
		$fields['email']	= lang('webshop_email');
		$fields['message']	= lang('message_message');
		$fields['recaptcha_response_field']	= 'Recaptcha';

		$this-&gt;validation-&gt;set_fields($fields);
	    /**
		 * form_validation, next version of Bep will update to form_validation
		 */
		//$this-&gt;form_validation-&gt;set_rules('name', 'Name', 'required');
		//$this-&gt;form_validation-&gt;set_rules('email', 'Email',  'required|valid_email');
		//$this-&gt;form_validation-&gt;set_rules('message', 'Message', 'required');
		//$this-&gt;form_validation-&gt;set_rules('captcha', 'Captcha', 'required');

        if ($this-&gt;validation-&gt;run() == FALSE)
		{
			// if any validation errors, display them
			$this-&gt;validation-&gt;output_errors();

			$captcha_result = '';
			$data['cap_img'] = $this-&gt;_generate_captcha();

			$data['title'] = lang('webshop_shop_name').&quot; | &quot;. lang('webshop_message_contact_us');
			$data['page'] = $this-&gt;config-&gt;item('backendpro_template_shop') . 'contact';
			$data['module'] = lang('webshop_folder');
			$this-&gt;load-&gt;view($this-&gt;_container,$data);
		}
		else
		{
		    // you need to send email
		    // validation has passed. Now send the email
			$name = $this-&gt;input-&gt;post('name');
			$email = $this-&gt;input-&gt;post('email');
			$message = $this-&gt;input-&gt;post('message');
			$myemail = 'admin(at)gmail.com';
			$this-&gt;load-&gt;library('email');
			$this-&gt;email-&gt;from($email.$name);
			$this-&gt;email-&gt;to($myemail);
			$this-&gt;email-&gt;subject(lang('webshop_message_subject'));
			$this-&gt;email-&gt;message(lang('webshop_message_sender').
			$name.&quot;\r\n&quot;.lang('webshop_message_sender_email').&quot;: &quot;.
			$email. &quot;\r\n&quot;.lang('webshop_message_message').&quot;: &quot; . $message);
			$this-&gt;email-&gt;send();
			flashMsg('success', lang('webshop_message_thank_for_message'));
		    // $this-&gt;session-&gt;set_flashdata('subscribe_msg', lang('webshop_message_thank_for_message'));
		    redirect(lang('webshop_folder').'/contact');
		}
  	}  
</pre>
<h3>Setting up Webshop Configuration for admin_email</h3>
<p>I wrote about <a href="http://www.okadadesign.no/blog/?p=1355">how to add preferences in BackendPro yesterday</a>. The line, $myemail = &#8216;admin(at)gmail.com&#8217;; can be improved by using preferences instead of rewriting row php each time when you change email messages.</p>
<p>Add the following to system/application/controllers/admin/settings.php. (Please read <a href="http://www.okadadesign.no/blog/?p=1355">the article for details</a>)</p>
<pre class="brush: php; title: ; notranslate">
'webshop'=&gt; array('name'=&gt; $this-&gt;lang-&gt;line('preference_webshop_configuration'), 'fields'=&gt;'main_nav_parent_id,categories_parent_id,admin_email'),		

...

$config['field']['admin_email'] = array('rules'=&gt;'trim|valid_email');
</pre>
<p>Add the following to modules/preferences/language/english/preferences_lang.php.</p>
<pre class="brush: php; title: ; notranslate">
$lang['preference_label_admin_email'] = 'Admin Email to receive email messages';
$lang['preference_desc_admin_email'] = 'Enter admin email address to receive email messages from customers';
</pre>
<p>Go to DB, be_preferences field and insert a new field called &#8216;admin_email&#8217;.<br />
Go to the back-end, System > Settings > Webshop Configuration and add your email address. </p>
<p>Now we can use $this->preference->item(&#8216;admin_email&#8217;) instead of  &#8216;admin(at)gmail.com&#8217;.<br />
Change the line in the function message().</p>
<pre class="brush: php; title: ; notranslate">
$myemail = $this-&gt;preference-&gt;item('admin_email');
</pre>
<p>Please test it by not filling some fields or filling up all. If your local server is not sending email, <a href="http://www.okadadesign.no/blog/?p=140">this article</a> may help you if you are using XAMPP or similar development environment.</p>
<p>Related posts:<ol>
<li><a href='http://www.okadadesign.no/blog/codeigniter/codeigniter-shopping-cart-v1-1-part-16-registration-page-and-customer-log-in-page/' rel='bookmark' title='Shopping cart v1.1 Part 16: Registration page and customer log in page'>Shopping cart v1.1 Part 16: Registration page and customer log in page</a></li>
<li><a href='http://www.okadadesign.no/blog/web-development/sending-email-from-localhost-using-msmtp-with-gmail/' rel='bookmark' title='Sending email from localhost using MSMTP with gmail'>Sending email from localhost using MSMTP with gmail</a></li>
<li><a href='http://www.okadadesign.no/blog/codeigniter/codeigniter-shopping-cart-v1-1-part-17-newsletter/' rel='bookmark' title='Shopping cart v1.1 Part 17: Newsletter'>Shopping cart v1.1 Part 17: Newsletter</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.okadadesign.no/blog/codeigniter/codeigniter-shopping-cart-v1-1-part-15-contact-page-and-sending-email-message/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

