Monday, April 18, 2011

Captcha in the Opencart




Captcha:
How to load the captcha:

In the controller we have to insert the code:
public function captcha() {
$this->load->library('captcha');
$captcha = new Captcha();
$this->session->data['captcha'] = $captcha->getCode();
$captcha->showImage();
}
In the template file:




Captcha contains only two function and they are below:
getCode():
This will generate the code that will be displayed in the image of the captcha.
function getCode(){
return $this->code;
}
And showImage():
This will generate the image with the code to show the captcha in the front end.

function showImage() {
$image = imagecreatetruecolor($this->height, $this->width);

$width = imagesx($image);
$height = imagesy($image);

$black = imagecolorallocate($image, 0, 0, 0);
$white = imagecolorallocate($image, 255, 255, 255);
$red = imagecolorallocatealpha($image, 255, 0, 0, 75);
$green = imagecolorallocatealpha($image, 0, 255, 0, 75);
$blue = imagecolorallocatealpha($image, 0, 0, 255, 75);

imagefilledrectangle($image, 0, 0, $width, $height, $white);

imagefilledellipse($image, ceil(rand(5, 145)), ceil(rand(0, 35)), 30, 30, $red);
imagefilledellipse($image, ceil(rand(5, 145)), ceil(rand(0, 35)), 30, 30, $green);
imagefilledellipse($image, ceil(rand(5, 145)), ceil(rand(0, 35)), 30, 30, $blue);

imagefilledrectangle($image, 0, 0, $width, 0, $black);
imagefilledrectangle($image, $width - 1, 0, $width - 1, $height - 1, $black);
imagefilledrectangle($image, 0, 0, 0, $height - 1, $black);
imagefilledrectangle($image, 0, $height - 1, $width, $height - 1, $black);

imagestring($image, 10, intval(($width - (strlen($this->code) * 9)) / 2), intval(($height - 15) / 2), $this->code, $black);

header('Content-type: image/jpeg');

imagejpeg($image);

imagedestroy($image);
}

captcha in the opencart, how to use captcha in the opencart, functions of captcha in the opencat, the easitest way to use captcha, functions for the captcha, how to change the image in the captcha, ways to learn captcha

Opencart Cache library function




Opencart Cache library function:
Calling of the cache function from the controller or view or model
$this->cache->get($key);
This is useful to get the caches that are enabled.
The get function in the library is defined as follows:
public function get($key) {
$files = glob(DIR_CACHE . 'cache.' . $key . '.*');
if ($files) {
foreach ($files as $file) {
$handle = fopen($file, 'r');
$cache = fread($handle, filesize($file));
fclose($handle);
return unserialize($cache);
}
}
}
$this->cache->set($key, $value):
This is useful to enable the cache.
The function set is defined as below:
public function set($key, $value) {
$this->delete($key);
$file = DIR_CACHE . 'cache.' . $key . '.' . (time() + $this->expire);
$handle = fopen($file, 'w');
fwrite($handle, serialize($value));
fclose($handle);
}

$this->cache->delete($key):
This is useful to delete the cache by which we can enable the next cache by setting.
The function delete defined as follows:
public function delete($key) {
$files = glob(DIR_CACHE . 'cache.' . $key . '.*');
if ($files) {
foreach ($files as $file) {
if (file_exists($file)) {
unlink($file);
clearstatcache();
}
}
}
}

opencart function collections, funtion collection of opencart, opencart by example, learn opencart by function and example

Sunday, April 17, 2011

Time to change the word that we speak






Friends it's time to change the words.
Let me give example:
If son wants to take a high costing training then
If father says "I can't afford it." Then it is statement which stop peple to think.
But if he says "How can I afford it?" Then it is question by which the son start to think or activate the mind.

Collection of library function in the opencart by Rupak Nepali




These are the library name that we can get in the opencart
cache, captcha, cart, config, currency, customer, db, document, encryption, image, json, language, length, log, mail, pagination, request, response, session, tax, template, user, weight
How we can use the library:
$this->cache->function_name_available();
List of function name in the respective category:
Cache:
    $this->cache->get($key);
    $this->cache->set($key, $value):
    $this->cache->delete($key):

Captcha:
Captcha contains only two function and they are below:
getCode():
showImage():

Cart:
Functions that are in the cart library of opencart are:
$this->cart->getProducts():
add($product_id, $qty = 1, $options = array()):
update($key, $qty):
remove($key):
clear():
getWeight():
setMinQty():
getSubTotal():
getTaxes():
getTotal():
countProducts():
hasProducts():
hasStock():
hasShipping():
hasDownload():

config:
config consists of 5 functions and they are as follows:
get($key):
set($key, $value):
has($key):
load($filename):

