A fusion of technology, music, and geekyness.

CakePHP eCommerce Done Right: Mocha Shopping Cart

Mocha Shopping Cart

Mocha Shopping Cart

A few months back I posted on CakePHP eCommerce and the lack of good solutions. Well that is now no longer the case. I would like to be one of the first people to introduce you to Mocha Shopping Cart. We have been working day and night (literally) to come up with a solution for the small and medium sized business owners to sell their products online easily. We also have geared Mocha to be extend-able and easy for CakePHP designers and developers to add in their own twists for clients.

Mocha is written entirely in CakePHP and jQuery and is certainly the best CakePHP eCommerce app out there. Why do I say that?

Mocha Shopping Cart is…

  • Fully hosted, secure, pre-installed
  • Very easy to set up and configure
  • Themable and Modular (Plug ins docs in the works)
  • Works with most popular payment and shipping apis (UPS, USPS, Authorize.net, Paypal, etc.)
  • Charges no transaction fees and no setup fees

If you still don’t believe me, Mocha is offering a limited time only Pre-Launch coupon code that gives you the first month FREE. You can try it for yourself and see how you like it. I think you will agree that it beats CakeCart and BakeSale, HANDS DOWN! And no, Mocha is not free (after the first 30 days). The costs help to speed up development, pay for server and hosting fees, and pay for that cup of coffee that us developers need when its 8 AM and we are having to talk with <insert_API_name_here> first thing in the morning.

Official Website: Mocha Shopping Cart
Blog with coupon code: Get a free trial of Mocha Shopping Cart


Easy JSON with CakePHP and jQuery

I am not sure if this is the fanciest way to get the job done but it works REALLY well. What job am I referring to? I am referring to outputting data as JSON in a CakePHP view and then parsing it in a jQuery AJAX response. Its fairly easy to accomplish with the JSON parser provided by json.org. Scroll to the bottom and download/include json2.js.

Controller example:

				$sizeArray = getimagesize('/path/to/really_cool_image.jpg');

				$outputArray = array(
					'file' => 'really_cool_image.jpg',
					'width' => $sizeArray[0],
					'height' => $sizeArray[1],
				);

				$this->set('result', $outputArray);

				$this->render(null, 'ajax');

AJAX View example:

Configure::write('debug', 0);
echo $javascript->object($result);

jQuery AJAX response handler example:

	  function(response, status) {
	  		imageDetails = JSON.parse(response);
	  		imageName = imageDetails.file;
	  }

CakePHP: Including Models inside your Controller

There are currently three methods for including and using models inside your controller. I am referring to the case when your controller does not belong to a model or or the model is not related to the model inside the controller you are working in. Although this case should be extremely rare, it seems to happen to me a lot. This post is basically a re-summary of Gwoo’s response in the CakePHP Google Groups discussion.

1. Controller::loadModel();
This method actually calls ClassRegistry::init() and saves the instance of the model as a parameter in the controller.

Example:

Controller::loadModel('Car');
$cars = $this->Car->find('all');

2. ClassRegistry::init()
This method creates an instance of the Model and returns it for use.

Example:

$car = ClassRegistry::init('Car');
$cars = $car->find('all');

3. App:import() (not recommended)
This method only includes the file. This requires you to create an instance each time.

Example:

App::import('Car');
$car = new Car();
$cars = $car->find('all');

As you can see this is really simple and basic stuff. However, I felt the need to re-post this information. If for nothing else, I will be using this as a reference point for myself :)

Update 5/27/09: Miles Johnson has a nice write up on this on his blog


CakePHP Character Encoding Checklist

I was having some issues today with character encoding and I thought I’d post about it. There are three elements that you need to make sure you have if you want to properly use UTF-8 character encoding in your Cake app. My issue was that I did not have #2, although adding #1 didn’t hurt either.

1. Database Config

Add ‘encoding’ => ‘utf8′ to app/config/database.php

	var $default = array(
		'driver' => 'mysql',
		'persistent' => false,
		'host' => 'localhost',
		'login' => 'user',
		'password' => 'password',
		'database' => 'database',
		'encoding' => 'utf8'
	);

2. Make sure your layout has the charset line in the

	<head>
	 	<?php echo $html->charset(); ?>
	 	Other elements...
	</head>

3. This one is set by default, but make sure App.encoding is set in app/config/core.php

/**
 * Application wide charset encoding
 */
	Configure::write('App.encoding', 'UTF-8');

And thats it!


Peep! A friendly GTD compliant productivity tool for you.


About a year ago Rick (http://www.rickguyer.com) had me read the book Getting Things Done by David Allen. In his book, Allen teaches you how to use his strategies and procedures on managing your tasks (or actions) in a very organized and well thought out fashion. His strategy is unique and calls for a very unique tool to accompany his GTD system. When I originally read his book, Rick and I spent several days searching for a different program, service, or web app that would allow us to incorporate Allen’s GTD system in an electronic fashion. After a solid week of effort I gave up after finding nothing that I felt was easy to use and completely GTD compliant.

Finally, after over a year, we decided to create this perfect GTD compliant web service that will help people, like us, be able to incorporate Allen’s system and become more productive. Peep! is “a simple and easy-to-use tool to help you focus and start getting things done.” I highly suggest you all try it and let me know what you think.

Head over to http://trypeep.com and get started today!


« Previous Entries

Powered by Wordpress | Designed by Elegant Themes