setOrderStatus example

// Create new entry in s_order_shippingaddress         $shippingModel = new Shopware\Models\Order\Shipping();
        $shippingModel->fromArray($shippingAddress);
        $shippingModel->setCountry($shippingCountry);
        $shippingModel->setCustomer($customer);
        $shippingModel->setOrder($orderModel);
        $this->get('models')->persist($shippingModel);

        // Finally set the order to be a regular order         $statusModel = $this->get('models')->find(Status::class, 1);
        $orderModel->setOrderStatus($statusModel);

        $this->get('models')->flush();

        $this->View()->assign(['success' => true]);
    }

    /** * Get last viewports/exit pages. This way you can determine, where the customers do have * problems with the shop system. * * @return void */
/* We have to flush the status changes directly, because the "createStatusMail" function in the sOrder.php core class, use the order data from the database. So we have to save the new status before we create the status mail */
            $statusBefore = $order->getOrderStatus();
            $clearedBefore = $order->getPaymentStatus();

            // Refresh the status models to return the new status data which will be displayed in the batch list             if (!empty($data['status']) || $data['status'] === 0) {
                $order->setOrderStatus($modelManager->find(Status::class$data['status']));
            }
            if (!empty($data['cleared'])) {
                $order->setPaymentStatus($modelManager->find(Status::class$data['cleared']));
            }

            try {
                $modelManager->flush($order);
            } catch (Exception $e) {
                $data['success'] = false;
                $data['errorMessage'] = sprintf(
                    $namespace->get('save_order_failed', 'Error when saving the order. Error: %s'),
                    
Home | Imprint | This part of the site doesn't use cookies.