Open Cart Global Functions

Open Cart Global Functions

Affiliate

$this->affiliate->login($email, $password);

This function logs the user into their Affiliate account, not their customer account. Incorporate this to build custom login pages for affiliates.

$this->affiliate->logout();

This function logs the user out of their Affiliate account.

$this->affiliate->isLogged();

This function checks to see if the Affiliate is logged in. Returns true or false. Can be used to put a login restriction on important Affiliate pages such as payment details which require them to be logged in.

$this->affiliate->getId();

Returns the Affiliate ID number.

$this->affiliate->getFirstName();

Returns the first name of the Affiliate.

$this->affiliate->getLastName();

Returns the last name of the Affiliate.

$this->affiliate->getEmail();

Returns the email address of the Affiliate.

$this->affiliate->getTelephone();

Returns the phone number of the Affiliate.

$this->affiliate->getFax();

Returns the fax number of the Affiliate.

$this->affiliate->getCode();

Returns the registered tracking code of the Affiliate.

Cache

$this->cache->get($key);

Grabs the requested cache file for faster local loading.

$this->cache->set($key, $value);

Use this to create a cache file for search results, images or other site data for faster loading.

$this->cache->delete($key);

Delete a local cache file from it’s key.

Captcha

$this->captcha->getCode();

Returns the correct code to match against user input to approve or fail a Captcha challenge.

$this->captcha->showImage();

Displays the Captcha image to the user.

Cart

$this->cart->getProducts();

Returns an array of all the contents in user’s basket along with other info like quantity, name, weights etc.

$this->cart->add($product_id, $quantity = 1, $option = array());

Add an item to the user’s cart with the code. First argument is the product ID, then the quantity, then the third option is an array for adding product options like colours, size, shape etc.

$this->cart->update($key, $quantity);

Updates the quantity of the products in a customer’s basket.

$this->cart->remove($key);

Remove a product from the user’s basket based on it’s key value in the getProducts() array.

$this->cart->clear();

Delete everything in the user’s basket

$this->cart->getWeight();

Get the total combined weight of everything in the user’s basket.

$this->cart->getSubTotal();

Get the subtotal of all the products in the user’s basket. This does not take into account extra order totals like handling fees, low order fees, shipping costs etc

$this->cart->getTaxes();

Get the total Tax payable on the products in the basket.

$this->cart->getTotal();

Get’s the final total for everything in the user’s basket. Including handling fees, low order fees and shipping costs (if set) etc.

$this->cart->countProducts();

Counts the number of products in the customer’s basket. This takes into account the quantity of the product so if a basket as 1 of Product A and 2 of Product B then the countProducts() will return 3.

$this->cart->hasProducts();

Checks to see if the user’s basket has anything in it. Returns true or false.

$this->cart->hasStock();

Checks to see if there is stock available for products in the user’s basket.

$this->cart->hasShipping();

Checks to see if there is a product in the user’s basket which requires shipping.

$this->cart->hasDownload();

Checks to see if there is a product in the user’s basket which is a downloadable product.

Config

$this->config->get($key);

Get a config setting from the database based on it’s key.

$this->config->set($key, $value);

Create a new config setting with a new key and value, used mainly for installing modules.

$this->config->has($key);

Checks to see if the config table has a setting with a particular key.

$this->config->load($filename);

Load a file within OpenCart.

Currency

$this->currency->set($currency);

Quickly set the user’s currency by the currency code with this.

$this->currency->format($number, $currency = ”, $value = ”, $format = true);

Used for formatting prices to match the layout of the selected currency.

$this->currency->convert($value, $from, $to);

Used for working out the value of something in one currency to another.

$this->currency->getId($currency = ”);

Gets the ID of the currency, leave blank to gett he ID of the selected currency or enter a currency code to choose.

$this->currency->getSymbolLeft($currency = ”);

Gets the left symbol, if any, for displaying next to the price.

$this->currency->getSymbolRight($currency = ”);

Gets the right symbol, if any, for displaying next to the price.

$this->currency->getDecimalPlace($currency = ”);

Gets the symbol which represents a decimal place in the selected currency.

$this->currency->getCode();

Returns the ISO code of the currently selected currency.

$this->currency->getValue($currency = ”);

Returns the value of the selected currency. This is the value used to work out currency rates.

$this->currency->has($currency);

Checks to see that there are active currencies and one has been set. Customer

$this->customer->login($email, $password, $override = false);

Log the customer into their account quickly with their email and password. Can be used for quick logins and custom login pages.

$this->customer->logout();

Log the customer out of their account.

Sheraj: