addons/example/order_items/eWidget.php

Properties

Description

Optional file. System will parse the order_items/ directory, and use any valid order item files found. Your addon can create multiple order items.

Note that any file found in the order_items/ directory that starts with an underscore _ will be ignored by the system. This example order item is configured to work for a specific purpose (so there is a "working" example order item for you to "start" from), it does not document everything that order items can do. To see the full order item documentation, see the "template" order item found in the main software at: classes/order_items/_template.php See that file for further documentation.

Classes

eWidgetOrderItem

Properties

 
 
No 
No 

Description

This order item is designed to allow users on your site to purchase an eWidget.
This order item does everything you might think a widget order item might do: - set the cost in the admin, under price plan cost specifics, under the plan item settings - user can add widget to their cart by clicking on "add widget" button - button is displayed automatically in main cart view, and also in the "listing cart" "add item" section of the my account links module. - This item has a 2 page process for adding a widget to the cart. Since this is just an example, the pages don't do much, they just demonstrate how to set up different steps for adding an item to the cart. - Allows user to preview the widget. (all preview does is display an image, since this is an example) - All the built-in processes for order items will work, such as viewing pending widgets, the system auto-activating widget once it's paid for, if admin checks "needs admin approval" the widget does NOT auto activate, etc. Since this "Widget" addon is designed to work as specified above, it will not demonstrate or document everything order items can actually do. For that, look at the template order item found in the main software at: classes/order_items/_template.php Use the file above as a starting point for creating your own order item if you are creating one that differs drastically from what this widget does. You can create as many order items inside of an addon, by creating an order_items/ directory, and placing your order items in that directory. This example Widget order item demonstrates a "parent" order item, or an order item that has no "parents" of it's own, so it will be added directly to an order. A parent order item will not be attached to another order item. Other "parent" order items used in the main software: auction, classified, listing renew/upgrade, listing edit, subscription renewal A "child" order item is one that is attached to a parent order item. Parent order items don't have to have children, but children DO have to have a parent. Examples of "child" order items are: bolding extra, better placement extra, featured listing extra (levels 1-5), account tokens attached, and listing images. Note that the class name should match the file name. The syntax for the order item class name is: [File Name]OrderItem The class name does not include the ending ".php" of course. And it is case sensitive.

Methods

Admin_site_display_user_data, User_management_home_body, User_management_information_display_user_data, adminDetails, adminItemDisplay, adminPlanItemConfigDisplay, adminPlanItemConfigUpdate, almostFinishedCheckVars, almostFinishedDisplay, almostFinishedLabel, almostFinishedProcess, displayInAdmin, geoCart_cartDisplay_newButton, geoCart_initItem_forceOutsideCart, geoCart_initItem_new, geoCart_initItem_restore, geoCart_initSteps, geoCart_initSteps_addOtherDetails, geoCart_previewDisplay, getActionName, getCostDetails, getDisplayDetails, getParentTypes, getTypeTitle, my_account_links_newButton, processStatusChange, youAreCoolCheckVars, youAreCoolDisplay, youAreCoolLabel, youAreCoolProcess,

Admin_site_display_user_data( int   $user_id, ) : string

Description

Lets display the number of widgets a user owns. But since this is an example, we didn't bother to keep track of that (if we did, we might have added a new column to the userdata table during the addon's installation, to keep track of the number)
See {@link _templateOrderItem::Admin_site_display_user_data()} for full documentation.

Arguments

Name Type Description Default
$user_id int

Return value

Type Description
string Text to add to page.

User_management_home_body( ) : n/a

Description

Optional Used: in User_management_home::menu()
Use this to add a link to the My Account Links module (or old user management home page)

Return value

Type Description
n/a n/a

User_management_information_display_user_data( ) : array

Description

Displays info on the account info page.
See {@link _templateOrderItem::User_management_information_display_user_data()} for full documentation.

Return value

Type Description
array Associative array, with the structure array ('label' => 'Left side','value' => 'Right side')

adminDetails( ) : array

Description

