Skip to content
Snippets Groups Projects
Select Git revision
  • 76ca0bb934311439e0dc31a0258f92178248c805
  • master default protected
  • before_library
  • V4.0.4
  • V4.0.3
  • V4.0.2
  • V4.0.1
  • V4.0
  • V3.6a
  • V3.99
  • V3.6
  • V3.5
  • V3.4
  • V3.3
  • V3.2
  • V3.1
  • V3.0
  • V2.2
  • V2.0
  • V1.13
  • V1.90
  • V1.12
  • V1.11
23 results

ordernumber.php

Blame
  • 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))