gomymobi: Knowledge Base

Usable store classes

Store built-in classes

- We already develop many built-in classes and pre-defined objects; you only need to use these objects to build your store themes.

- Depend on your context, some objects are not available to use, example: in listing page of products, you can not use object $Product to query details about product, or you can not use object $Shop_Order unless you are in order page.

- However, above examples are rare; basically, you may use all these global objects in any page in store. But be careful yourself.


You may use this declared object to use in any page of your store themes. This object contains all useful methods to work with store settings.

$shop array of store settings that fetched from both store table & site table or shop ID

Return: Object

Example: define a store object


Return an attribute (database table field) of store. Check out table of stores for fields you may get; with attributes of Paypal you may use: paypal_sandbox, paypal_email, paypal_prefix, paypal_pdt.

Return: String / Number

Example


Return a string of formatted timestamp with date format from store owner setting.

$time a timestamp

Return: String


Return favicon URL of store.

Return: String


Return an array of store payment settings.

Return: Array

Example


Return logo URL of store.

Return: String


Return URL of store.

Return: String

Example


Return a string of formatted price, based on store currency settings.

Return: String



You may use this declared object to use in any page of your store themes. This object contains the hierarchy structure of all categories from a store.

$categories array of all categories from a store that fetched from both category table. Or you may pass NULL or empty, this class shall get the current store autimatically.

Return: Object

Example: fetch all categories from table then define an object of store categories

Example: best simple solution

2 above solutions return object with data like below


Return an array of objects (active categories of store) in hierarchy structure.

Return: Array of Objects

Example: you may use this object to create a hierarchy menu bar



If this defined object $Shop_Current_Category is not NULL, indicate visitors are viewing some store category. And you may access all properties of this object directly, please check its properties (table fields).

$category array of all category properties (table fields) fetched from category table. Or you may use unique slug of category

Return: Object / NULL

Example: define an object for some category


Add some category object to current category object as hierarchy structure.

$category_object an object of some category you would like to add as children



This object contains all active pages of a store, you may use this object in anywhere in stores.

Return: Object / NULL


Return an object of store page by page ID.

$id ID value of page need to retrieve

Return: Object / NULL


Return array of store page objects.

Return: Array of Objects



This class allows you to declare an object for a page.

$page array of store page properties (table fields) fetched from page table. Or you may use ID (number) of page

Return: Object / NULL



This method returns the final price that buyers need to pay, after calculated with sale off or signup fee (for subscription products). This method is used in checkout page.

Return: Number


This method returns the final price that buyers need to pay, after calculated with signup fee. This method is used fpr subscription products only.

Return: Number


Return a string of product price. You may apply the filter get_price to format final result.

$short show short format of price

Return: String

Example: if product is single, echo one of results

Example: if product is a group

Example: if product is a subscription, echo something like below


Example: apply filter


Return an array that contains related product objects. These similiar products are calculated based on product name.

$number by default, fetch 8 related products only

Return: Array of Objects


Return an array of objects that contains children products. This method is used if product is a group. Result returns FALSE if product is not a group, returns NULL if there is no children or returns childrens.

Return: Array of Objects / NULL / FALSE


Return an attribute (table field) of product. Beside, this method also accepts some extra attributes for accessing easier.

$attr attribute would like to retrieve, extra attributes

featured_image feature image of product

tags all tags of product, return array of tags if exist

Return: Array / String


Detect if product is really something.

$type attribute would like to detect, acceptable values:

saleoff check if product is sale off (discount)
new return TRUE if product is new
instock return TRUE if product is still in stock
outstock return TRUE if product is out of stock
group detect if product is a group
subscription check if product is a subscription
single check if product is single
digital check if product is digital

Return: TRUE / FALSE



This class is used to list products, filtered by your rules and conditions.

$type main filter you need to apply; by default, this class returns new products; acceptable values:

featured select featured products only
discounted choose products have discount or sale off only
childs pick childrens of product, used with $condition is parent ID
cart pick products is in cart, used with $condition is an array of product IDs
relate pick related products, used with $condition is an array of ID and Name of current product
order_add_item search products to add into order, used in order management page with store owner permission

$condition additional conditions you would like to apply

$number limit how many products you would like to retrieve; by default, retrieve 10 products only

$parent if TRUE, select products that are not in any group

Return: Array of Objects / NULL

Example


This static method counts products with your rules and conditions.

$type main filter to count, you may check table fields for futher usage, acceptable defined values:

featured count all featured products
discounted count all discounted products

Return: TRUE / FALSE

Example


Return an object of product in current list.

$id ID value of product need to retrieve

Return: Object / NULL


Return an array of product object in current list.

Return: Array of Objects


Return an array of product IDs in current list.

Return: Array



Return an object of store order.

$order_properties array of all order properties (table fields) fetched from order table. Or you may use order ID value

Return: Object / NULL

Example


Detect if order is really something.

$type attribute would like to detect, acceptable values:

subscription check if order is a subscription
shipping check if order has tangible items need to ship
suspended return TRUE if order is suspended
downloadable return TRUE if order has downloadable files

Return: TRUE / FALSE


Return a string of formatted price, based on store currency settings. This method used to show total price of order in cart, checkout pages, order pages; and for displaying purpose only, not for calculating.

Use $Shop_Order->get('purchase_price') if want to get subscription price, or for calculating.

$short if TRUE, return short format

Return: String


Return an attribute (database table field) of order. Check out table of orders for fields you may get..

$attr attribute would like to retrieve; beside table fields, you may also use these defined attributes:

date retrieve created date of order, result is formatted by date format setting of store owner
date_completed retrieve completed date (paid date) of order, result is formatted by date format setting of store owner
items return list of products in order, used with second parameter $option
count return total of products
list return a string of products, include link to each product & purchase count
id return array of product IDs
default return array of products
files retrieve array of downloadable files in order or only return number of files if set second parameter $option = 'count'
buyer_name return full name of buyer
buyer_email return link to email of buyer or email only if set second parameter $option = 'raw'
buyer_phone return link to phone number of buyer or phone number only if set second parameter $option = 'raw'
ship_fullname return full name of shipping person
ship_fax return fax of shipped person
ship_company return company of shipped person
ship_email return link to email of shipped person or email only if set second parameter $option = 'raw'
ship_phone return link to phone number of shipped person or phone number only if set second parameter $option = 'raw'
ship_address return shipping address
payment_method return method name of chosen payment or slug of method if set second parameter $option = 'key'
payment_guide return paying guide of chosen method
paypal_link return link to Paypal for paying if order is unpaid and payment method is Paypal

$option additional option need to retrieve

Return: String



don't hesitate to contact us if your thing is outside of this section
by using contact button above or send directly to gomymobi@gmail.com with subject: [contactgmm]
if could not receive our reply within 24 hours, please resend ticket again