Jump to content

500 Server Error after order confirmation


Recommended Posts

Hi, I have Prestashop 1.6.0.9 (updated from 1.5.4.1) with 2 languages EN and GR.
I've noticed that when a customer adds a product while shop is in English and then he switches the language in Greek he gets an 500 Server Error.
In error log I get:
[PrestaShopException]

Property OrderDetail->product_name is not valid
at line 846 in file classes/ObjectModel.php

840.
841.             $message = $this->validateField($field, $this->$field);
842.             if ($message !== true)
843.             {
844.                 if ($die)
845.                     throw new PrestaShopException($message);
846.                 return $error_return ? $message : false;
847.             }
848.         }
849.
850.         return true;
  • ObjectModelCore->validateFields - [line 260 - classes/ObjectModel.php]
    254.      *
    255.      * @return array All object fields
    256.      */
    257.     public function getFields()
    258.     {
    259.         $this->validateFields();
    260.         $fields = $this->formatFields(self::FORMAT_COMMON);
    261.
    262.         // For retro compatibility
    263.         if (Shop::isTableAssociated($this->def['table']))
    264.             $fields = array_merge($fields, $this->getFieldsShop());
  • ObjectModelCore->getFields - [line 464 - classes/ObjectModel.php]
    458.         }
    459.         
    460.         // Database insertion
    461.         if (Shop::checkIdShopDefault($this->def['table']))
    462.             $this->id_shop_default = min($id_shop_list);
    463.         if (!$result = ObjectModel::$db->insert($this->def['table'], $this->getFields(), $null_values))
    464.             return false;
    465.
    466.         // Get object id in database
    467.         $this->id = ObjectModel::$db->Insert_ID();
    468.
  • ObjectModelCore->add - [line 425 - classes/ObjectModel.php] - [2 Arguments]
    419.      * @param bool $autodate
    420.      * @return boolean Insertion result
    421.      */
    422.     public function save($null_values = false, $autodate = true)
    423.     {
    424.         return (int)$this->id > 0 ? $this->update($null_values) : $this->add($autodate, $null_values);
    425.     }
    426.
    427.     /**
    428.      * Add current object to database
    429.      *
  • ObjectModelCore->save - [line 146 - override/classes/order/OrderDetail.php]
    140.         
    141.         // Set shop id
    142.         $this->id_shop = (int)$product['id_shop'];
    143.         
    144.         // Add new entry to the table
    145.         $this->save();
    146.
    147.         if ($use_taxes)
    148.             $this->saveTaxCalculator($order);
    149.         unset($this->tax_calculator);
    150.     }
  • OrderDetail->create - [line 613 - classes/order/OrderDetail.php] - [7 Arguments]
    607.
    608.         $this->id_order = $order->id;
    609.         $this->outOfStock = false;
    610.
    611.         foreach ($product_list as $product)
    612.             $this->create($order, $cart, $product, $id_order_state, $id_order_invoice, $use_taxes, $id_warehouse);
    613.
    614.         unset($this->vat_address);
    615.         unset($products);
    616.         unset($this->customer);
    617.     }
  • OrderDetailCore->createList - [line 195 - override/classes/PaymentModule.php] - [7 Arguments]
    189.
    190.                     $order_list[] = $order;
    191.
    192.                     // Insert new Order detail list using cart for the current order
    193.                     $order_detail = new OrderDetail(null, null, $this->context);
    194.                     $order_detail->createList($order, $this->context->cart, $id_order_state, $order->product_list, 0, true, $package_list[$id_address][$id_package]['id_warehouse']);
    195.                     $order_detail_list[] = $order_detail;
    196.
    197.                     // Adding an entry in order_carrier table
    198.                     if (!is_null($carrier))
    199.                     {
  • PaymentModule->validateOrder - [line 59 - modules/cashondelivery/controllers/front/validation.php] - [9 Arguments]
    53.
    54.         if (Tools::getValue('confirm'))
    55.         {
    56.             $customer = new Customer((int)$this->context->cart->id_customer);
    57.             $total = $this->context->cart->getOrderTotal(true, Cart::BOTH);
    58.             $this->module->validateOrder((int)$this->context->cart->id, Configuration::get('PS_OS_PREPARATION'), $total, $this->module->displayName, null, array(), null, false, $customer->secure_key);
    59.             Tools::redirectLink(__PS_BASE_URI__.'order-confirmation.php?key='.$customer->secure_key.'&id_cart='.(int)$this->context->cart->id.'&id_module='.(int)$this->module->id.'&id_order='.(int)$this->module->currentOrder);
    60.         }
    61.     }
    62.
    63.     /**
  • CashondeliveryValidationModuleFrontController->postProcess - [line 171 - classes/controller/Controller.php]
    165.             // setMedia MUST be called before postProcess
    166.             if (!$this->content_only && ($this->display_header || (isset($this->className) && $this->className)))
    167.                 $this->setMedia();
    168.
    169.             // postProcess handles ajaxProcess
    170.             $this->postProcess();
    171.
    172.             if (!empty($this->redirect_after))
    173.                 $this->redirect();
    174.
    175.             if (!$this->content_only && ($this->display_header || (isset($this->className) && $this->className)))
  • ControllerCore->run - [line 373 - classes/Dispatcher.php]
    367.             // Execute hook dispatcher
    368.             if (isset($params_hook_action_dispatcher))
    369.                 Hook::exec('actionDispatcher', $params_hook_action_dispatcher);
    370.
    371.             // Running controller
    372.             $controller->run();
    373.         }
    374.         catch (PrestaShopException $e)
    375.         {
    376.             $e->displayMessage();
    377.         }
  • DispatcherCore->dispatch - [line 28 - index.php]
    22. * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
    23. * International Registered Trademark & Property of PrestaShop SA
    24. */
    25.
    26. require(dirname(__FILE__).'/config/config.inc.php');
    27. Dispatcher::getInstance()->dispatch();

 

 

 

 

I've tested it with all payment methods

Cash on delivery (COD) v0.7.3 - by PrestaShop

Bank wire v1.0.5 - by PrestaShop

PayPal v3.8.1 - by PrestaShop

 

In BO I see that a new order has been placed without products in it and several errors

Notice on line 120 in file

.../cache/smarty/compile/c2/a1/ab/c2a1ab9698417537d94aa592b3eb9bf447f8b7ec.file.view.tpl.php

[8] Trying to get property of non-object

 and 

Notice on line 361 in file .

../cache/smarty/compile/c2/a1/ab/c2a1ab9698417537d94aa592b3eb9bf447f8b7ec.file.view.tpl.php
[8] Trying to get property of non-object

 

I'm also not getting any email alert for this order

 

Any help would be appreciated!

 

Link to comment
Share on other sites

It seems it doesn't like the greek language, check the order_detail table encoding, it might not be compatible with greek chars

Maybe you are right :)

 

The encoding is utf8_general_ci but I don't think that it has to do with encoding.

 

Tested it again today:

  • add to cart in greek , checkout in greek -> OK
  • add to cart in greek, checkout in english -> OK
  • add to cart in english, checkout in english -> OK
  • add to cart in english, checkout in greek -> 500 error
Edited by kapapi (see edit history)
Link to comment
Share on other sites

×
×
  • Create New...