Created
November 23, 2019 07:08
-
-
Save dsebao/d9f025f82d0b044c8b24dcc5d06596bd to your computer and use it in GitHub Desktop.
Cambio de currency simbol (USD y $ dependiendo el tipo de listing)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Archivo dentro del plugin Realty Portal Listing | |
| // includes/property/library/ | |
| //Linea 434 | |
| public function get_price() { | |
| $price = trim( get_post_meta( $this->ID, 'price', true ) ); | |
| //Agregue un argumento mas en el rp_format_price que es el ID para que dentro de la funcion | |
| //capture que tipo de listing es y haga el cambio de USD y $ | |
| $price = ( preg_match( "/^([0-9]+)$/", $price ) ) ? rp_format_price( $price,true,$this->ID) : esc_html( $price ); | |
| return apply_filters( 'rp_get_price', $price ); | |
| } | |
| public function get_price_html() { | |
| if($this->get_price()): | |
| //Se agrego volcar en una clase el listing type | |
| $listing_type = get_the_terms( $this->ID,'listing_type'); | |
| $before_price = '<div class="property-price '.$listing_type[0]->name.'"><span class="before-price">' . esc_html( get_post_meta( $this->ID, 'before_price', true ) ) . '</span>'; | |
| $before_price = apply_filters( 'rp_before_get_price_html', $before_price ); | |
| $after_price = '<span class="after-price">' . esc_html( get_post_meta( $this->ID, 'after_price', true ) ) . '</span></div>'; | |
| $after_price = apply_filters( 'rp_after_get_price_html', $after_price ); | |
| return apply_filters( 'rp_get_price_html', $before_price . ' ' . $this->get_price() . ' ' . $after_price ); | |
| endif; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Archivo dentro del plugin Realty Portal Listing | |
| // includes/property/library/ | |
| //Linea 675 | |
| /** | |
| * This function get format price | |
| * EDIT: se agrego un argumento mas el post_id | |
| * @param $price | |
| * @param bool $html | |
| * | |
| * @return mixed|string|void | |
| */ | |
| function rp_format_price( $price, $html = true,$post_id = '') { | |
| $currency_code = RP_Property::get_setting( 'property_setting', 'property_currency', 'USD' ); | |
| //EDITADO, del ID pasado como argumento extraigo el tipo de listing que es y trasformo el currency simbol | |
| if($post_id !== ''){ | |
| $tax = get_the_terms($post_id,'listing_type'); | |
| if($tax[0]->name == 'Venta'){ | |
| $currency_symbol = 'U$D'; | |
| } else if($tax[0]->name == 'Alquiler') { | |
| $currency_symbol = '$'; | |
| } else { | |
| $currency_symbol = rp_currency_symbol( $currency_code ); | |
| } | |
| } else { | |
| $currency_symbol = rp_currency_symbol( $currency_code ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment