Select Git revision
ordernumber.php
ordernumber.php 21.27 KiB
<?php
/**
* @package VirtueMart 2 OrderNumber plugin for Joomla! 2.5
* @author Reinhold Kainhofer, reinhold@kainhofer.com
* @copyright (C) 2012-2014 - Reinhold Kainhofer
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
**/
if ( !defined( 'ABSPATH' ) and !defined('_JEXEC') ) {
die( 'Direct Access to ' . basename( __FILE__ ) . ' is not allowed.' ) ;
}
if (!class_exists('vmShopperPlugin'))
require(JPATH_VM_PLUGINS . DS . 'vmshopperplugin.php');
// if (!class_exists( 'VmConfig' ))
// require(JPATH_ROOT.DS.'administrator'.DS.'components'.DS.'com_virtuemart'.DS.'helpers'.DS.'config.php');
// VmConfig::loadConfig();
if (!class_exists('OrdernumberHelperJoomla'))
require_once (dirname(__FILE__) . DS . 'ordernumber_helper_joomla.php');
class plgVmShopperOrdernumber extends vmShopperPlugin {
protected $helper = null;
function __construct(& $subject, $config) {
parent::__construct($subject, $config);
/* Create the database table */
$this->tableFields = array_keys ($this->getTableSQLFields ());
$this->helper = new OrdernumberHelperJoomla();
$this->helper->tableName = $this->_tablename;
$this->helper->registerCallback('setupStoreReplacements', array($this, 'setupStoreReplacements'));
$this->helper->registerCallback('setupOrderReplacements', array($this, 'setupOrderReplacements'));
$this->helper->registerCallback('setupUserReplacements', array($this, 'setupUserReplacements'));
$this->helper->registerCallback('setupShippingReplacements', array($this, 'setupShippingReplacements'));
$this->helper->registerCallback('setupThirdPartyReplacements', array($this, 'setupThirdPartyReplacements'));
}
/**
* Glue functions for the OrdernumberHelper
*/
public function getVmPluginCreateTableSQL () {
return $this->createTableSQL ('VM Shopper plugin: custom order and invoice numbers');
}
function getTableSQLFields () {
$SQLfields = array(
'id' => 'int(11) UNSIGNED NOT NULL AUTO_INCREMENT',
'number_type' => 'varchar(30)',
'number_format' => 'varchar(255)',
'count' => 'int(1)',
);
return $SQLfields;
}
// We don't need this function, but the parent class declares it abstract, so we need to overload
function plgVmOnUpdateOrderBEShopper($_orderID) {}
/* Extract the country information from the given ID */
protected static function getCountryFromID ($country_id) {
$db = JFactory::getDBO();
$query = 'SELECT * FROM `#__virtuemart_countries` WHERE `virtuemart_country_id` = ' . (int)$country_id;
$db->setQuery($query);
return $db->loadObject();
}
public function setupStoreReplacements (&$reps, $details, $nrtype) {
if (isset($details->virtuemart_vendor_id))