Post by OSWS » Mon Oct 19, 2020 4:53 am

Having been running a site on Opencart 20.3.1. without any issues until today I'm now seeing the following error. It seems to be suggesting testForStock() mpethod isn't found, although the method exists in /system/vqmod/vqcache/vq2-system-library-cart.php

Code: Select all

PHP Fatal error:  Uncaught Error: Call to undefined method Cart::testForStock() in /public_html/vqmod/vqcache/vq2-system_modification_catalog_controller_checkout_cart.php:375
Stack trace:
#0 /home/site/public_html/vqmod/vqcache/vq2-system_modification_system_engine_action.php(66): ControllerCheckoutCart->add(Array)
#1 /site/modelsce/public_html/vqmod/vqcache/vq2-system_engine_front.php(97): Action->execute(Object(Registry))
#2 /home/site/public_html/vqmod/vqcache/vq2-system_engine_front.php(52): Front->execute(Object(Action))
#3 /home/site/public_html/index.php(260): Front->dispatch(Object(Action), Object(Action))
#4 {main}
  thrown in /public_html/vqmod/vqcache/vq2-system_modification_catalog_controller_checkout_cart.php on line 375
I did update /system/library/cart.php earlier in the day to include the code from Opencart 2.1.0.2 which addresses this problem - viewtopic.php?f=20&t=40578&start=60 (database not clearing items following completion of order) but have since reverted /system/library/cart.php to use the Opencart 2.0.3.1 code. (NB: I have cleared VQMod cache to rebuild the cache in case this was impacted, although I don't know why it would be).

Would this error be related to a module or would the database have been affected somehow?

Here's the code from 2.0.3.1 (the part which I replaced):

Code: Select all

public function __construct($registry) {
        $this->config = $registry->get('config');
        $this->customer = $registry->get('customer');
        $this->session = $registry->get('session');
        $this->db = $registry->get('db');
        $this->tax = $registry->get('tax');
        $this->weight = $registry->get('weight');

        if (!isset($this->session->data['cart']) || !is_array($this->session->data['cart'])) {
            $this->session->data['cart'] = array();
        }
    }
and here's the block from 2.1.0.1 which I inserted in place of the above.

Code: Select all

<?php
class Cart {
	private $config;
	private $db;
	private $data = array();

	public function __construct($registry) {
		$this->config = $registry->get('config');
		$this->customer = $registry->get('customer');
		$this->session = $registry->get('session');
		$this->db = $registry->get('db');
		$this->tax = $registry->get('tax');
		$this->weight = $registry->get('weight');

		if (!isset($this->session->data['cart']) || !is_array($this->session->data['cart'])) {
			$this->session->data['cart'] = array();
		}
	}
I would appreciate any advice on how to identify what may be causing the issue being reported in the PHP error log. The testForStock() method called in home/site/public_html/vqmod/vqcache/vq2-system_modification_catalog_controller_checkout_cart.php:375

Code: Select all

375   $stock_test = $this->cart->testForStock();
is referenced in /home/site/public_html/vqmod/vq2-system_library_cart.php:

Code: Select all

public function testForStock() {
		$return = array();
		foreach ($this->getProducts() as $product) {
			if (!$product['stock']) {
				$return = array(
					'stock' => false,
					'pid' => $product['product_id'],
					'name' => $product['name']
				);
				break;
			}
		}

		return $return;
	}
and I'm struggling to undertand how the simple change made to /system/library.cart.php would have affected VQMod cache, especially as I have restored the original code from Opencart 2.0.3.1.

New member

Posts

Joined
Mon Sep 28, 2015 9:02 pm

Post by straightlight » Mon Oct 19, 2020 6:54 am

Clear your .cache files as well as all your files in your VQCache folder.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by OSWS » Mon Oct 19, 2020 6:18 pm

Thanks, Straighlight that's fixed the issue. Could have sworn I cleared the system cache before posting but the cart functionality is now working.

New member

Posts

Joined
Mon Sep 28, 2015 9:02 pm

Post by paulfeakins » Tue Oct 20, 2020 4:58 pm

OSWS wrote:
Mon Oct 19, 2020 6:18 pm
Thanks, Straighlight that's fixed the issue. Could have sworn I cleared the system cache before posting but the cart functionality is now working.
Please add [SOLVED] to the start of the post title.

For quick, professional OpenCart support please email info@antropy.co.uk


User avatar
Guru Member

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - Reigate, Surrey, United Kingdom
Who is online

Users browsing this forum: No registered users and 24 guests