currency:
set($currency):
format($number, $currency = '', $value = '', $format = TRUE):
convert($value, $from, $to):
getId():
getCode():
getValue($currency):
has($currency):

customer:
login($email, $password):
logout():
isLogged():
getId():
getFirstName():
getLastName():
getEmail():
getTelephone():
getFax():
getNewsletter():
getCustomerGroupId():
getAddressId():

db:
query($sql):
escape($value):
countAffected():
getLastId():

document:
setTitle($title):
getTitle():
setDescription($description):
getDescription():
setKeywords($keywords):
getKeywords():
setBase($base):
getBase():
setCharset($charset):
getCharset():
setLanguage($language):
getLanguage():
setDirection($direction):
getDirection():
addLink($href, $rel):
getLinks():
addStyle($href, $rel = 'stylesheet', $media = 'screen'):
getStyles():
addScript($script):
getScripts():
addBreadcrumb($text, $href, $separator = ' > '):
getBreadcrumbs():

encryption:
encrypt($value):
base64_encode()
decrypt($value):

image:
create($image):
save($file, $quality = 100):
resize($width = 0, $height = 0):
watermark($file, $position = 'bottomright'):
crop($top_x, $top_y, $bottom_x, $bottom_y):
rotate($degree, $color = 'FFFFFF'):
filter($filter):
text($text, $x = 0, $y = 0, $size = 5, $color = '000000'):
merge($file, $x = 0, $y = 0, $opacity = 100):
html2rgb($color):

Json:
encode($data):
decode($json, $assoc = FALSE):

Language:

get($key):
load($filename):

Length:
convert($value, $from, $to):
format($value, $unit, $decimal_point = '.', $thousand_point = ','):


log:
write($message):

Mail:
setTo($to):
setFrom($from):
addheader($header, $value):
setSender($sender):
setSubject($subject):
setText($text):
setHtml($html):
addAttachment($file, $filename = ''):
send():

Pagination:
render():

Request:
clean($data):

Response:
addHeader($header):
redirect($url):
setOutput($output, $level = 0):
compress($data, $level = 0):
output():

Session:
$this->session:

Tax:
setZone($country_id, $zone_id):
calculate($value, $tax_class_id, $calculate = TRUE):
getRate($tax_class_id):
getDescription($tax_class_id):
has($tax_class_id):

Template:
fetch($filename):

User:
login($username, $password):
logout():
hasPermission($key, $value):
isLogged():
getId():
getUserName():

Weight:
convert($value, $from, $to):
format($value, $unit, $decimal_point = '.', $thousand_point = ','):

Need help on the opencart about the price changing in the cart




My price changes as per the customer login i am successful to change in the product display but what i now need is that how do i make changes in the cart and the confirm page.

I have added the "product_price_customer" table in the database and which contain the

