Jump to content
thirty bees forum
  • 0

Updating to new Thirtybees 1.6 caused getting a Error 500 page after adding item to cart...


Question

Posted

Hello people, I just tried updating my shop to Thirtybees 1.6.

After doing some testings on the resulting front office, I noticed that whenever I would click on the Add to Cart for a product,  then clicking on the "Proceed to checkout" button on the next screen, I would get a Error page 500 instead of the usual Shopping-cart summary page.

I revert back to Thirtybees 1.5.1 and it's working like it was before.

However, any ideas what was the cause of this problem?

I'd like to update to the 1.6 version but would like to know what I need to do so it does not break my shop in the process.

Any help would be appreciated.

 

16 answers to this question

Recommended Posts

  • 0
Posted
8 minutes ago, datakick said:

Anything can cause that.

Install collectlogs module, update back to 1.6, and then look what errors are collected. 

I already have the collectlogs module, I suspect it has something to do with a Paypal payment module from PrestoChangeo:

Message:
file_get_contents(http://updates.presto-changeo.com/?module_info=PPP_1.4.6_1730731632_1730991416_259200): Failed to open stream: HTTP request failed! HTTP/1.1 521


Location:
modules/paypalpro/PrestoChangeoClasses/PrestoChangeoPaymentModule.php line 290
#0  builtin
#1  modules/paypalpro/PrestoChangeoClasses/PrestoChangeoPaymentModule.php(290): file_get_contents(string(85): "http://updates.presto-changeo.com/?module_info=PPP_1.4.6_1730731632_1730991416_2"...)
#2  modules/paypalpro/paypalpro.php(89): PrestoChangeoPaymentModule->upgradeCheck("PPP")
#3  builtin: PaypalPro->__construct()
#4  Core/Foundation/IoC/Core_Foundation_IoC_Container.php(180): ReflectionClass->newInstance()
#5  Core/Foundation/IoC/Core_Foundation_IoC_Container.php(224): Core_Foundation_IoC_Container->makeInstanceFromClassName("paypalpro", array(1))
#6  Core/Foundation/IoC/Core_Foundation_IoC_Container.php(244): Core_Foundation_IoC_Container->doMake("paypalpro", array(1))
#7  classes/core/ServiceLocator.php(168): Core_Foundation_IoC_Container->make("paypalpro")
#8  Adapter/Adapter_ServiceLocator.php(59): Thirtybees\Core\DependencyInjection\ServiceLocatorCore->getByServiceName("paypalpro")
#9  classes/module/Module.php(877): Adapter_ServiceLocator::get("paypalpro")
#10 classes/Dispatcher.php(420): ModuleCore::getModulesOnDisk(true)
#11 controllers/admin/AdminPerformanceController.php(1422): DispatcherCore::getModuleControllers("admin")
#12 controllers/admin/AdminPerformanceController.php(971): AdminPerformanceControllerCore->displayControllerList(array(10), 1)
#13 controllers/admin/AdminPerformanceController.php(120): AdminPerformanceControllerCore->initFieldsetFullPageCache()
#14 controllers/admin/AdminPerformanceController.php(71): AdminPerformanceControllerCore->renderForm()
#15 classes/controller/Controller.php(209): AdminPerformanceControllerCore->initContent()
#16 classes/Dispatcher.php(851): ControllerCore->run()
#17 admin123/index.php(58): DispatcherCore->dispatch()

But it could be something else...

I a bit worried to do the upgrade again as I don't wont to break my shop...

 

 

 

 

  • 0
Posted

What's the severity of that message? I doubt it's exception or error, it looks like notice or warnings. If so, than it probably won't be the root cause

  • 0
Posted
2 minutes ago, datakick said:

What's the severity of that message? I doubt it's exception or error, it looks like notice or warnings. If so, than it probably won't be the root cause

You're right, it's just a warning. I see this on my 1.5.1 Thirtybees version...

When doing the update via Core Updater, do I have to do anything else then the update and Database schema check to perform the update?

(like doing a Force compilation or clear cache)...

 

  • 0
Posted (edited)
4 minutes ago, datakick said:

Nothing special, just update

Ok, I will place my shop under maintenance and try again, then I will post the error logs...

Doing a backup now...

 

Edited by papagino
  • 0
Posted
29 minutes ago, datakick said:

Nothing special, just update

Ok just updated and same problem, here is the error Exception I got:

Quote

Exception

 

Message:

TypeError: array_merge(): Argument #1 must be of type array, null given

 

 

 

Location:

override/classes/Carrier.php line 84

 

Stacktrace

#0  override/classes/Carrier.php(84)
#1  override/classes/Carrier.php(84): array_merge()
#2  classes/Cart.php(4157): Carrier::getAvailableCarrierList()
#3  classes/Cart.php(4114): CartCore->getDeliveryAddressesWithoutCarriers()
#4  classes/Cart.php(4063): CartCore->getDeliveryErrorReasons()
#5  controllers/front/ParentOrderController.php(378): CartCore->getSummaryDetails()
#6  controllers/front/OrderController.php(318): ParentOrderControllerCore->_assignSummaryInformations()
#7  classes/controller/Controller.php(209): OrderControllerCore->initContent()
#8  classes/controller/FrontController.php(264): ControllerCore->run()
#9  classes/Dispatcher.php(858): FrontControllerCore->run()
#10 index.php(33): DispatcherCore->dispatch()

 

  • 0
Posted
10 minutes ago, datakick said:

paste content of 

override/classes/Carrier.php
<?php

class Carrier extends CarrierCore
{
	public static function getAvailableCarrierList(Product $product, $id_warehouse, $id_address_delivery = null, $id_shop = null, $cart = null, &$error = array())
	{
		static $ps_country_default = null;

		if ($ps_country_default === null)
			$ps_country_default = Configuration::get('PS_COUNTRY_DEFAULT');

		if (is_null($id_shop))
			$id_shop = Context::getContext()->shop->id;
		if (is_null($cart))
			$cart = Context::getContext()->cart;

		$id_address = (int)((!is_null($id_address_delivery) && $id_address_delivery != 0) ? $id_address_delivery :  $cart->id_address_delivery);
		if ($id_address)
		{
			$id_zone = Address::getZoneById($id_address);

			// Check the country of the address is activated
			if (!Address::isCountryActiveById($id_address))
				return array();
		}
		else
		{
			// changed for Presto-Changeo carrier modules --->
			$cookie = Context::getContext()->cookie;
			$cookie_country = $cookie->id_country ? $cookie->id_country : $cookie->pc_dest_country;
			$country = new Country((isset($cookie_country) && strlen($cookie_country) ? $cookie_country : $ps_country_default));
			// <--- changed for Presto-Changeo carrier modules
			$id_zone = $country->id_zone;
		}

		// Does the product is linked with carriers?
		$cache_id = 'Carrier::getAvailableCarrierList_'.(int)$product->id.'-'.(int)$id_shop;
		if (!Cache::isStored($cache_id))
		{
			$query = new DbQuery();
			$query->select('id_carrier');
			$query->from('product_carrier', 'pc');
			$query->innerJoin('carrier', 'c',
							  'c.id_reference = pc.id_carrier_reference AND c.deleted = 0 AND c.active = 1');
			$query->where('pc.id_product = '.(int)$product->id);
			$query->where('pc.id_shop = '.(int)$id_shop);

			$carriers_for_product = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
			Cache::store($cache_id, $carriers_for_product);
		}
		else
			$carriers_for_product = Cache::retrieve($cache_id);

		$carrier_list = array();
		if (!empty($carriers_for_product))
		{
			//the product is linked with carriers
			foreach ($carriers_for_product as $carrier) //check if the linked carriers are available in current zone
				if (Carrier::checkCarrierZone($carrier['id_carrier'], $id_zone))
					$carrier_list[$carrier['id_carrier']] = $carrier['id_carrier'];
			if (empty($carrier_list))
				return array();//no linked carrier are available for this zone
		}

		// The product is not dirrectly linked with a carrier
		// Get all the carriers linked to a warehouse
		if ($id_warehouse)
		{
			$warehouse = new Warehouse($id_warehouse);
			$warehouse_carrier_list = $warehouse->getCarriers();
		}

		$available_carrier_list = array();
		$cache_id = 'Carrier::getAvailableCarrierList_getCarriersForOrder_'.(int)$id_zone.'-'.(int)$cart->id;
		if (!Cache::isStored($cache_id))
		{
			$customer = new Customer($cart->id_customer);
			$carrier_error = array();
			$carriers = Carrier::getCarriersForOrder($id_zone, $customer->getGroups(), $cart, $carrier_error);
			Cache::store($cache_id, array($carriers, $carrier_error));
		} else
			list($carriers, $carrier_error) = Cache::retrieve($cache_id);

		$error = array_merge($error, $carrier_error);

		foreach ($carriers as $carrier)
			$available_carrier_list[$carrier['id_carrier']] = $carrier['id_carrier'];

		if ($carrier_list)
			$carrier_list = array_intersect($available_carrier_list, $carrier_list);
		else
			$carrier_list = $available_carrier_list;

		if (isset($warehouse_carrier_list))
			$carrier_list = array_intersect($carrier_list, $warehouse_carrier_list);

		$cart_quantity = 0;

		foreach ($cart->getProducts(false, $product->id) as $cart_product)
			if ($cart_product['id_product'] == $product->id)
				$cart_quantity += $cart_product['cart_quantity'];

		if ($product->width > 0 || $product->height > 0 || $product->depth > 0 || $product->weight > 0)
		{
			foreach ($carrier_list as $key => $id_carrier)
			{
				$carrier = new Carrier($id_carrier);

				// Get the sizes of the carrier and the product and sort them to check if the carrier can take the product.
				$carrier_sizes = array((int)$carrier->max_width, (int)$carrier->max_height, (int)$carrier->max_depth);
				$product_sizes = array((int)$product->width, (int)$product->height, (int)$product->depth);
				rsort($carrier_sizes, SORT_NUMERIC);
				rsort($product_sizes, SORT_NUMERIC);

				if (($carrier_sizes[0] > 0 && $carrier_sizes[0] < $product_sizes[0])
					|| ($carrier_sizes[1] > 0 && $carrier_sizes[1] < $product_sizes[1])
					|| ($carrier_sizes[2] > 0 && $carrier_sizes[2] < $product_sizes[2]))
				{
					$error[$carrier->id] = Carrier::SHIPPING_SIZE_EXCEPTION;
					unset($carrier_list[$key]);
				}

				if ($carrier->max_weight > 0 && $carrier->max_weight < $product->weight * $cart_quantity)
				{
					$error[$carrier->id] = Carrier::SHIPPING_WEIGHT_EXCEPTION;
					unset($carrier_list[$key]);
				}
			}
		}
		return $carrier_list;
	}
}

 

  • 0
Posted

Replace this line with

        if (! is_array($error)) {
            $error = [];
        }
        $error = array_merge($error, $carrier_error);

Core method variant allows $error parameter to have null value, and it properly handles that situation. Your override version does not - it's probably from very old ps16.

Note:

This override completely replaces the core version of getAvailableCarrierList method. There has been a lot of changes in that method (for example added support for min package weight), which will not work for you now.

You should update the override code -- copy the current version from tb core, and apply the needed changes. Otherwise system will not work properly in all cases. 

This is not related to 1.6.0, though -- it's the same with 1.5.1 as well. 

  • 0
Posted
55 minutes ago, datakick said:

I've also updated core code in bleeding edge, to have better backwards compatibility with legacy overrides.

1 hour ago, datakick said:

You should update the override code -- copy the current version from tb core, and apply the needed changes. Otherwise system will not work properly in all cases.

Not sure what you mean with the statement above, should I replace the override/classes/Carrier.php with a new tb core one, then modify the line as above?

Also, I am using a purchased Canada Post Module called: Canada Post: Rates and Estimator v4.2.1 - by ZH Media.

Will this effect the functionality of it? Probably not...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...