$initial_rating = ''; $client_id = Yii::app()->functions->getClientId(); if ($your_ratings = Yii::app()->functions->isClientRatingExist($merchant_id, $client_id)) { $initial_rating = $your_ratings['ratings']; } echo CHtml::hiddenField('initial_rating', $initial_rating); $has_reviews = false; if ($reviews = Yii::app()->functions->getReviews($client_id, $merchant_id)) { $has_reviews = true; } $merchant_address = $re_info['street'] . " " . $re_info['city'] . " " . $re_info['post_code']; $from_address = $_SESSION['kr_search_address']; /*dump($from_address); dump($merchant_address); dump($re_info['country_code']);*/ $miles = getDeliveryDistance2($from_address, $merchant_address, $re_info['country_code']); //dump($miles); $mt_delivery_miles = Yii::app()->functions->getOption("merchant_delivery_miles", $merchant_id); $merchant_distance_type = Yii::app()->functions->getOption("merchant_distance_type", $merchant_id); //dump($merchant_distance_type); $use_distance = 0; $unit_distance = Yii::t("default", "miles"); $use_distance1 = ''; $ft = false; $unit = "miles"; if (is_array($miles) && count($miles) >= 1) { if ($merchant_distance_type == "km") { $use_distance = str_replace(",", "", $miles['km']); $use_distance1 = $miles['km']; $unit_distance = Yii::t("default", "km"); $unit = "km";
public function reCheckDelivery($data = '', $mtid = '') { //dump($data); $mt_delivery_miles = Yii::app()->functions->getOption("merchant_delivery_miles", $mtid); $delivery_fee = Yii::app()->functions->getOption("merchant_delivery_charges", $mtid); //dump("delivery_fee=>".$delivery_fee); //dump($mt_delivery_miles); $shipping_enabled = Yii::app()->functions->getOption("shipping_enabled", $mtid); if ($shipping_enabled != 2) { return true; } //dump($shipping_enabled); if (is_numeric($mt_delivery_miles) || $shipping_enabled == 2) { $merchant_distance_type = Yii::app()->functions->getOption("merchant_distance_type", $mtid); //dump("unit=>".$merchant_distance_type); $delivery_address = $data['street']; $delivery_address .= " " . $data['city']; $delivery_address .= " " . $data['state']; $delivery_address .= " " . $data['zipcode']; $merchant_address = ''; $country_code = Yii::app()->functions->adminCountry(); if ($merchant_info = Yii::app()->functions->getMerchant($mtid)) { $merchant_address = $merchant_info['street']; $merchant_address .= " " . $merchant_info['city']; $merchant_address .= " " . $merchant_info['state']; $merchant_address .= " " . $merchant_info['post_code']; $country_code = $merchant_info['country_code']; } if (isset($data['address_book_id'])) { if ($address_book = Yii::app()->functions->getAddressBookByID($data['address_book_id'])) { $data['street'] = $address_book['street']; $data['city'] = $address_book['city']; $data['state'] = $address_book['state']; $data['zipcode'] = $address_book['zipcode']; $data['location_name'] = $address_book['location_name']; $delivery_address = $data['street']; $delivery_address .= " " . $data['city']; $delivery_address .= " " . $data['state']; $delivery_address .= " " . $data['zipcode']; } } if ($data['map_address_toogle'] == 2) { if (isset($data['map_address_lat']) && isset($data['map_address_lng'])) { $geo_res = geoCoding($data['map_address_lat'], $data['map_address_lng']); //dump($geo_res); $data['street'] = isset($geo_res['street_number']) ? $geo_res['street_number'] . " " : ''; $data['street'] .= isset($geo_res['street']) ? $geo_res['street'] . " " : ''; $data['street'] .= isset($geo_res['street2']) ? $geo_res['street2'] . " " : ''; $data['city'] = $geo_res['locality']; $data['state'] = $geo_res['admin_1']; $data['zipcode'] = isset($geo_res['postal_code']) ? $geo_res['postal_code'] : ''; $delivery_address = $data['street']; $delivery_address .= " " . $data['city']; $delivery_address .= " " . $data['state']; $delivery_address .= " " . $data['zipcode']; $country_code = $geo_res['country_code']; } } /*dump("delivery address =>".$delivery_address); dump("merchant address=>".$merchant_address); dump($country_code);*/ $miles = getDeliveryDistance2($delivery_address, $merchant_address, $country_code); //dump($miles); $use_distance1 = ''; $unit = ''; $ft = false; if (is_array($miles) && count($miles) >= 1) { if ($merchant_distance_type == "km") { $use_distance1 = $miles['km']; $unit = 'km'; } else { $use_distance1 = $miles['mi']; $unit = 'mi'; } if (preg_match("/ft/i", $miles['mi'])) { $use_distance1 = str_replace("ft", '', $miles['mi']); $unit = 'ft'; $ft = true; } } /*dump("use_distance1=>".$use_distance1); dump("Unit=>".$unit);*/ $is_ok_delivered = 1; if (is_numeric($mt_delivery_miles)) { if ($mt_delivery_miles >= $use_distance1) { $is_ok_delivered = 1; } else { $is_ok_delivered = 2; } if ($ft == TRUE) { $is_ok_delivered = 1; } } //dump($is_ok_delivered); if ($is_ok_delivered == 1) { $delivery_fee = $this->getDeliveryChargesByDistance($mtid, $use_distance1, $unit, $delivery_fee); /*dump($use_distance1); dump($unit); dump($delivery_fee);*/ $_SESSION['shipping_fee'] = $delivery_fee; return true; } else { return false; } } return true; }