CREATE TABLE IF NOT EXISTS `product_price_customer` (
`product_price_customer_id` int(11) NOT NULL AUTO_INCREMENT,
`product_id` int(11) NOT NULL,
`price` float NOT NULL,
`customer_id` int(11) NOT NULL,
PRIMARY KEY (`ppc_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;


Need Quick Help

Thanking You

www.dgcpack.com

http://rupaknpl.blogspot.com

Saturday, April 16, 2011

Rajnikanth funny videos from you tube











Rajnikanth funny video

Opencart Views






Opencart Views

A Opencart view is simply a web page, or a page fragment, like a header, footer, sidebar, etc. In fact, views can flexibly be embedded within other views (within other views, etc., etc.) if you need this type of hierarchy.
Opencart Views are never called directly; they must be loaded by an opencart controller. Remember that in an MVC framework, the Controller acts as the traffic cop, so it is responsible for fetching a particular view. If you have not read the Opencart Controller page you should do so before continuing.
Using the example controller we created in the opencart controller page, let's add a view to it.

Creating a View

Opencart View is located in the

catalog/view/theme/template_folder_name/template/subdirectory/file_name.tpl


The extension of the opencart view file is .tpl
Now on the file we write the html code.

Save the file as hello.tpl in the 

catalog/view/theme/template_folder_name/template/subdirectory/

Let me describe the view file the variable is defined in the controller and the $header is the path to the header file as





Loading a opencart view or Loading multiple views

 

$this->children = array(
                                'common/column_right',
                                'common/column_left',
                                'common/footer',
                                'common/header'
);
This will automatically load the header, column_right, column_left, footer and header.
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/category.tpl')) {
 $this->template = $this->config->get('config_template') . '/template/product/category.tpl';
} else {
$this->template = 'default/template/product/category.tpl';
}
These lines in the controller say that load the file if it does not exist        

What is a Controller in Opencart?






What is a Controller in Opencart?

A OpenCart Controller is simply a class file that is named in a way that can be associated with a URI.
Consider this URI:
rupaknepali.com/index.php?route=account/account
In the above example, Opencart would attempt to find a controller named account.php in account folder and load it. Your file will be included in the
catalog/controller/account/account.php
rupaknepali.com/ admin/index.php?route=sale/customer
Here the file loaded will be:
admin/controller/sale/customer.php
When a controller's name matches the first segment of a URI, it will be loaded.

Let's try it:  Hello World!

Let's create a simple controller so you can see it in action. Using your text editor, create a file called hello.php, and put the following code in it:
Then save the file to your catalog/controllers/account/ folder.
Now visit your site using a URL similar to this:
rupaknepali.com/index.php?route=account/hello
If you did it right, you should see Hello World!.
Note: Class names must start with an uppercase letter. In other words, this is valid:

class ControllerAccountHello extends Controller {

}
?>
This may not be valid:

class controllerAccountHelloextends Controller {
}
?>
Also, always make sure your controller extends the parent controller class so that it can inherit all its functions.

Functions

In the above example the function name is index(). The "index" function is always loaded by default if the second segment of the URI is empty. Another way to show your "Hello World" message would be this:
rupaknepali.com/index.php?route=account/hello/index
The second segment of the URI determines which function in the controller gets called.
Let's try it. Add a new function to your controller:
Now load the following URL to see the comment function:
rupaknepali.com/index.php?route=account/hello/comments
You should see your new message.

example in opencart, controller example in the opencart, learn opencart by example, how controllers work in opencart?,what is controller in opencart,opwncart

Model-View-Controller in Opencart






Model-View-Controller in Opencart
Opencart is based on the Model-View-Controller development pattern. MVC is a software approach that separates application logic from presentation. In practice, it permits your ecommerce site which will contain minimal scripting since the presentation is separate from the PHP scripting.
  • The Model represents your data structures. Typically your model classes will contain functions that help you retrieve, insert, and update information in your database.
  • The View is the information that is being presented to a user. A View will normally be a web page, but in Opencart, a view can also be a page fragment like a header or footer. It can also be an RSS page, or any other type of "page".
  • The Controller serves as an intermediary between the Model, the View, and any other resources needed to process the HTTP request and generate a web page.
Opencart has a fairly loose approach to MVC since Models are not required. If you don't need the added separation, or find that maintaining models requires more complexity than you want, you can ignore them and build your application minimally using Controllers and Views. Opencart also enables you to incorporate your own existing scripts not needed to follow the patterns but it will effects when you wanted to upgrade the Opencart  If we follow the patterns then it will be easy for us and the system.

Design and Architectural Goals with the reference of E-commerce

The goal of Opencart is to maximize the performance, capability, and flexibility in the smallest, lightest possible package.
To meet this goal programmers are committed to benchmarking, re-factoring, and simplifying at every step of the development process, rejecting anything that doesn't further the stated objective.
From a technical and architectural standpoint, Opencart was created with the following objectives:
  • Dynamic Instantiation. In Opencart, components are loaded and routines executed only when requested, rather than globally. No assumptions are made by the system regarding what may be needed beyond the minimal core resources, so the system is very light-weight by default. The events, as triggered by the HTTP request, and the controllers and views you design will determine what is invoked.
  • Loose Coupling. Coupling is the degree to which components of a system rely on each other. The less components depend on each other the more reusable and flexible the system becomes. Our goal was a very loosely coupled system.
  • Component Singularity. Singularity is the degree to which components have a narrowly focused purpose. In Opencart, each class and its functions are highly autonomous in order to allow maximum usefulness.
Opencart is a dynamically instantiated, loosely coupled system with high component singularity. It strives for simplicity, flexibility, and high performance in a small footprint package.

MVC description of the opencart, opencart design and architectural goals

Wednesday, April 13, 2011

Collection of opencart functions that are very useful for ecommerce development






$this->cart->remove($key):
Remove the cart value
$this->cart->update($key, $value):
Update the cart value
$customer_id=$this->customer->getId():
The $customer_id is the logged in Customer ID
$this->request->get[‘get_data’]:
This acts as the $_GET
$this->session->data[‘session_data’]:
This acts as the $_SESSION
$this->request->post[‘post_data’]:
This acts as the $_POST
$this->document->title:
This returns the document title.
$this->document->keywords:
This returns the keywords at the title of the page which is not shown in the document means acts as the meta keywords.
$this->document->description:
This acts as the meta description and will directly located in the head section of the pages.

$this->customer->isLogged():
Check whether the customer is logged in or not

collections of opencart reserved keywordk, opencart functions collections