This displays brief details of a widget when the widget is in a long list of stuff. Sometimes a short list. Could even be the only thing in the list, who knows. It will be used to display the item in the admin at Orders > Manage Items (plus a few other places in the admin)
See {@link _templateOrderItem::adminDetails()} for full documentation.

Return value

Type Description
array Associative array, in the form array ('type' => string, 'title' => string)

adminItemDisplay( int   $item_id, ) : string

Description

This will display info when viewing an item's details. This is when the admin clicks on an item in the admin at "Orders > Manage Items"
See {@link _templateOrderItem::adminItemDisplay()} for full documentation.

Arguments

Name Type Description Default
$item_id int

Return value

Type Description
string What is going to be displayed

adminPlanItemConfigDisplay( \geoPlanItem   $planItem, ) : string

Description

This will display the "plan item" settings when the admin clicks the configure link next to this addon.
See {@link _templateOrderItem::adminPlanItemConfigDisplay()} for full documentation.

Arguments

Name Type Description Default
$planItem \geoPlanItem

The geoPlanItem object that holds the settings for this item and price plan

Return value

Type Description
string

adminPlanItemConfigUpdate( \geoPlanItem   $planItem, ) : bool

Description

This saves the plan item settings.
See {@link _templateOrderItem::adminPlanItemConfigUpdate()} for full documentation.

Arguments

Name Type Description Default
$planItem \geoPlanItem

The geoPlanItem object that holds the settings for this item and price plan

Return value

Type Description
bool If return true, message "settings saved" will be displayed, if return false, message "settings not saved" will be displayed.

almostFinishedCheckVars( ) : n/a

Description

This checks all the input variables submitted as part of the almostFinished step. If there are any problems, this method will raid an error with the cart and the cart will know not to go on.

Return value

Type Description
n/a n/a

almostFinishedDisplay( ) : n/a

Description

Since we added a "almostFinished" step, we need to have 3 methods that handle that step: a display, a check vars, and a process. This one is the display.

Return value

Type Description
n/a n/a

almostFinishedLabel( ) : string

Description

What is displayed for the almostFinished label

Return value

Type Description
string

almostFinishedProcess( ) : n/a

Description

This only happens if there are no errors raised when we checked the vars before. This method should save any values that need to be saved for the almostFinished step.
This step can raise an error with the cart to make the cart not proceed to the next step. Just because you can, doesn't mean you should though. It is considered bad practice to raise an error in this step, except for special cases where raising an error in checkvars is not possible. If at all possible, you should detect any problems in the check vars stage and raised an error then.

Return value

Type Description
n/a n/a

displayInAdmin( ) : bool

Description

Required by order item system.
See {@link _templateOrderItem::displayInAdmin()} for full documentation.

Return value

Type Description
bool

geoCart_cartDisplay_newButton( ) : n/a

Description

Used to display the "add new button" down there under the "add to cart" box.
See {@link _templateOrderItem::geoCart_cartDisplay_newButton()} for full documentation.

Return value

Type Description
n/a n/a

geoCart_initItem_forceOutsideCart( ) : bool

Description

This guy is required by the system. Like most order items, we'll just be returning false here.
See {@link _templateOrderItem::geoCart_initItem_forceOutsideCart()} for full documentation.

Return value

Type Description
bool True to force creating "parellel" cart just for this item, false otherwise.

geoCart_initItem_new( ) : bool

Description

When first creating this item, go ahead and set the cost to that as set in the admin for the price plan used.
See {@link _templateOrderItem::geoCart_initItem_new()} for full documentation.

Return value

Type Description
bool We'll return true to allow new

geoCart_initItem_restore( ) : bool

Description

Just in case admin has changed price of eWidgets since this order item was created, we'll use this to re-save the price.
See {@link _templateOrderItem::geoCart_initItem_restore()} for full documentation.

Return value

Type Description
bool We'll return true to allow restoring.

geoCart_initSteps(   $allPossible = false, ) : n/a

Description

This is where we define what steps there are for adding an eWidget.
See {@link _templateOrderItem::geoCart_initSteps()} for full documentation.

Arguments

Name Type Description Default
$allPossible n/a false

Return value

Type Description
n/a n/a

geoCart_initSteps_addOtherDetails( ) : bool

Description

