0% found this document useful (0 votes)
1K views1 page

OpenCart - Global Library Methods

The document describes global library methods in OpenCart 1.4.x that can be called from controllers, models and views to access common functions. It includes methods for caching, cart, config, currency, customer, database, document, encryption, image, JSON, language, length, log, request, response, tax and session.

Uploaded by

duzgun
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1K views1 page

OpenCart - Global Library Methods

The document describes global library methods in OpenCart 1.4.x that can be called from controllers, models and views to access common functions. It includes methods for caching, cart, config, currency, customer, database, document, encryption, image, JSON, language, length, log, request, response, tax and session.

Uploaded by

duzgun
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

OpenCart 1.4.

x - Global Library Methods Most of these can be called from anywhere in the catalog or admin folders (controllers, models, views). (Created by Qphoria)
CACHE $this->document->getDescription()- Get meta description
$this->cache->delete($key) - Deletes cache [product, category, country, zone, language, currency, $this->document->setKeywords()- Set meta keywords
manufacturer] $this->document->getKeywords()- Get meta keywords
$this->document->setBase($base) - Set page base
CART $this->document->getBase() - Get page base
$this->cart->getProducts() Gets all products currently in the cart including options, discounted prices, etc. $this->document->setCharset($charset) - Set page charset
$this->cart->add( $product_id, $qty = 1, $options = array()) - Allows you to add a product to the cart $this->document->getCharset() - Get page charset
$this->cart->remove( $key ) - Allows you to remove a product from the cart $this->document->setLanguage($language) - Set page language
$this->cart->clear() - Allows you to remove all products from the cart $this->document->getLanguage()- Get page language
$this->cart->getWeight() - Sum of the weight of all products in the cart that have require shipping set to Yes $this->document->setDirection($direction) - Set page direction (rtl/ltr)
$this->cart->getSubTotal() - returns the subtotal of all products added together before tax $this->document->getDirection()- Get page direction (rtl/ltr)
$this->cart->getTotal() - returns the total of all products added together after tax $this->document->addLink( $href, $rel ) – Add dynamic <link> tag
$this->cart->countProducts() - returns the count of all product in the cart $this->document->getLinks()- Get page link tags
$this->cart->hasProducts() - returns true if there is at least one item in the cart $this->document->addStyle( $href, $rel = 'stylesheet', $media = 'screen' ) – Add dynamic style
$this->cart->hasStock() - returns false if there is at least one item in the cart that is out of stock $this->document->getStyles()- Get page styles
$this->cart->hasProducts() - returns true if there is at least one item in the cart that requires shipping $this->document->addScript( $script ) - Add dynamic script
$this->cart->hasDownload() - returns true if there is at least one item in the cart that has a download $this->document->getScripts()- Get page scripts
associated $this->document->addBreadcrumb($text, $href, $separator = ' &gt; ') – Add breadcrumb
$this->document->getBreadcrumbs()- Get Breadcrumbs
CONFIG
$this->config->get($key) - returns setting value by keyname based on application (catalog or admin) ENCRYPT
$this->config->set($key, $value) - set the value to override the setting value. DOES NOT SAVE TO DATABASE $this->encryption->encrypt($value) - Encrypt data based on key in admin settings
$this->encryption->decrypt($value) - Decrypt data based on key in admin settings
CURRENCY
$this->currency->set($currency) - set or override the currency code to be used in the session IMAGE
$this->currency->format($number, $currency = '', $value = '', $format = TRUE) - format the currency $this->image->resize($width = 0, $height = 0)
$this->currency->convert($value, $from, $to) - convert a value from one currency to another. Currencies must
exist JSON
$this->currency->getId() - get the database entry id for the current currency (1, 2, 3, 4) $this->json->encode( $data )
$this->currency->getCode() - get the 3-letter iso code for the current currency (USD, EUR, GBP, AUD, etc) $this->json->decode( $data , $assoc = FALSE)
$this->currency->getValue($currency) - get the current exchange rate from the database for the specified
currency. LANGUAGE
$this->currency->has(currency) - Check if a currency exists in the opencart currency list $this->language->load($filename);

CUSTOMER LENGTH
$this->customer->login($email, $password) - Log a customer in $this->length->convert($value, $from, $to) - convert a length to another. units must exist
$this->customer->logout() - Log a customer out $this->length->format($value, $unit, $decimal_point = '.', $thousand_point = ',') - format the length to use
$this->customer->isLogged() - check if customer is logged in unit
$this->customer->getId() - get the database entry id for the current customer (integer)
LOG
$this->customer->getFirstName() - get customer first name
$this->log->write($message) - Writes to the system error log
$this->customer->getLastName() - get customer last name
$this->customer->getEmail() - get customer email REQUEST
$this->customer->getTelephone() - get customer telephone number $this->request->clean($data) - Cleans the data coming in to prevent XSS
$this->customer->getFax() - get customer fax number $this->request->get['x'] - Same as $_GET['x']
$this->customer->getNewsletter() - get customer newsletter status $this->request->post['x'] - Same as $_POST['x']
$this->customer->getCustomerGroupId() - get customer group id
$this->customer->getAddressId() - get customer default address id (maps to the address database field) RESPONSE
$this->response->addHeader($header) - additional php header tags can be defined here
DATABASE $this->response->redirect($url) - redirects to the url specified
$this->db->query($sql) - Execute the specified sql statement. Returns row data and rowcount.
$this->db->escape($value) - Escape/clean data before entering it into database TAX
$this->db->countAffected($sql) - Returns count of affected rows from most recent query execution $this->tax->setZone($country_id, $zone_id) - Set the country and zone id for taxing (integer)
$this->db->getLastId($sql) - Returns last auto-increment id from more recent query execution
4
$this->tax->calculate($value, $tax_class_id, $calculate = TRUE) - Calculate all taxes to be added to the total
$this->tax->getRate($tax_class_id) - Get the rates of a tax class id
DOCUMENT (*Called from controller only before renderer) $this->tax->getDescription($tax_class_id) - Get the description of a tax class id
$this->document->setTitle($title) - Set page title $this->tax->has($tax_class_id) - Check if a tax class id exists in opencart
$this->document->getTitle()- Get page title
$this->document->setDescription($description) - Set meta description SESSION
$this->session->data['x'] - Same as $_SESSION['x']

You might also like