save order error

Issue #101 resolved
Dragan Vuletic created an issue

Fresh install ( tested on master/develop branches and Zip archive ). Single product. Guest checkout. All default options checked ( free shipping, identical addresses, Check / Money Order ). Place Order always produce following error:

ERROR: SQLSTATE[HY000]: General error: 1364 Field 'grand_total' doesn't have a default value 
QUERY: INSERT INTO `fcom_sales_order` (`cart_id`, `admin_id`, `customer_id`, `customer_email`, `item_qty`, `store_currency_code`, `same_address`, `create_at`, `update_at`, `unique_id`) VALUES ('3', '', '', 'gyhjhgj@sdfsdf.com', '1', 'USD', '1', '2015-07-08 08:47:26', '2015-07-08 08:47:26', '10000006')

It seems like problem is in Sellvana_Sales_Model_Order::importDataFromCart function, when first save() is triggered. Removing that first save solves the issue for Place Order.

public function importDataFromCart($cart)
    {
        $this->_cart = $cart;
        $this
            ->_importBasicFieldsFromCart()
            ->save() // create unique id

            ->_importAddressDataFromCart()
            ->_importItemsDataFromCart()
            ->_importTotalsDataFromCart()
            ->_importShippingDataFromCart()
            ->_importPaymentDataFromCart()
            ->_importDiscountDataFromCart()
            ->_setDefaultStates()
            ->save()
        ;
        return $this;
    }

Comments (3)

  1. Log in to comment