/**
  * @param $id
  * @return array
  * @throws BadRequestHttpException
  * @throws NotFoundHttpException
  */
 public function actionUpdateShippingOption($id)
 {
     Yii::$app->response->format = Response::FORMAT_JSON;
     $post = Yii::$app->request->post();
     if (!isset($post['OrderDeliveryInformation']['shipping_option_id'])) {
         throw new BadRequestHttpException();
     }
     /** @var OrderDeliveryInformation $orderDeliveryInformation */
     $orderDeliveryInformation = OrderDeliveryInformation::findOne($id);
     if (is_null($orderDeliveryInformation)) {
         throw new NotFoundHttpException();
     }
     $value = $post['OrderDeliveryInformation']['shipping_option_id'];
     $orderDeliveryInformation->shipping_option_id = $value;
     /** @var ShippingOption $shippingOption */
     $shippingOption = ShippingOption::findOne($value);
     // @todo Need to save shipping price
     if (is_null($shippingOption) || !$orderDeliveryInformation->save(true, ['shipping_option_id'])) {
         return ['message' => Yii::t('app', 'Cannot change shipping option')];
     }
     return ['output' => $shippingOption->name];
 }
 /**
  * Finds the ShippingOption model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return ShippingOption the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = ShippingOption::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }