User Tools

Site Tools


Sidebar

tutorials:development:auto_check_extras

Auto-Check Extras

This tutorial will walk you through the steps necessary to create an addon, that will cause any "listing extras" to start out automatically checked when placing a new listing.

Requires Geo 4.0.0

This tutorial assumes a basic understanding of PHP and knowledge of how to FTP files from and to your server.

  1. In the addons/ directory, create a new directory named auto_check_extras. <
  2. Inside the new directory, create a file named info.php. This file is what tells the Geo addon system what this particular addon can do. Use the following contents for this file:
<?php
//file /addons/auto_check_extras/info.php
class addon_auto_check_extras_info {
	var $name = 'auto_check_extras';
	var $version = '1.0.0';
	var $title = 'Auto-Check Listing Extras';
	var $author = "Geo Developer Tutorial";
	var $description = 'Automatically checks listing extas when a user places a new auction or classified listing.';
	var $auth_tag = 'my_addons';
}

<

  1. Now, inside addons/auto_check_extras/ directory, create a new sub-directory named order_items. This directory is parsed by the order system, to look for any order items in the addon. To accomplish our task, we will be creating just such an order item. <
  2. Inside the new directory, create a file named auto_check_listing_extras.php. This file will serve as a new order item, although the order item will never actually be added to an order. Use the following contents for this file:
<?php
//file /addons/auto_check_extras/order_items/auto_check_listing_extras.php
require_once CLASSES_DIR . PHP5_DIR . 'OrderItem.class.php';
class auto_check_listing_extrasOrderItem extends geoOrderItem
{
	//Note: only the most necessary methods needed for the current task
	//are defined here.  For a complete list of methods, see the file
	//classes/order_items/_template.php
 
	//This is where the action happens for this order item!
	public static function geoCart_other_detailsDisplay (){
		$cart = geoCart::getInstance();
 
		if (isset($cart->site->session_variables['auto_check_ran'])) {
			//make sure we only auto-check the first time the page
			//loads!
			return;
		}
		$cart->site->session_variables['auto_check_ran'] = 1;
 
		//Un-Comment the lines for the extras you want to auto-check
 
		//un-comment for better placement
		//$cart->site->session_variables ['better_placement'] = 1;
 
		//un-comment for bolding
		//$cart->site->session_variables ['bolding'] = 1;
 
		//un-comment for featured level 1
		//$cart->site->session_variables ['featured_ad'] = 1;
 
		//un-comment for featured level 2
		//$cart->site->session_variables ['featured_ad_2'] = 1;
 
		//un-comment for featured level 3
		//$cart->site->session_variables ['featured_ad_3'] = 1;
 
		//un-comment for featured level 4
		//$cart->site->session_variables ['featured_ad_4'] = 1;
 
		//un-comment for featured level 5
		//$cart->site->session_variables ['featured_ad_5'] = 1;
	}
 
	protected $type = "auto_check_listing_extras";
	const type = 'auto_check_listing_extras';
	protected $defaultProcessOrder = 10;
	const defaultProcessOrder = 10;
 
	//required by system
	public function displayInAdmin() {
		return false;
	}
 
	//required by system, doesn't have to do anything though
	public static function geoCart_initSteps($allPossible=false){
 
	}
 
	//required by system
	public static function geoCart_initItem_forceOutsideCart() {
		return false;
	}
 
	//required by system
	public static function getParentTypes(){
		return array('classified','auction');
	}
 
	//required by system
	public function getDisplayDetails ($inCart){
		return false;
	}
 
	//required by system
	public static function geoCart_initSteps_addOtherDetails(){
		return false;
	}
 
}

<

  1. In the contents of the file, in the method geoCart_other_detailsDisplay, un-comment the line for each listing extra type that you want to be auto-checked. For instance, if you wanted bolding to be auto-checked, in the file you would change the code:
		//un-comment for bolding
		//$cart->site->session_variables ['bolding'] = 1;

And change to:

		//un-comment for bolding
 
		$cart->site->session_variables ['bolding'] = 1;

<

  1. Now, go into addon management, and you should see the addon named "Auto-Check Listing Extras". Install and enable that addon. <
  2. If everything is done correctly, when placing a listing, the listing extras should start out checked by default. <
tutorials/development/auto_check_extras.txt · Last modified: 2016/10/05 23:07 by geojames