Required by system, to tell if this item uses the other details step.
See {@link _templateOrderItem::geoCart_initSteps_addOtherDetails()} for full documentation.

Return value

Type Description
bool we'll say false.

geoCart_previewDisplay( ) : n/a

Description

Used to display a preview of our lovely eWidget
See {@link _templateOrderItem::geoCart_previewDisplay()} for full documentation.

Return value

Type Description
n/a n/a

getActionName( array   $vars, ) : string

Description

Optional.
Used: in geoCart and my_account_links module This is used to display what the action is if this order item is the main type. It should return something like "adding new listing" or "editing images".

Arguments

Name Type Description Default
$vars array

Array with the action and step to get the action name for.

Return value

Type Description
string

getCostDetails( ) : array|bool

Description

Required.
Used: By payment gateways to see what types of items are in the cart. This is very similar to {@see _templateOrderItem::getDisplayDetails()} except that the information is used by payment gateways and is specifically for information about what the "cost" of something is for. Should return an associative array, that follows: array( 'type' => string, //The order item type, should always be $this->getType() 'extra' => mixed, //used to convey to payment gateways "custom information" that may be needed by the gateway. Most can set this to null. 'cost' => double, //amount this adds to the total, what getCost returns 'total' => double, //amount this AND all children adds to the total 'children' => array(), //optional, should be array of child items, with the index //being the item's ID, and the contents being associative array like //this one. Careful not to get into any infinite loops... )

Return value

Type Description
array|bool Either an associative array as documented above, or boolean false if this item has no cost (positive or negative, including children).

getDisplayDetails( bool   $inCart, bool   $inEmail = false, ) : array|bool

Description

Used to display the item in various places, primarily in the main Cart view on the client side.
See {@link _templateOrderItem::getDisplayDetails()} for full documentation.

Arguments

Name Type Description Default
$inCart bool

True if this is being called from inside the cart, false otherwise. Note: do NOT try to use the geoCart object if $inCart is false.

$inEmail bool

True if the results are going to be used in an e-mail notification

false

Return value

Type Description
array|bool Either an associative array as documented above, or boolean false to hide this item from view.

getParentTypes( ) : array

Description

This is used by the system to determine what, if any, default parents this item can be a part of. Since this is a main parent order item, it will be returning an empty array.
See {@link _templateOrderItem::getParentTypes()} for full documentation.

Return value

Type Description
array

getTypeTitle( ) : string

Description

Since the default is to cap the first letter, and we don't want to do that, let's not cap the e.
See {@link _templateOrderItem::getTypeTitle()} for full documentation.

Return value

Type Description
string

my_account_links_newButton( ) : array

Description

Used to display the Add new eWidget button in my account links module.
See {@link _templateOrderItem::my_account_links_newButton()} for full documentation.

Return value

Type Description
array

processStatusChange( string   $newStatus, bool   $sendEmailNotices = true, bool   $updateCategoryCount = false, ) : n/a

Description

If this were a normal order item, most likely something would be done here, something that is involved when activating or de-activating an eWidget.
See {@link _templateOrderItem::processStatusChange()} for full documentation.

Arguments

Name Type Description Default
$newStatus string

a string of what the new status for the item should be. The statuses built into the system are active, pending, and pending_alter.

$sendEmailNotices bool

If set to false, you should not send any e-mail notifications like might be normally done. (if it's false, it will be because this is called from admin and admin said don't send e-mails)

true
$updateCategoryCount bool

If true, should update the category count for any listings that may have activated or de-activated as result of the status change.

false

Return value

Type Description
n/a n/a

youAreCoolCheckVars( ) : n/a

Description

This checks all the input variables submitted as part of the youAreCool step. If there are any problems, this method will raid an error with the cart and the cart will know not to go on.

Return value

Type Description
n/a n/a

youAreCoolDisplay( ) : n/a

Description

Since we added a "youAreCool" step, we need to have 3 methods that handle that step: a display, a check vars, and a process. This one is the display.

Return value

Type Description
n/a n/a

youAreCoolLabel( ) : string

Description

What is displayed for the youAreCool label

Return value

Type Description
string

youAreCoolProcess( ) : n/a

Description

This only happens if there are no errors raised when we checked the vars before. This method should save any values that need to be saved for the youAreCool step.
This step can raise an error with the cart to make the cart not proceed to the next step. Just because you can, doesn't mean you should though. It is considered bad practice to raise an error in this step, except for special cases where raising an error in checkvars is not possible. If at all possible, you should detect any problems in the check vars stage and raised an error then.

Return value

Type Description
n/a n/a

Properties

$defaultProcessOrder, $type,

int  protected  $defaultProcessOrder = 10

The "process" order, or the order that this item is going to be processed relative to other order items. If this has an order of 5 and another item has an order of 10, this item will appear before the other wherever item stuff appears.
See {@link _templateOrderItem::$defaultProcessOrder} for full documentation.

string  protected  $type = "eWidget"

Note that this is the same as the file name (w/o .php) and the start of the class name.
See {@link _templateOrderItem::$type} for full documentation.

Constants

  defaultProcessOrder = 10

Just here for easy internal reference, not used by system. Should be same as other number.


  type = 'eWidget'

Isn't used by system, just used internally to access the name of the order item easily.


Documentation was generated by phpDocumentor 2.2.0 .

Namespaces

  • global

    Packages

    • Default
      • ExampleAddon
        • addon_example_admin
          In charge of doing stuff on the admin side, this is optional.
        • addon_example_info
          Required class for addons, this is the Addon information class, used by the addon system to determine what the addon can do. Also contains info about the addon that can be viewed in the addon management page in the admin.
        • addon_example_pages
          Addon page class, used by the addon system to display pages on the client side.
        • addon_example_setup
          This class is not required. If it, and the function for a particular routine exist, then that function will be called IN ADDITION TO the automated routines of the addon framework.
        • addon_example_tags
          Expects one function for each tag. Function name should be the same as the tag name. Can also have a constructor if anything needs to be constructed.
        • addon_example_util
          This is where to put functions that the main part of the addon will use.
        • eWidgetOrderItem
          This order item is designed to allow users on your site to purchase an eWidget.
      • System
        • DataAccess
          This is the main Database access object.
        • Singleton
          Singleton method class
        • _templateOrderItem
          Developers: use this file as a template to create a new order item.
        • _templatePaymentGateway
          This is the "developer template" payment gateway handler, a developer could use this file as a starting point for creating a new payment gateway in the system.
        • geoAPI
          The main system class for receiving and handling remote API calls, this acts as a translation layer between the communication with the "outside" and each API call.
        • geoAddon
          This is the class that handles anything and everything to do with addons.
        • geoArrayTools
          Utility functions for manipulating arrays
        • geoBrowse
          Contains functions common to browsing listings
        • geoBrowsingFilter
          System for activating, storing, and deactivating browsing filters.
        • geoCJAX
          Class that wraps the CJAX_FRAMEWORK, used to get the CJAX class.
        • geoCache
          This is the main part of the Geo cache system, it does all the "low level" stuff like writing files and escaping cache data.
        • geoCacheModule
          Part of Geo Cache system, specifically tuned to work best with cacheing module data (which will be an array).
        • geoCachePage
          Cache system specifically tuned to work best with cacheing output of pages and modules
        • geoCacheSetting
          Part of Geo Cache system, specifically tuned to work best with cacheing site-wide key=value type settings.
        • geoCacheText
          Part of Geo Cache system, this part specifically tuned to work best with cacheing language specific messages.
        • geoCalendar
          Holds utility method(s) for manipulating stuff dealing with calendar selector.
        • geoCart
          This class is behind the cart, loading all the order items and such and displaying, and processing all the different pages.
        • geoCategory
          Utility class that holds various methods to do stuff with categories in the system.
        • geoCombineResources
          This class helps to combine CSS and JS files, minify them, and optionally compress them.
        • geoCron
          This is the cron job backend, it handles all the communication and security and all that.
        • geoCrypt
          Class to use for encrypting information that needs to be able to be retrieved later.
        • geoDate
          Holds utility method(s) for manipulating stuff dealing with dates.
        • geoEmail
          Class that sends out e-mails.
        • geoFields
          Class that holds settings information for fields to use.
        • geoFieldsField
          A mini object to hold data about a specific field.
        • geoFile
          As the name implies, this is used for file-based utility methods.
        • geoFilter
          A few utility methods, good for filtering stuff.
        • geoFormatString
          Used to display a message nice and pretty, we'll probably be getting rid of this class though so don't go crazy using it.
        • geoHTML
          Class to generate chunks of HTML that are very common, used the most in the admin panel.
        • geoImage
          This class is responsible for a lot of the image processing, along with other aspects like generating the image tag for thumbnails.
        • geoInvoice
          This is the invoice object representing an invoice in the system.
        • geoLeveledField
          Class for doing common things with leveled fields.
        • geoListing
          A listing object, basically a container object for particular listing.
        • geoListingDisplay
          This is basically a container that is responsible for helping to display {listing .
        • geoListingFeed
          Class that helps to render RSS or other types of feeds based on list of listings.
        • geoMaster
          This is dedicated class for getting the value of, and setting, the various "master switches" within the software. Since this is meant as an easy way to get the values of master switches, most of the methods are static.
        • geoNumber
          Utility functions relating to number conversion/manipulation/validation ect.
        • geoOrder
          The geoOrder object, an object representation of an order in the system.
        • geoOrderItem
          The class that all order items must extend.
        • geoPC
          Used for login credential validation, password hashing, etc. along with software licensing.
        • geoPagination
          Utility functions useful for generating pagination of a results page such as when browing ads or searching
        • geoPaymentGateway
          This class should be extended by each different payment gateway, this will have some default functions that each gateway will inherit, and also has a few final static methods used by the system to affect all order items.
        • geoPlanItem
          A container to hold settings for a particular order item type, according to price plan ID, and optionally category ID for category specific settings.
        • geoRecurringBilling
          The geoRecurringBilling object, an object representation of a recurring billing in the system.
        • geoRegion
          Stuff for regions and sub-regions.
        • geoRegistry
          Handy little object, can be used to set registry type settings.
        • geoSearchUtils
          Class for search utilities.
        • geoSellerBuyer
          Handles back-end for the seller/buyer payment gateways, to allow the buyer to more easily pay the seller for a won auction. This handles the underlying system, but the actual work is done by individual seller/buyer gateways, for instance the Paypal buy-now functionality.
        • geoSession
          Manages session storage and session cookies for user sessions.
        • geoString
          Utility functions relating to languages and string manipulation.
        • geoStringData
          This class is to store accented chars, to be used by {@link geoString::removeAccents()}, mainly to keep the String.class.php file un-cluttered.
        • geoTable
          NOT FULLY IMPLEMENTED! Do not use this class yet as it is not finished and may change drastically before we are done with it, or may even be removed.
        • geoTableRow
          NOT FULLY IMPLEMENTED! Do not use this class yet as it is not finished and may change drastically before we are done with it, or may even be removed.
        • geoTableRowset
          NOT FULLY IMPLEMENTED! Do not use this class yet as it is not finished and may change drastically before we are done with it, or may even be removed.
        • geoTableSelect
          Class used to generate a select query, useful when multiple areas want to affect a single query, for instance when generating a search query and there are addons involved.
        • geoTables
          Used to hold database table names, used throughout the code.
        • geoTemplate
          Template object that extends the Smarty class (a 3rd party library) to enable using templates to display things.
        • geoTransaction
          This is the object used for a transaction in the order and invoice system.
        • geoUser
          An object representative of a certain user in the system.
        • geoUserRating
          Store, retrieve, and display inter-user ratings
        • geoUtil
          Misc utility functions
        • geoView
          As the name implies, this is used for creating the page view. It does take a little setup (like any class), the setup is normally done in the display_page method in geoSite, or display_page in geoAdmin if displaying a page in the admin.
        • iApiTransport
          Interface for API Transports, a transport must implement this interface for the system to use it.
        • iOrderItem
          You cannot have abstract static functions, so instead need to have an interface to force the given static functions to be defined.
        • metaDbTables
          Used so that old locations that use the old name geoTables will still work.