public function caculatePrice() { $sku = Input::has('sku') ? Input::get('sku') : 'ROL-663'; $sizew = Input::has('sizew') ? Input::get('sizew') : 0; $sizeh = Input::has('sizeh') ? Input::get('sizeh') : 0; $quantity = Input::has('order_qty') ? Input::get('order_qty') : 1; $product = new VIImage(); $product->sizew = $sizew; $product->sizeh = $sizeh; $groups = ProductOptionGroup::select('id', 'name', 'key')->get(); foreach ($groups as $value) { $option_key = Input::has($value->key) ? Input::get($value->key) : ''; if ($option_key != '') { //echo 'option_key: '.$option_key.'<br/>'; $obj_option = ProductOption::where('key', $option_key)->first(); $option = floatval($obj_option->name); if ($value->key == 'depth') { $product->bleed = $option; } else { $key = $value->key; $product->{$key} = $option; } } } // echo '<pre>'; // print_r($product); // echo '</pre>'; // exit; $product->quantity = $quantity; $product->sku = $sku; $price = JTProduct::getPrice($product); if ($product->margin_up) { $biggerPrice = $price['sell_price'] * (1 + $product->margin_up / 100); $arrReturn = ['sell_price' => $price['sell_price'], 'bigger_price' => VIImage::viFormat($biggerPrice), 'amount' => $price['sub_total']]; } else { $arrReturn = ['sell_price' => $price['sell_price'], 'amount' => $price['sub_total']]; } if (Request::ajax()) { $arrReturn = ['status' => 'ok', 'message' => '', 'data' => $arrReturn]; $response = Response::json($arrReturn); $response->header('Content-Type', 'application/json'); return $response; } return false; }