We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 50981
    • 3 Posts
    Hi,
    Im trying to install a visioncart module which is not supported anymore on my revolution 2.2.11 but im getting an error while im installing it:
    Attempting to preserve files at /core/components/visioncart into archive /core/packages/visioncart-0.7.0-rc5/modCategory/c716d9c19996467b951a7fdfa4041037.0.preserved.zip
    Attempting to preserve files at /assets/components/visioncart into archive /core/packages/visioncart-0.7.0-rc5/modCategory/c716d9c19996467b951a7fdfa4041037.1.preserved.zip
    [b]Could not load package metadata for package visioncart.[/b]


    I tried to configure this module and everything was fine and I created a shop, categories and products. But when im trying to view a product site (when i select a category) im getting an error:
    Fatal error: Call to a member function route() on a non-object in /core/cache/includes/elements/modplugin/28.include.cache.php on line 36


    This is a file content that error is talking about:
    <?php
    function elements_modplugin_28($scriptProperties= array()) {
    global $modx;
    if (is_array($scriptProperties)) {
    extract($scriptProperties, EXTR_SKIP);
    }
    /**
     * @package visioncart
     */
    
    if ($modx->context->get('key') == 'mgr') {
    	switch((string) $modx->event->name) {
    		case 'OnBeforeCacheUpdate':
    			$modx->cacheManager->refresh(array(
    				'visioncart' => array(
    					'.php'
    				)
    			));
    			break;
    	}
    	return false;
    }
    
    switch((string) $modx->event->name) {
    	case 'OnWebPageInit':
    		$corePath = $modx->getOption('visioncart.core_path', null, $modx->getOption('core_path', null, MODX_CORE_PATH));
    		$modx->addPackage('visioncart', $corePath.'components/visioncart/model/');
    		$modx->visioncart = $modx->getService('visioncart', 'VisionCart', $corePath.'components/visioncart/model/visioncart/', array(
    			'method' => (string) (isset($_REQUEST['method']) && $_REQUEST['method'] != '') ? strtolower($_REQUEST['method']) : 'resource',
    			'initialize' => 'plugin',
    			'context' => (string) $modx->context->get('key'),
    			'event' => (string) $modx->event->name
    		));
    		break;
    	case 'OnPageNotFound':
    		$modx->visioncart->route(array(
    			'method' => (string) (isset($_REQUEST['method']) && $_REQUEST['method'] != '') ? strtolower($_REQUEST['method']) : 'resource',
    			'initialize' => 'plugin',
    			'context' => (string) $modx->context->get('key'),
    			'event' => (string) $modx->event->name
    		));
    		break;
    
    	case 'OnLoadWebDocument':
    		$modx->visioncart->assign(array(
    			'method' => (string) (isset($_REQUEST['method']) && $_REQUEST['method'] != '') ? strtolower($_REQUEST['method']) : 'resource',
    			'initialize' => 'plugin',
    			'context' => (string) $modx->context->get('key'),
    			'event' => (string) $modx->event->name
    		));
    		break;
    	default:
    		//exit($modx->event->name);
    		break;
    }
    }
    


    Could you please help me to fix it? [ed. note: baggy11 last edited this post 8 years, 7 months ago.]
      • 3749
      • 24,544 Posts
      That means that the visioncart package hasn't been loaded when a page is not found. I know nothing about visioncart so I'm not sure what the proper fix would be.

      This is a long shot, but you might try replacing the switch statement with this, since the code in all three sections seems to be the same:

      switch((string) $modx->event->name) {
          case 'OnWebPageInit':
          case 'OnPageNotFound':
          case 'OnLoadWebDocument':
              $corePath = $modx->getOption('visioncart.core_path', null, $modx->getOption('core_path', null, MODX_CORE_PATH));
              if (! $modx->addPackage('visioncart', $corePath.'components/visioncart/model/')) {
                  $modx->log(modX::LOG_LEVEL_ERROR, '[visioncart plugin] addPackage() failed');
              }
              $modx->visioncart = $modx->getService('visioncart', 'VisionCart', $corePath.'components/visioncart/model/visioncart/', array(
                  'method' => (string) (isset($_REQUEST['method']) && $_REQUEST['method'] != '') ? strtolower($_REQUEST['method']) : 'resource',
                  'initialize' => 'plugin',
                  'context' => (string) $modx->context->get('key'),
                  'event' => (string) $modx->event->name
              ));
              break;
         
          default:
              //exit($modx->event->name);
              break;
      }



      If it still throws the error, it means that the addPackage() call is failing.





        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 50981
        • 3 Posts
        Now im not getting an error when i try to view a product site, but im just redirected to my home page so that is not a perfect solution. So maybe someone had some experience with this module and could give me directions what to do?
        • It might get more attention if you changed the title of the original post to something about VisionCart. I don't think too many people know much about it. Its pages aren't even active on the RTFM any more.
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org