Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Global Library Methods : Basic opencart library functions along with their functionalities, Most of these can be called from anywhere in the catalog or admin folders (controllers, models, views)</p> <pre><code>CACHE $this-&gt;cache-&gt;delete($key) - Deletes cache [product, category, country, zone, language, currency, manufacturer] CART $this-&gt;cart-&gt;getProducts() Gets all products currently in the cart including options, discounted prices, etc. $this-&gt;cart-&gt;add( $product_id, $qty = 1, $options = array()) - Allows you to add a product to the cart $this-&gt;cart-&gt;remove( $key ) - Allows you to remove a product from the cart $this-&gt;cart-&gt;clear() - Allows you to remove all products from the cart $this-&gt;cart-&gt;getWeight() - Sum of the weight of all products in the cart that have require shipping set to Yes $this-&gt;cart-&gt;getSubTotal() - returns the subtotal of all products added together before tax $this-&gt;cart-&gt;getTotal() - returns the total of all products added together after tax $this-&gt;cart-&gt;countProducts() - returns the count of all product in the cart $this-&gt;cart-&gt;hasProducts() - returns true if there is at least one item in the cart $this-&gt;cart-&gt;hasStock() - returns false if there is at least one item in the cart that is out of stock $this-&gt;cart-&gt;hasShipping() - returns true if there is at least one item in the cart that requires shipping $this-&gt;cart-&gt;hasDownload() - returns true if there is at least one item in the cart that has a download associated CONFIG $this-&gt;config-&gt;get($key) - returns setting value by keyname based on application (catalog or admin) $this-&gt;config-&gt;set($key, $value) - set the value to override the setting value. DOES NOT SAVE TO DATABASE CURRENCY $this-&gt;currency-&gt;set($currency) - set or override the currency code to be used in the session $this-&gt;currency-&gt;format($number, $currency = '', $value = '', $format = TRUE) - format the currency $this-&gt;currency-&gt;convert($value, $from, $to) - convert a value from one currency to another. Currencies must exist $this-&gt;currency-&gt;getId() - get the database entry id for the current currency (1, 2, 3, 4) $this-&gt;currency-&gt;getCode() - get the 3-letter iso code for the current currency (USD, EUR, GBP, AUD, etc) $this-&gt;currency-&gt;getValue($currency) - get the current exchange rate from the database for the specified currency. $this-&gt;currency-&gt;has(currency) - Check if a currency exists in the opencart currency list CUSTOMER $this-&gt;customer-&gt;login($email, $password) - Log a customer in $this-&gt;customer-&gt;logout() - Log a customer out $this-&gt;customer-&gt;isLogged() - check if customer is logged in $this-&gt;customer-&gt;getId() - get the database entry id for the current customer (integer) $this-&gt;customer-&gt;getFirstName() - get customer first name $this-&gt;customer-&gt;getLastName() - get customer last name $this-&gt;customer-&gt;getEmail() - get customer email $this-&gt;customer-&gt;getTelephone() - get customer telephone number $this-&gt;customer-&gt;getFax() - get customer fax number $this-&gt;customer-&gt;getNewsletter() - get customer newsletter status $this-&gt;customer-&gt;getCustomerGroupId() - get customer group id $this-&gt;customer-&gt;getAddressId() - get customer default address id (maps to the address database field) DATABASE $this-&gt;db-&gt;query($sql) - Execute the specified sql statement. Returns row data and rowcount. $this-&gt;db-&gt;escape($value) - Escape/clean data before entering it into database $this-&gt;db-&gt;countAffected($sql) - Returns count of affected rows from most recent query execution $this-&gt;db-&gt;getLastId($sql) - Returns last auto-increment id from more recent query execution 4 DOCUMENT (*Called from controller only before renderer) $this-&gt;document-&gt;setTitle($title) - Set page title $this-&gt;document-&gt;getTitle()- Get page title $this-&gt;document-&gt;setDescription($description) - Set meta description $this-&gt;document-&gt;getDescription()- Get meta description $this-&gt;document-&gt;setKeywords()- Set meta keywords $this-&gt;document-&gt;getKeywords()- Get meta keywords $this-&gt;document-&gt;setBase($base) - Set page base $this-&gt;document-&gt;getBase() - Get page base $this-&gt;document-&gt;setCharset($charset) - Set page charset $this-&gt;document-&gt;getCharset() - Get page charset $this-&gt;document-&gt;setLanguage($language) - Set page language $this-&gt;document-&gt;getLanguage()- Get page language $this-&gt;document-&gt;setDirection($direction) - Set page direction (rtl/ltr) $this-&gt;document-&gt;getDirection()- Get page direction (rtl/ltr) $this-&gt;document-&gt;addLink( $href, $rel ) – Add dynamic &lt;link&gt; tag $this-&gt;document-&gt;getLinks()- Get page link tags $this-&gt;document-&gt;addStyle( $href, $rel = 'stylesheet', $media = 'screen' ) – Add dynamic style $this-&gt;document-&gt;getStyles()- Get page styles $this-&gt;document-&gt;addScript( $script ) - Add dynamic script $this-&gt;document-&gt;getScripts()- Get page scripts $this-&gt;document-&gt;addBreadcrumb($text, $href, $separator = ' &amp;gt; ') – Add breadcrumb $this-&gt;document-&gt;getBreadcrumbs()- Get Breadcrumbs ENCRYPT $this-&gt;encryption-&gt;encrypt($value) - Encrypt data based on key in admin settings $this-&gt;encryption-&gt;decrypt($value) - Decrypt data based on key in admin settings IMAGE $this-&gt;image-&gt;resize($width = 0, $height = 0) JSON $this-&gt;json-&gt;encode( $data ) $this-&gt;json-&gt;decode( $data , $assoc = FALSE) LANGUAGE $this-&gt;language-&gt;load($filename); LENGTH $this-&gt;length-&gt;convert($value, $from, $to) - convert a length to another. units must exist $this-&gt;length-&gt;format($value, $unit, $decimal_point = '.', $thousand_point = ',') - format the length to use unit LOG $this-&gt;log-&gt;write($message) - Writes to the system error log REQUEST $this-&gt;request-&gt;clean($data) - Cleans the data coming in to prevent XSS $this-&gt;request-&gt;get['x'] - Same as $_GET['x'] $this-&gt;request-&gt;post['x'] - Same as $_POST['x'] RESPONSE $this-&gt;response-&gt;addHeader($header) - additional php header tags can be defined here $this-&gt;response-&gt;redirect($url) - redirects to the url specified TAX $this-&gt;tax-&gt;setZone($country_id, $zone_id) - Set the country and zone id for taxing (integer) $this-&gt;tax-&gt;calculate($value, $tax_class_id, $calculate = TRUE) - Calculate all taxes to be added to the total $this-&gt;tax-&gt;getRate($tax_class_id) - Get the rates of a tax class id $this-&gt;tax-&gt;getDescription($tax_class_id) - Get the description of a tax class id $this-&gt;tax-&gt;has($tax_class_id) - Check if a tax class id exists in opencart SESSION $this-&gt;session-&gt;data['x'] - Same as $_SESSION['x'] </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload