Skip to content

Thinkshop helper functions

towonder edited this page Mar 17, 2011 · 1 revision

Product Functions

Get products in an order:

*Call: $this->getOrderProducts(order id, overview (optional));

This function gives you all the Product metadata and options in a particular order.
All you need for this function is an order id. The overview parameter is a simple boolean
which controls the amount of data you get returned.

If overview is true you'll get your order and all products returned without metadata, product
options and images.

Get all product metadata

*Call: $this->addMetatermsToProduct(product);

Returns all the metadata connected to a product for super easy access. It gives you the names of extrafields and choicelists, next to all the choices and fieldvalues.

Find all products in category

*Call: $this->Product->findInCategory(category id, order (optional));

Returns all products and it's connected models (like photo's, video's, metadata and children) within a specific category without having to set your Category model to recursivelevel 2.

Generate functions

Create code

*Call: $this->createCode(amount of characters);
Use this function to create new passwords and other securitystrings.

Create slug

*Call: $this->makeSlug(string);
Pass a string and get a valid slug returned. Easy as pie.


Validate functions

Valid E-mail

*Call: $this->isEmail(string);
Pass a string to check if it's a valid e-mailadres.

Get valid filetype

*Call: $this->getType(string)
Returns an image filetype. Browser and OS-independant.


Array functions

Order Array By

*Call: $this->orderBy(array, field, order (optional));

Simply order an array. Pass the order parameter like you would a MySql order; 'ASC' or 'DESC'

Pre-print

*Call: $this->pa(array);

Use this function to simply create a datadump of an array.