We provide emailed quotes after an order is recieved in OpenCart. How can I add a field to show TBC instead of £0.00 in OpenCart. We use X-Shipping for our 4 delivery options:
Is this possible?
Here is the PHP code for the catalog side
<?php
class ModelShippingXshipping extends Model {
function getQuote($address) {
$this->load->language('shipping/xshipping');
$method_data = array();
$quote_data = array();
for($i=1;$i<=12;$i++)
{
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone_to_geo_zone WHERE geo_zone_id = '" . (int)$this->config->get('xshipping_geo_zone_id'.$i) . "' AND country_id = '" . (int)$address['country_id'] . "' AND (zone_id = '" . (int)$address['zone_id'] . "' OR zone_id = '0')");
if (!$this->config->get('xshipping_geo_zone_id'.$i)) {
$status = true;
} elseif ($query->num_rows) {
$status = true;
} else {
$status = false;
}
if (!$this->config->get('xshipping_status'.$i)) {
$status = false;
}
if (!$this->config->get('xshipping_name'.$i)) {
$status = false;
}
$shipping_cost=$this->config->get('xshipping_cost'.$i);
$free_shipping_cost=(float)$this->config->get('xshipping_free'.$i);
if(empty($free_shipping_cost))$free_shipping_cost=0;
if ($this->cart->getSubTotal() >= $free_shipping_cost && $free_shipping_cost!=0) {
$shipping_cost = 0;
}
if ($status) {
$quote_data['xshipping'.$i] = array(
'code' => 'xshipping'.'.xshipping'.$i,
'title' => $this->config->get('xshipping_name'.$i),
'cost' => $shipping_cost,
'tax_class_id' => $this->config->get('xshipping_tax_class_id'.$i),
'text' => $this->currency->format($this->tax->calculate($shipping_cost, $this->config->get('xshipping_tax_class_id'.$i), $this->config->get('config_tax')))
);
}
}
if(!$quote_data) return array();
$method_data = array(
'code' => 'xshipping',
'title' => $this->language->get('text_title'),
'quote' => $quote_data,
'sort_order' => $this->config->get('xshipping_sort_order'),
'error' => ''
);
return $method_data;
}
}
?>
Related
I have a school web app that has an online exam feature## Heading ##Students are given a number of times they can attempt the exam.
However, when a student attempts the exam two or more times and saves, the scores are duplicated in the database instead of being updated.
I will like that when a student attempts an exam again, the previous scores are overwritten or replaced not duplicated.
Controller:
public function save()
{
if ($this->input->server('REQUEST_METHOD') == 'POST') {
$total_rows = $this->input->post('total_rows');
if (!empty($total_rows)) {
$save_result = array();
foreach ($total_rows as $row_key => $row_value) {
if (($_POST['question_type_' . $row_value]) == "singlechoice") {
if (isset($_POST['radio' . $row_value])) {
$save_result[] = array(
'onlineexam_student_id' => $this->input->post('onlineexam_student_id'),
'onlineexam_question_id' => $this->input->post('question_id_' . $row_value),
'select_option' => $_POST['radio' . $row_value],
'attachment_name' => "",
'attachment_upload_name' => "",
);
}
} elseif (($_POST['question_type_' . $row_value]) == "true_false") {
# code...
if (isset($_POST['radio' . $row_value])) {
$save_result[] = array(
'onlineexam_student_id' => $this->input->post('onlineexam_student_id'),
'onlineexam_question_id' => $this->input->post('question_id_' . $row_value),
'select_option' => $_POST['radio' . $row_value],
'attachment_name' => "",
'attachment_upload_name' => "",
);
}
} elseif (($_POST['question_type_' . $row_value]) == "multichoice") {
# code...
if (isset($_POST['checkbox' . $row_value])) {
$save_result[] = array(
'onlineexam_student_id' => $this->input->post('onlineexam_student_id'),
'onlineexam_question_id' => $this->input->post('question_id_' . $row_value),
'select_option' => json_encode($_POST['checkbox' . $row_value]),
'attachment_name' => "",
'attachment_upload_name' => "",
);
}
} elseif (($_POST['question_type_' . $row_value]) == "descriptive") {
# code...
if (isset($_POST['answer' . $row_value]) || (isset($_FILES["attachment" . $row_value]) && !empty($_FILES["attachment" . $row_value]['name']))) {
$inst_array = array(
'onlineexam_student_id' => $this->input->post('onlineexam_student_id'),
'onlineexam_question_id' => $this->input->post('question_id_' . $row_value),
'select_option' => $_POST['answer' . $row_value],
);
$file_name = "";
$upload_file_name = "";
if (isset($_FILES["attachment" . $row_value]) && !empty($_FILES["attachment" . $row_value]['name'])) {
$file_name = $_FILES["attachment" . $row_value]["name"];
$fileInfo = pathinfo($_FILES["attachment" . $row_value]["name"]);
$upload_file_name = time() . uniqid(rand()) . '.' . $fileInfo['extension'];
move_uploaded_file($_FILES["attachment" . $row_value]["tmp_name"], "./uploads/onlinexam_images/" . $upload_file_name);
}
$inst_array['attachment_name'] = $file_name;
$inst_array['attachment_upload_name'] = $upload_file_name;
$save_result[] = $inst_array;
}
}
}
$this->onlineexamresult_model->add($save_result);
$this->onlineexam_model->updateExamResult($this->input->post('onlineexam_student_id'));
redirect('user/onlineexam', 'refresh');
}
} else {
}
}
model:
public function add($data_insert)
{
$this->db->trans_begin();
if (!empty($data_insert)) {
$this->db->insert_batch('onlineexam_student_results', $data_insert);
}
if ($this->db->trans_status() === false) {
$this->db->trans_rollback();
return false;
} else {
$this->db->trans_commit();
return true;
}
}
How would i disable 'Cash On Delivery' payment method in opencart 2.x checkout if the selected address is from a zone_id that i don't want
I don't know the specific variable to do the logic; I have tried adding the logic below but it does not work
if (($this->config->get('cod_geo_zone_id')) == 1736) {
$status = true;
} else {
$status = false;
}
The complete code is as below in: catalog\model\payment\cod.php
<?php
class ModelPaymentCOD extends Model {
public function getMethod($address, $total) {
$this->load->language('payment/cod');
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone_to_geo_zone WHERE geo_zone_id = '" . (int)$this->config->get('cod_geo_zone_id') . "' AND country_id = '" . (int)$address['country_id'] . "' AND (zone_id = '" . (int)$address['zone_id'] . "' OR zone_id = '0')");
if ($this->config->get('cod_total') > 0 && $this->config->get('cod_total') > $total) {
$status = false;
} elseif (!$this->config->get('cod_geo_zone_id')) {
$status = true;
} elseif ($query->num_rows) {
$status = true;
}
else {
$status = false;
}
if (($this->config->get('cod_geo_zone_id')) == 1736) {
$status = true;
} else {
$status = false;
}
/*$zonex = $address['zone_id'];
if ($zonex == 1736) {
$status = false;
}*/
$method_data = array();
if ($status) {
$method_data = array(
'code' => 'cod',
'title' => $this->language->get('text_title'),
'terms' => '',
'sort_order' => $this->config->get('cod_sort_order')
);
}
return $method_data;
}
}
Any help will be appreciated
I want to update my data but the column mark_obtained does not update. I don't know why, do I have something wrong in my code?
This is in my controller code :
function marks($exam_id = '', $class_id = '', $subject_exam_id = '')
{
if ($this->session->userdata('admin_login') != 1)
redirect(base_url(), 'refresh');
if ($this->input->post('operation') == 'selection') {
$page_data['exam_id'] = $this->input->post('exam_id');
$page_data['class_id'] = $this->input->post('class_id');
$page_data['subject_exam_id'] = $this->input->post('subject_exam_id');
if ($page_data['exam_id'] > 0 && $page_data['class_id'] > 0 && $page_data['subject_exam_id'] > 0) {
redirect(base_url() . 'index.php?admin/marks/' . $page_data['exam_id'] . '/' . $page_data['class_id'] . '/' . $page_data['subject_exam_id'], 'refresh');
} else {
$this->session->set_flashdata('mark_message', 'Choose exam, class and subject');
redirect(base_url() . 'index.php?admin/marks/', 'refresh');
}
}
if ($this->input->post('operation') == 'update') {
$students = $this->db->get_where('enroll' , array('class_id' => $class_id , 'year' => $running_year))->result_array();
foreach($students as $row) {
$data['mark_obtained'] = $this->input->post('mark_obtained_' . $row['student_id']);
$data['comment'] = $this->input->post('comment_' . $row['student_id']);
$this->db->where('mark_id', $this->input->post('mark_id_' . $row['student_id']));
$this->db->update('mark', array('mark_obtained' => $data['mark_obtained'] , 'comment' => $data['comment']));
}
$this->session->set_flashdata('flash_message' , get_phrase('data_updated'));
redirect(base_url() . 'index.php?admin/marks/' . $this->input->post('exam_id') . '/' . $this->input->post('class_id') . '/' . $this->input->post('subject_exam_id'), 'refresh');
}
$page_data['exam_id'] = $exam_id;
$page_data['class_id'] = $class_id;
$page_data['subject_exam_id'] = $subject_exam_id;
$page_data['page_info'] = 'Exam marks';
$page_data['page_name'] = 'marks';
$page_data['page_title'] = get_phrase('manage_exam_marks');
$this->load->view('backend/index', $page_data);
}
and this is my view :
<?php if($exam_id >0 && $class_id >0 && $subject_exam_id >0 ):?>
<?php
////CREATE THE MARK ENTRY ONLY IF NOT EXISTS////
$students = $this->db->get_where('enroll' , array(
'year' => $running_year , 'class_id' => $class_id
))->result_array();
foreach($students as $row):
$verify_data = array( 'exam_id' => $exam_id ,
'class_id' => $class_id ,
'subject_exam_id' => $subject_exam_id ,
'year' => $running_year,
'student_id' => $row['student_id']);
$query = $this->db->get_where('mark' , $verify_data);
if($query->num_rows() < 1)
$this->db->insert('mark' , $verify_data);
endforeach;
<input type="number" value="<?php echo $row2['mark_obtained'];?>" name="mark_obtained" class="form-control" >
Please help me solve the issue.
if ($this->input->post('operation') == 'update') {
$data['mark_obtained'] = $this->input->post('mark_obtained');
$data['comment'] = $this->input->post('comment');
$this->db->where('mark_id', $this->input->post('mark_id'));
$this->db->update('mark_obtained', $data); // ***MAYBE THIS WAS THE ISSUE****
$this->session->set_flashdata('flash_message' , get_phrase('data_updated'));
redirect(base_url() . 'index.php?admin/marks/' . $this->input->post('exam_id') . '/' . $this->input->post('class_id') . '/' . $this->input->post('subject_id'), 'refresh');
}
I pointed out to a line I corrected, which may have been the issue. You say the mark_obtained column was not beeing updated but you were actaully updating a column called mark in your code.
How can I modify the module so it takes only the articles from a specific category (ID = 35) of the articles?
The below code takes all the articles for the opencart module pavblog. I would like to change it so it does take only articles with category id of 35.
Please let me know how is it possible to change this code.
It was taken from catalog/controller/module folders in opencart.
<?php
class Controllermodulepavbloglatest extends Controller {
protected function index($setting) {
static $module = 0;
$this->load->model('pavblog/blog');
$this->load->model('catalog/product');
$this->load->model('tool/image');
$this->language->load('module/pavblog');
$this->data['button_cart'] = $this->language->get('button_cart');
if( !defined("_PAVBLOG_MEDIA_") ){
if (file_exists('catalog/view/theme/' . $this->config->get('config_template') . '/stylesheet/pavblog.css')) {
$this->document->addStyle('catalog/view/theme/' . $this->config->get('config_template') . '/stylesheet/pavblog.css');
} else {
$this->document->addStyle('catalog/view/theme/default/stylesheet/pavblog.css');
}
define("_PAVBLOG_MEDIA_",true);
}
$default = array(
'latest' => 1,
'limit' => 9
);
$this->data['width'] = $setting['width'];
$this->data['height'] = $setting['height'];
$this->data['cols'] = (int)$setting['cols'];
$this->data['tabs'] = array();
$data = array(
'sort' => 'b.`created`',
'order' => 'DESC',
'start' => 0,
'limit' => $setting['limit']
);
if( $setting['tabs'] == 'featured' ){
$data['featured'] = 1;
$blogs = $this->model_pavblog_blog->getListBlogs( $data );
$this->data['heading_title'] = $this->language->get('text_featured');
}elseif( $setting['tabs'] == 'mostviewed' ){
$data['sort'] = 'b.`hits`';
$blogs = $this->model_pavblog_blog->getListBlogs( $data );
$this->data['heading_title'] = $this->language->get('text_mostviewed');
}else {
$blogs = $this->model_pavblog_blog->getListBlogs( $data );
$this->data['heading_title'] = $this->language->get('text_latest');
}
$this->load->model('pavblog/category');
$users = $this->model_pavblog_category->getUsers();
foreach( $blogs as $key => $blog ){
if( $blogs[$key]['image'] ){
$blogs[$key]['thumb'] = $this->model_tool_image->resize($blog['image'], $setting['width'], $setting['height'] );
}else {
$blogs[$key]['thumb'] = '';
}
$blogs[$key]['description'] = html_entity_decode($blog['description'], ENT_QUOTES, 'UTF-8');
$blogs[$key]['author'] = isset($users[$blog['user_id']])?$users[$blog['user_id']]:$this->language->get('text_none_author');
$blogs[$key]['category_link'] = $this->url->link( 'pavblog/category', "path=".$blog['category_id'] );
$blogs[$key]['comment_count'] = 10;
$blogs[$key]['link'] = $this->url->link( 'pavblog/blog','id='.$blog['blog_id'] );
}
if( isset( $setting['description'][$this->config->get('config_language_id')] ) ) {
$this->data['message'] = html_entity_decode($setting['description'][$this->config->get('config_language_id')], ENT_QUOTES, 'UTF-8');
}else {
$this->data['message'] = '';
}
$this->data['blogs'] = $blogs;
$this->data['module'] = $module++;
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/pavbloglatest.tpl')) {
$this->template = $this->config->get('config_template') . '/template/module/pavbloglatest.tpl';
} else {
$this->template = 'default/template/module/pavbloglatest.tpl';
}
$this->render();
}
}
?>
The code you are referring to
<?php
/******************************************************
* #package Pav blog module for Opencart 1.5.x
* #version 1.0
* #author http://www.pavothemes.com
* #copyright Copyright (C) Feb 2013 PavoThemes.com <#emai:pavothemes#gmail.com>.All rights reserved.
* #license GNU General Public License version 2
*******************************************************/
/**
* class ModelPavblogBlog
*/
class ModelPavblogBlog extends Model {
public function __construct( $registry ){
parent::__construct( $registry );
$this->isInstalled();
}
/**
* Get Blog Information by Id
*/
public function getInfo( $id ){
$query = ' SELECT b.*,bd.title,bd.description,cd.title as category_title,bd.content FROM '
. DB_PREFIX . "pavblog_blog b LEFT JOIN "
. DB_PREFIX . "pavblog_blog_description bd ON b.blog_id=bd.blog_id LEFT JOIN "
. DB_PREFIX . 'pavblog_category c ON c.category_id=b.category_id LEFT JOIN '
. DB_PREFIX . 'pavblog_category_description cd ON (c.category_id=cd.category_id AND cd.language_id='.(int)$this->config->get('config_language_id').')' ;
$query .=" WHERE bd.language_id=".(int)$this->config->get('config_language_id');
$query .= " AND b.blog_id=".(int)$id;
$query = $this->db->query( $query );
$blog = $query->row;
return $blog;
}
/**
* update hit time after read
*/
public function updateHits( $id ){
$sql = ' UPDATE '.DB_PREFIX.'pavblog_blog SET hits=hits+1 WHERE blog_id='.(int)$id;
$this->db->query( $sql );
}
/**
* get list of blogs in same category of current
*/
public function getSameCategory( $category_id, $blog_id, $limit=10 ){
$data = array(
'filter_category_id' => $category_id,
'not_in' => $blog_id,
'sort' => 'created',
'order' => 'DESC',
'start' => 0,
'limit' => $limit
);
return $this->getListBlogs( $data );
}
/**
* get total blog
*/
public function getTotal( $data ){
$sql = ' SELECT count(b.blog_id) as total FROM '
. DB_PREFIX . "pavblog_blog b LEFT JOIN "
. DB_PREFIX . "pavblog_blog_description bd ON b.blog_id=bd.blog_id and bd.language_id=".(int)$this->config->get('config_language_id')." LEFT JOIN "
. DB_PREFIX . 'pavblog_category c ON c.category_id=b.category_id LEFT JOIN '
. DB_PREFIX . 'pavblog_category_description cd ON c.category_id=cd.category_id and cd.language_id='.(int)$this->config->get('config_language_id') ;
$sql .=" WHERE bd.language_id=".(int)$this->config->get('config_language_id');
if( isset($data['filter_category_id']) && $data['filter_category_id'] ){
$sql .= " AND b.category_id=".(int)$data['filter_category_id'];
}
if( isset($data['filter_tag']) && $data['filter_tag'] ){
$tmp = explode (",",$data['filter_tag'] );
if( count($tmp) > 1 ){
$t = array();
foreach( $tmp as $tag ){
$t[] = 'b.tags LIKE "%'.$this->db->escape( $tag ).'%"';
}
$sql .= ' AND '.implode(" OR ", $t ).' ';
}else {
$sql .= ' AND b.tags LIKE "%'.$this->db->escape( $data['filter_tag'] ).'%"';
}
}
$query = $this->db->query( $sql );
return $query->row['total'];
}
/**
* get list blogs
*/
public function getListBlogs( $data ){
$sql = ' SELECT b.*,bd.title,bd.description,cd.title as category_title FROM '
. DB_PREFIX . "pavblog_blog b LEFT JOIN "
. DB_PREFIX . "pavblog_blog_description bd ON b.blog_id=bd.blog_id and bd.language_id=".(int)$this->config->get('config_language_id')." LEFT JOIN "
. DB_PREFIX . 'pavblog_category c ON c.category_id=b.category_id LEFT JOIN '
. DB_PREFIX . 'pavblog_category_description cd ON c.category_id=cd.category_id and cd.language_id='.(int)$this->config->get('config_language_id') ;
$sql .=" WHERE b.status = '1' AND bd.language_id=".(int)$this->config->get('config_language_id');
if( isset($data['filter_category_id']) && $data['filter_category_id'] ){
$sql .= " AND b.category_id=".(int)$data['filter_category_id'];
}
if( isset($data['filter_tag']) && $data['filter_tag'] ){
$tmp = explode (",",$data['filter_tag'] );
if( count($tmp) > 1 ){
$t = array();
foreach( $tmp as $tag ){
$t[] = 'b.tags LIKE "%'.$this->db->escape( $tag ).'%"';
}
$sql .= ' AND '.implode(" OR ", $t ).' ';
}else {
$sql .= ' AND b.tags LIKE "%'.$this->db->escape( $data['filter_tag'] ).'%"';
}
}
if( isset($data['featured']) ){
$sql .= ' AND featured=1 ';
}
if( isset($data['not_in']) && $data['not_in'] ){
$sql .= ' AND b.blog_id NOT IN('.$data['not_in'].')';
}
$sort_data = array(
'bd.title',
'b.hits',
'b.`position`',
'b.`created`',
'b.created'
);
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
if ($data['sort'] == 'pd.name' || $data['sort'] == 'p.model') {
$sql .= " ORDER BY LCASE(" . $data['sort'] . ")";
}else {
$sql .= " ORDER BY " . $data['sort'];
}
} else {
$sql .= " ORDER BY b.`position`";
}
if (isset($data['order']) && ($data['order'] == 'DESC')) {
$sql .= " DESC, LCASE(bd.title) DESC";
} else {
$sql .= " ASC, LCASE(bd.title) ASC";
}
if (isset($data['start']) || isset($data['limit'])) {
if ($data['start'] < 0) {
$data['start'] = 0;
}
if ($data['limit'] < 1) {
$data['limit'] = 20;
}
$sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit'];
}
$query = $this->db->query( $sql );
$blogs = $query->rows;
return $blogs;
}
public function isInstalled() {
$sql = " SHOW TABLES LIKE '".DB_PREFIX."pavblog_blog'";
$query = $this->db->query( $sql );
if( count($query->rows) <=0 ){
$file = dirname(DIR_APPLICATION).'/admin/model/sample/module.php';
if( file_exists($file) ){
require_once( $file );
$sample = new ModelSampleModule( $this->registry );
$result = $sample->installSampleQuery( $this->config->get('config_template'),'pavblog', true );
}
return false;
}
return true;
}
public function getDefaultConfig(){
return array(
'children_columns' => '3',
'general_cwidth' => '250',
'general_cheight' => '250',
'general_lwidth'=> '620',
'general_lheight'=> '300',
'general_sheight'=> '250',
'general_swidth'=> '250',
'general_xwidth' => '80',
'general_xheight' => '80',
'cat_show_hits' => '1',
'cat_limit_leading_blog'=> '1',
'cat_limit_secondary_blog'=> '5',
'cat_leading_image_type'=> 'l',
'cat_secondary_image_type'=> 's',
'cat_show_title'=> '1',
'cat_show_image'=> '1',
'cat_show_author'=> '1',
'cat_show_category'=> '1',
'cat_show_created'=> '1',
'cat_show_readmore' => 1,
'cat_show_description' => '1',
'cat_show_comment_counter'=> '1',
'blog_image_type'=> 'l',
'blog_show_title'=> '1',
'blog_show_image'=> '1',
'blog_show_author'=> '1',
'blog_show_category'=> '1',
'blog_show_created'=> '1',
'blog_show_comment_counter'=> '1',
'blog_show_comment_form'=>'1',
'blog_show_hits' => 1,
'cat_columns_leading_blog'=> 1,
'cat_columns_leading_blogs'=> 1,
'cat_columns_secondary_blogs' => 2,
'comment_engine' => 'local',
'diquis_account' => 'pavothemes',
'facebook_appid' => '100858303516',
'facebook_width'=> '600',
'comment_limit'=> '10',
'auto_publish_comment'=>0,
'enable_recaptcha' => 1,
'recaptcha_public_key'=>'6LcoLd4SAAAAADoaLy7OEmzwjrf4w7bf-SnE_Hvj',
'recaptcha_private_key'=>'6LcoLd4SAAAAAE18DL_BUDi0vmL_aM0vkLPaE9Ob',
'rss_limit_item' => 12,
'keyword_listing_blogs_page'=>'blogs'
);
}
}
?>
Try changing:
$data = array(
'sort' => 'b.`created`',
'order' => 'DESC',
'start' => 0,
'limit' => $setting['limit']
);
to:
$data = array(
'filter_category_id' => 35,
'sort' => 'b.`created`',
'order' => 'DESC',
'start' => 0,
'limit' => $setting['limit']
);
I did some research on opencart and I think this should work. Initially, I didn't see the following code, which checks for a filter_category_id in the getListBlogs() function:
if( isset($data['filter_category_id']) && $data['filter_category_id'] ){
$sql .= " AND b.category_id=".(int)$data['filter_category_id'];
}
I have 0 experience in php coding, but I need to change this code to let show 1k, 2k, 3k etc..., here is is the full code:
if (!function_exists('get_theme_currency')) {
function get_theme_currency()
{
$currency = get_option('theme_currency_sign');
if (!empty($currency)) {
return $currency;
}
return __('$', 'framework');
}
if (!function_exists('get_property_price')) {
function get_property_price()
{
global $post;
$price_digits = doubleval(get_post_meta($post->ID, 'REAL_HOMES_property_price', true));
if ($price_digits) {
$currency = get_theme_currency();
$price_post_fix = get_post_meta($post->ID, 'REAL_HOMES_property_price_postfix', true);
$decimals = intval(get_option('theme_decimals'));
$decimal_point = get_option('theme_dec_point');
$thousands_separator = get_option('theme_thousands_sep');
$currency_position = get_option('theme_currency_position');
$formatted_price = number_format($price_digits, $decimals, $decimal_point, $thousands_separator);
if ($currency_position == 'after') {
return $formatted_price . $currency . ' ' . $price_post_fix;
} else {
return $currency . $formatted_price . ' ' . $price_post_fix;
}
} else {
return __('NA', 'framework');
}
}
if (!function_exists('property_price')) {
function property_price()
{
echo get_property_price();
}
if (!function_exists('get_custom_price')) {
function get_custom_price($amount)
{
$amount = doubleval($amount);
if ($amount) {
$currency = get_theme_currency();
$decimals = intval(get_option('theme_decimals'));
$decimal_point = get_option('theme_dec_point');
$thousands_separator = get_option('theme_thousands_sep');
$currency_position = get_option('theme_currency_position');
$formatted_price = number_format($amount, $decimals, $decimal_point, $thousands_separator);
if ($currency_position == 'after') {
return $formatted_price . $currency;
} else {
return $currency . $formatted_price;
}
} else {
return __('NA', 'framework');
}
}
if (!function_exists('advance_location_options')) {
function advance_location_options($taxonomy_name)
{
$taxonomy_terms = get_terms($taxonomy_name, array(
'hide_empty' => false,
'parent' => 0
));
$searched_term = '';
if ($taxonomy_name == 'property-city') {
if (!empty($_GET['location'])) {
$searched_term = $_GET['location'];
}
}
generate_hirarchical_options($taxonomy_name, $taxonomy_terms, $searched_term);
if ($searched_term == 'any' || empty($searched_term)) {
echo '<option value="any" selected="selected">' . __('Any', 'framework') . '</option>';
} else {
echo '<option value="any">' . __('Any', 'framework') . '</option>';
}
}
if (!function_exists('min_prices_list')) {
function min_prices_list()
{
$min_price_array = array(
1000,
5000,
10000,
50000,
100000,
200000,
300000,
400000,
500000,
600000,
700000,
800000,
900000,
1000000,
1500000,
2000000,
2500000,
5000000
);
$minimum_price_values = get_option('theme_minimum_price_values');
if (!empty($minimum_price_values)) {
$min_prices_string_array = explode(',', $minimum_price_values);
if (is_array($min_prices_string_array) && !empty($min_prices_string_array)) {
$new_min_prices_array = array();
foreach ($min_prices_string_array as $string_price) {
$integer_price = doubleval($string_price);
if ($integer_price > 1) {
$new_min_prices_array[] = $integer_price;
}
}
if (!empty($new_min_prices_array)) {
$min_price_array = $new_min_prices_array;
}
}
}
$minimum_price = '';
if (isset($_GET['min-price'])) {
$minimum_price = doubleval($_GET['min-price']);
}
if (!empty($min_price_array)) {
foreach ($min_price_array as $price) {
if ($minimum_price == $price) {
echo '<option value="' . $price . '" selected="selected">' . get_custom_price($price) . '</option>';
} else {
echo '<option value="' . $price . '">' . get_custom_price($price) . '</option>';
}
}
}
if ($minimum_price == 'any' || empty($minimum_price)) {
echo '<option value="any" selected="selected">' . __('Any', 'framework') . '</option>';
} else {
echo '<option value="any">' . __('Any', 'framework') . '</option>';
}
}
if (!function_exists('max_prices_list')) {
function max_prices_list()
{
$max_price_array = array(
5000,
10000,
50000,
100000,
200000,
300000,
400000,
500000,
600000,
700000,
800000,
900000,
1000000,
1500000,
2000000,
2500000,
5000000,
10000000
);
$maximum_price_values = get_option('theme_maximum_price_values');
if (!empty($maximum_price_values)) {
$max_prices_string_array = explode(',', $maximum_price_values);
if (is_array($max_prices_string_array) && !empty($max_prices_string_array)) {
$new_max_prices_array = array();
foreach ($max_prices_string_array as $string_price) {
$integer_price = doubleval($string_price);
if ($integer_price > 1) {
$new_max_prices_array[] = $integer_price;
}
}
if (!empty($new_max_prices_array)) {
$max_price_array = $new_max_prices_array;
}
}
}
$maximum_price = '';
if (isset($_GET['max-price'])) {
$maximum_price = doubleval($_GET['max-price']);
}
if (!empty($max_price_array)) {
foreach ($max_price_array as $price) {
if ($maximum_price == $price) {
echo '<option value="' . $price . '" selected="selected">' . get_custom_price($price) . '</option>';
} else {
echo '<option value="' . $price . '">' . get_custom_price($price) . '</option>';
}
}
}
if ($maximum_price == 'any' || empty($maximum_price)) {
echo '<option value="any" selected="selected">' . __('Any', 'framework') . '</option>';
} else {
echo '<option value="any">' . __('Any', 'framework') . '</option>';
}
}
Here is the cod Andy ask me to find, I hope this is the one:
if( isset($_GET['min-price']) && ($_GET['min-price'] != 'any') && isset($_GET['max-price']) && ($_GET['max-price'] != 'any') ){
$min_price = doubleval($_GET['min-price']);
$max_price = doubleval($_GET['max-price']);
if( $min_price >= 0 && $max_price > $min_price ){
$meta_query[] = array(
'key' => 'REAL_HOMES_property_price',
'value' => array( $min_price, $max_price ),
'type' => 'NUMERIC',
'compare' => 'BETWEEN'
);
}
}elseif( isset($_GET['min-price']) && ($_GET['min-price'] != 'any') ){
$min_price = doubleval($_GET['min-price']);
if( $min_price > 0 ){
$meta_query[] = array(
'key' => 'REAL_HOMES_property_price',
'value' => $min_price,
'type' => 'NUMERIC',
'compare' => '>='
);
}
}elseif( isset($_GET['max-price']) && ($_GET['max-price'] != 'any') ){
$max_price = doubleval($_GET['max-price']);
if( $max_price > 0 ){
$meta_query[] = array(
'key' => 'REAL_HOMES_property_price',
'value' => $max_price,
'type' => 'NUMERIC',
'compare' => '<='
);
}
}
if( isset($_GET['min-area']) && !empty($_GET['min-area']) && isset($_GET['max-area']) && !empty($_GET['max-area']) ){
$min_area = intval($_GET['min-area']);
$max_area = intval($_GET['max-area']);
if( $min_area >= 0 && $max_area > $min_area ){
$meta_query[] = array(
'key' => 'REAL_HOMES_property_size',
'value' => array( $min_area, $max_area ),
'type' => 'NUMERIC',
'compare' => 'BETWEEN'
);
}
}elseif( isset($_GET['min-area']) && !empty($_GET['min-area']) ){
$min_area = intval($_GET['min-area']);
if( $min_area > 0 ){
$meta_query[] = array(
'key' => 'REAL_HOMES_property_size',
'value' => $min_area,
'type' => 'NUMERIC',
'compare' => '>='
);
}
}elseif( isset($_GET['max-area']) && !empty($_GET['max-area']) ){
$max_area = intval($_GET['max-area']);
if( $max_area > 0 ){
$meta_query[] = array(
'key' => 'REAL_HOMES_property_size',
'value' => $max_area,
'type' => 'NUMERIC',
'compare' => '<='
);
}
}
Here is another 2 more codes I found that rendering this dropdown price
$('#select-min-price,#select-max-price').change(function(obj, e){
var min_text_val = $('#select-min-price').val();
var min_int_val = (isNaN(min_text_val))?0:parseInt(min_text_val);
var max_text_val = $('#select-max-price').val();
var max_int_val = (isNaN(max_text_val))?0:parseInt(max_text_val);
if( (min_int_val >= max_int_val) && (min_int_val != 0) && (max_int_val != 0)){
$('#select-max-price_input,#select-min-price_input').css('outline','2px solid red');
}else{
$('#select-max-price_input,#select-min-price_input').css('outline','none');
}
});
$('#min-area,#max-area').change(function(obj, e){
var min_text_val = $('#min-area').val();
var min_int_val = (isNaN(min_text_val))?0:parseInt(min_text_val);
var max_text_val = $('#max-area').val();
var max_int_val = (isNaN(max_text_val))?0:parseInt(max_text_val);
if( (min_int_val >= max_int_val) && (min_int_val != 0) && (max_int_val != 0)){
$('#min-area,#max-area').css('outline','2px solid red');
}else{
$('#min-area,#max-area').css('outline','none');
}
});
I got this code from WordPress theme called Real Homes, in the settings I can only put 1000, I tried to make it 1K, it disappeared from the dropdown select list.
Do I have to change the whole code, or I have to replace it.
Thanks in advance