function product_details_get() { $userId = $this->get('userId'); $this->config->load('product'); $latitude = $this->get('latitude'); $longitude = $this->get('longitude'); $deviceType = $this->get('deviceType'); $UDID = $this->get('UDID'); $deviceToken = $this->get('deviceToken'); $defaultDataArr = array('UDID' => $UDID, 'deviceType' => $deviceType, 'deviceToken' => $deviceToken, 'latitude' => $latitude, 'longitude' => $longitude); $isValideDefaultData = $this->check_default_data($defaultDataArr); if (strtoupper(get_counry_code_from_lat_long($latitude, $longitude)) != 'IN') { $this->response(array('error' => 'Invalid username or password,please try again.'), 400); return FALSE; } if ($isValideDefaultData['type'] == 'fail') { $this->response(array('error' => $isValideDefaultData['message']), 400); return FALSE; } $productId = $this->get('productId'); $productDetailsArr = $this->product->details($productId, TRUE); if (empty($productDetailsArr)) { $this->response(array('error' => 'Invalid product index. Please try again!'), 400); return FALSE; } //pre($productDetailsArr);die; if ($productDetailsArr[0]['status'] == 0) { $this->response(array('error' => 'This product is an inactive product. Please try again!'), 400); return FALSE; } $this->product->update_view($productId); $productImageArr = $this->product->get_products_images($productId, TRUE); $productPriceArr = $this->product->get_products_price($productId, TRUE); $result = array(); $result['is_loged_in'] = $userId; //$data['breadCrumbStr']=$this->breadCrumb($productDetailsArr[0]->categoryId, $productDetailsArr[0]->title); $result['productDetailsArr'] = $productDetailsArr; $result['productImageArr'] = $productImageArr; $result['productPriceArr'] = $productPriceArr; /*$mobileBoxContentsArr=$this->config->item('mobileBoxContents'); $mobileContentArr= explode(',', $productDetailsArr[0]['mobileBoxContent']); if(!empty($mobileContentArr)): $inBox=''; foreach($mobileContentArr AS $k){ if($inBox=='') $inBox=$mobileBoxContentsArr[$k]; else $inBox.= ', '.$mobileBoxContentsArr[$k]; } $result['mobileBoxContents']=$inBox; else: $result['mobileBoxContents']='No thing inside'; endif; $mobileColor=$this->config->item('mobileColor'); $mobileColorName='';if(array_key_exists($productDetailsArr[0]['color'], $mobileColor)){$mobileColorName=$mobileColor[$productDetailsArr[0]['color']];} $result['mobileColorName']=$mobileColorName; $mobileDisplayResolution=$this->config->item('mobileDisplayResolution'); $mobileDisplayResolutiontype='';if(array_key_exists($productDetailsArr[0]['displayResolution'], $mobileDisplayResolution)){$mobileDisplayResolutiontype=$mobileDisplayResolution[$productDetailsArr[0]['displayResolution']];} $result['mobileDisplayResolutionType']=$mobileDisplayResolutiontype; $mobileBatteryType=$this->config->item('mobileBatteryType'); $mobileBatteryName='';if(array_key_exists($productDetailsArr[0]['batteryType'], $mobileBatteryType)){$mobileBatteryName=$mobileBatteryType[$productDetailsArr[0]['batteryType']];} $result['mobileBatteryName']=$mobileBatteryName; $result['mobileOS']=$this->config->item('mobileOS')[$productDetailsArr[0]['os']]; $mobileConnectivity=$this->config->item('mobileConnectivity'); $connectivityArr= explode(',', $productDetailsArr[0]['mobileConnectivity']); $connectionStr=''; foreach($connectivityArr AS $k =>$v){ $connectionStr.=$mobileConnectivity[$v].', '; } $result['connectivityType']=$connectionStr; $mobileProcessorCores=$this->config->item('mobileProcessorCores'); $processorType="";if(array_key_exists($productDetailsArr[0]['processorCores'], $mobileProcessorCores)){$processorType=$mobileProcessorCores[$productDetailsArr[0]['processorCores']];} $result['processorType']=$processorType; $result['mobileProcessorBrand']=$this->config->item('mobileProcessorBrand')[$productDetailsArr[0]['processorBrand']]; $mobileCamera=$this->config->item('mobileCamera'); $rearCamera='';if(array_key_exists($productDetailsArr[0]['mobileRearCamera'], $mobileCamera)){$rearCamera=$mobileCamera[$productDetailsArr[0]['mobileRearCamera']];} $result['rearCamera']=$rearCamera; $frontCamera='';if(array_key_exists($productDetailsArr[0]['frontCamera'], $mobileCamera)){$frontCamera=$mobileCamera[$productDetailsArr[0]['frontCamera']];} $result['frontCamera']=$frontCamera; $ramData=$this->config->item('ramData'); $ram='';if(array_key_exists($productDetailsArr[0]['ram'], $ramData)){$ram=$ramData[$productDetailsArr[0]['ram']];} $result['ram']=$ram; $expandableMemory=$this->config->item('expandableMemory'); $expandableMemoryData='';if(array_key_exists($productDetailsArr[0]['expandableMemory'],$expandableMemory)){$expandableMemoryData=$expandableMemory[$productDetailsArr[0]['expandableMemory']];} $result['expandableMemoryData']=$expandableMemoryData; $warrantyDuration=$this->config->item('warrantyDuration'); $warrantyDurationData='';if(array_key_exists($productDetailsArr[0]['warrantyDuration'], $warrantyDuration)){$warrantyDurationData=$warrantyDuration[$productDetailsArr[0]['warrantyDuration']];} $result['warrantyDurationData']=$warrantyDurationData; $internalMemory=$this->config->item('internalMemory'); $internalMemoryData='';if(array_key_exists($productDetailsArr[0]['internalMemory'], $internalMemory)){$internalMemoryData=$internalMemory[$productDetailsArr[0]['internalMemory']];} $result['internalMemoryData']=$internalMemoryData;*/ $options = $this->option->get_product_display_option_values($productId); $optionsArr = array(); foreach ($options as $k => $option) { foreach ($option as $kk => $val) { //$temp= lcfirst(str_replace(" ","",ucwords(strtolower($kk)))); $optionsArr[$kk] = implode(',', $val); } } $topOptions = $this->option->get_product_display_top_option_values($productId); $topOptionsArr = array(); foreach ($topOptions as $k => $option) { foreach ($option as $kk => $val) { //$temp= lcfirst(str_replace(" ","",ucwords(strtolower($kk)))); $topOptionsArr[$kk] = implode(',', $val); } } $result['options'] = $optionsArr; $result['topOptions'] = $topOptionsArr; $result['tidiit_currency_simbol'] = get_currency_simble_from_lat_long($latitude, $longitude); //pre($result);die; success_response_after_post_get($result); }
function best_selling_products_list_post() { $userId = $this->post('userId'); $UDID = $this->post('UDID'); $deviceType = $this->post('deviceType'); $deviceToken = $this->post('deviceToken'); $latitude = $this->post('latitude'); $longitude = $this->post('longitude'); $defaultDataArr = array('UDID' => $UDID, 'deviceType' => $deviceType, 'deviceToken' => $deviceToken, 'latitude' => $latitude, 'longitude' => $longitude); $isValideDefaultData = $this->check_default_data($defaultDataArr); if (strtoupper(get_counry_code_from_lat_long($latitude, $longitude)) != 'IN') { $this->response(array('error' => 'Invalid username or password,please try again.'), 400); return FALSE; } if ($isValideDefaultData['type'] == 'fail') { $this->response(array('error' => $isValideDefaultData['message']), 400); return FALSE; } $cond = array(); //$cond['brand'] = [$brandDetails->title]; $data['sort'] = 'popular'; $data['range'] = array(0, 100000); //$offset=NULL; //$item_per_page=NULL; //$products = $this->category->get_brand_products($brandId, $offset, $limit = $item_per_page, $cond); $products = $this->product->get_all_best_selling_product(); $brnds = $this->brand->get_all(); $brand = []; foreach ($brnds as $bkey => $bdata) { $brand[] = $bdata->title; } $data['products'] = $products; $data['brands'] = $brand; $range = array(0, 100000); $data['range'] = array('minimum' => $range[0], 'maximum' => $range[01]); $data['master_sort'] = array('popular' => 'Popularity', 'lowestPrice' => 'Lowest Price', 'highestPrice' => 'Highest Price', 'new' => 'isNew'); $data['tidiit_currency_simbol'] = get_currency_simble_from_lat_long($latitude, $longitude); success_response_after_post_get($data); }
function track_order_post() { $orderId = $this->post('orderId'); $userId = $this->post('userId'); $latitude = $this->post('latitude'); $longitude = $this->post('longitude'); $deviceType = $this->post('deviceType'); $UDID = $this->post('UDID'); $deviceToken = $this->post('deviceToken'); $defaultDataArr = array('UDID' => $UDID, 'deviceType' => $deviceType, 'deviceToken' => $deviceToken, 'latitude' => $latitude, 'longitude' => $longitude); $isValideDefaultData = $this->check_default_data($defaultDataArr); if (strtoupper(get_counry_code_from_lat_long($latitude, $longitude)) != 'IN') { $this->response(array('error' => 'Invalid username or password,please try again.'), 400); return FALSE; } if ($isValideDefaultData['type'] == 'fail') { $this->response(array('error' => $isValideDefaultData['message']), 400); return FALSE; } $result = array(); $orderDetails = $this->order->details($orderId, TRUE); if (empty($orderDetails)) { $this->response(array('error' => 'Invalid order index. Please try again!'), 400); return FALSE; } $userDetails = $this->user->get_details_by_id($userId); if (empty($userDetails)) { $this->response(array('error' => 'Invalid user index. Please try again!'), 400); return FALSE; } //pre($orderDetails);die; $orderInfo = unserialize(base64_decode($orderDetails[0]['orderInfo'])); $orderInfo = json_decode(json_encode($orderInfo), true); //pre($orderInfo);die; $orderDetails[0]['orderDate'] = date('d-m-Y H:i:s', strtotime($orderDetails[0]['orderDate'])); $orderDetails[0]['orderUpdatedate'] = date('d-m-Y H:i:s', strtotime($orderDetails[0]['orderUpdatedate'])); $orderDetails[0]['cancelDate'] = date('d-m-Y H:i:s', strtotime($orderDetails[0]['cancelDate'])); $orderDetails[0]['productImage'] = $orderInfo['pimage']['image']; $orderDetails[0]['productTitle'] = $orderInfo['pdetail']['title']; //pre($orderDetails);die; $result['orderDetails'] = $orderDetails; $result['orderInfo'] = $orderInfo; $result['order_state_data'] = $this->order->get_state(true); $result['tidiit_currency_simbol'] = get_currency_simble_from_lat_long($latitude, $longitude); success_response_after_post_get($result); }
function buying_club_order_coupon_set_post() { $this->load->model('Coupon_model', 'coupon'); $promocode = $this->post('couponCode', TRUE); $orderId = $this->post('orderId', TRUE); $userId = $this->post('userId', TRUE); $latitude = $this->post('latitude', TRUE); $longitude = $this->post('longitude', TRUE); $deviceType = $this->post('deviceType'); $UDID = $this->post('UDID'); $deviceToken = $this->post('deviceToken'); $defaultDataArr = array('UDID' => $UDID, 'deviceType' => $deviceType, 'deviceToken' => $deviceToken, 'latitude' => $latitude, 'longitude' => $longitude); $isValideDefaultData = $this->check_default_data($defaultDataArr); if ($isValideDefaultData['type'] == 'fail') { $this->response(array('error' => $isValideDefaultData['message']), 400); return FALSE; } if ($userId == "" || $orderId == "" || $promocode == "") { $this->response(array('error' => 'Please provide user index,order index,coupon Code!'), 400); return FALSE; } $coupon = $this->coupon->is_coupon_code_exists($promocode); $orderDetails = $this->order->details($orderId, TRUE); if (empty($orderDetails)) { $this->response(array('error' => 'Invalid order index provided.'), 400); return FALSE; } $userDetails = $this->user->get_details_by_id($userId); if (empty($userDetails)) { $this->response(array('error' => 'Please provide valid user index!'), 400); return FALSE; } if ($this->order->is_valid_order_by_order_id_user_id($orderId, $userId) == FALSE) { $this->response(array('error' => 'Please provide valid user index and related order index!'), 400); return FALSE; } if (!$coupon) { $this->response(array('error' => 'Invalid promo code or promo code has expaired!!'), 400); return FALSE; } $ordercoupon = $this->coupon->is_coupon_code_valid_for_single($coupon); if ($ordercoupon) { $this->response(array('error' => 'Invalid promo code or promo code has expaired!!'), 400); return FALSE; } else { $orderIdArr = array(); foreach ($orderDetails as $k) { $orderIdArr[] = $k['orderId']; } /*if($this->coupon->is_coupon_recently_used($orderIdArr,$coupon->couponId)==TRUE){ $this->response(array('error' => 'Promo code has alrady used in your current session.'), 400); return FALSE; }*/ //pre($orderDetails);die; $ctotal = 0; foreach ($orderDetails as $k) { //pre($k);die; $ctotal += $k['subTotalAmount']; } if ($coupon->type == 'percentage') { $amt = $coupon->amount / 100 * $orderDetails[0]['subTotalAmount']; $amt1 = number_format($amt, 2, '.', ''); $data['couponAmount'] = substr($amt1, 0, -3); } elseif ($coupon->type == 'fix') { $data['couponAmount'] = $coupon->amount; } //pre($data);die; $tax = 0; $grandTotal = 0; $couponAmount = 0; $countryShortName = get_counry_code_from_lat_long($latitude, $longitude); //$countryShortName='IN'; if ($countryShortName == FALSE) { $this->response(array('error' => 'Please provide valid latitude and longitude!'), 400); return FALSE; } foreach ($orderDetails as $k) { if ($k['orderId'] == $orderId) { $suggestedCountryShortName = array('IN', 'KE'); if (!in_array($countryShortName, $suggestedCountryShortName)) { $countryShortName = $this->user->loged_in_user_shipping_country_code($userId); } $currentLocationTaxDetails = $this->product->get_tax_for_current_location($k['productId'], $countryShortName . '_tax'); $taxCol = $countryShortName . '_tax'; $taxPercentage = $currentLocationTaxDetails->{$taxCol}; $orderAmountBeforeTax = $k['subTotalAmount'] - $data['couponAmount']; $cTax = $orderAmountBeforeTax * $taxPercentage / 100; $orderAmount = $orderAmountBeforeTax + $cTax; $orderDataArr = array('taxAmount' => $cTax, 'discountAmount' => $data['couponAmount'], 'orderAmount' => $orderAmount); $this->order->update($orderDataArr, $k['orderId']); $this->order->tidiit_creat_order_coupon(array('orderId' => $k['orderId'], 'couponId' => $coupon->couponId, 'amount' => $data['couponAmount'])); $couponAmount += $data['couponAmount']; } else { $cTax = $k['taxAmount']; $orderAmount = $k['orderAmount']; $couponAmount += $k['discountAmount']; } $tax += $cTax; $grandTotal += $orderAmount; } $data['tax'] = number_format(round($tax, 0, PHP_ROUND_HALF_UP), 2); //$grandTotal=round($ctotal - $data['couponAmount']+round($tax,0,PHP_ROUND_HALF_UP),0,PHP_ROUND_HALF_UP); $data['grandTotal'] = number_format(round($grandTotal, 0, PHP_ROUND_HALF_UP), 2); $result['message'] = "Promo code has been applied successfully!"; $data['couponAmount'] = number_format(round($couponAmount, 0, PHP_ROUND_HALF_UP), 2); $result['content'] = $data; $result['tidiit_currency_simbol'] = get_currency_simble_from_lat_long($latitude, $longitude); success_response_after_post_get($result); } }