• Resolved high8sky

    (@high8sky)


    Thumbnails and titles were loaded normally, but the price information did not follow.

    How do I get the price?

    • This topic was modified 6 years, 2 months ago by high8sky.

    The page I need help with: [log in to see the link]

Viewing 15 replies - 1 through 15 (of 15 total)
  • Plugin Author Hector Cabrera

    (@hcabrera)

    Hi @high8sky,

    The WPP widget doesn’t have any feature that allows it to display pricing information out of the box. Displaying additional info (like the pricing information you’re talking about) requires coding that information into the widget yourself (or ask your developer to implement it for you). This might help: wpp_parse_custom_content_tags.

    Thread Starter high8sky

    (@high8sky)

    I do not know how to change the php language very well. Could you help me?

    The function to print the price in my theme is

    $price = floatval ( get_post_meta(get_the_ID(), ‘property_price’, true) );
    $price_label = esc_html ( get_post_meta(get_the_ID(), ‘property_label’, true) );
    $price = wpestate_show_price(get_the_ID(),$wpestate_currency,$where_currency,1);
    $thumb_id = get_post_thumbnail_id();
    $link = esc_url ( get_permalink());
    $title = get_the_title();

    $display.=’</span>
    <span class=widget_latest_price>’. $price.'</span>
    </div>’ ;
    $display.='</div>’;

    Could you tell me how to handle this?

    Plugin Author Hector Cabrera

    (@hcabrera)

    I’m going to need to see a bit more of code to help you out. For example, where are these variables coming from?: $wpestate_currency, $where_currency.

    By the way, from your code it seems that these two lines if code aren’t necessary:

    $price = floatval ( get_post_meta(get_the_ID(), ‘property_price’, true) );
    $price_label = esc_html ( get_post_meta(get_the_ID(), ‘property_label’, true) );
    Thread Starter high8sky

    (@high8sky)

    http://help.wpresidence.net/article/technical-how-to-default-property-fields/

    It is a document provided by theme developers.

    Is this enough information?

    Thread Starter high8sky

    (@high8sky)

    ///////////////////////////////////////////////////////////////////////////////////////////////////////////
    ///  Property details  function
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////
    if( !function_exists('details_estate_box') ):
    
    function details_estate_box($post) {
        global $post;
        wp_nonce_field(plugin_basename(__FILE__), 'estate_property_noncename');
        
        $mypost             =   $post->ID;
        print'            
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
            <td width="33%" valign="top" align="left">
                <p class="meta-options">
                <label for="property_price">'.esc_html__('Price: ','wpresidence-core').'</label><br />
                <input type="text" id="property_price" size="40" name="property_price" value="' . esc_html(get_post_meta($mypost, 'property_price', true)) . '">
                </p>
            </td>
    • This reply was modified 6 years, 2 months ago by high8sky.
    • This reply was modified 6 years, 2 months ago by high8sky.
    Plugin Author Hector Cabrera

    (@hcabrera)

    Alright, thanks for sharing this additional info. I guess that’s a good starting point.

    Are you using the WordPress Popular Posts widget on your sidebar? If so, could you please share screenshots of its settings?

    Thread Starter high8sky

    (@high8sky)

    Plugin Author Hector Cabrera

    (@hcabrera)

    Thanks for the screenshots, @high8sky.

    I see you already added a {price} tag to your HTML so please try adding this to your theme’s functions.php file:

    /**
     * Parses custom content tags in WordPress Popular Posts.
     *
     * @param  string  $html    The HTML markup from the plugin.
     * @param  integer $post_id The post/page ID.
     * @return string
     */
    function wpp_parse_tags_in_popular_posts( $html, $post_id ){
    
        // Replace custom content tag {price} with actual price
        if ( false !== strpos($html, '{price}') ) {
            // Get price
            $price = esc_html(get_post_meta($post_id, 'property_price', true));
            $price_label = esc_html(get_post_meta($post_id, 'property_label', true));
    
            // Replace {price} with the actual price
            $html = str_replace('{price}', $price . $price_label, $html);
        }
    
        return $html;
    }
    add_filter("wpp_parse_custom_content_tags", "wpp_parse_tags_in_popular_posts", 10, 2);
    Thread Starter high8sky

    (@high8sky)

    Thank you. Works perfectly. However, there are three types of price output. Before Price / price / after price There is an output variable. Is it possible to print this part as well?

    “1000 / 10” This should be output.
    (before) / (price)

    https://www.xn--3v0bs6vzvense83w.com/wp-content/uploads/2016/11/1111.jpg

            <td width="33%" valign="top" align="left">
                <p class="meta-options">
                <label for="property_label">'.esc_html__('After Price Label(*for example "per month"): ','wpresidence-core').'</label><br />
                <input type="text" id="property_label" size="40" name="property_label" value="' . esc_html(get_post_meta($mypost, 'property_label', true)) . '">
                </p>
            </td>
        </tr>
        <tr>
            <td width="33%" valign="top" align="left">
                <p class="meta-options">
                <label for="property_label_before">'.esc_html__('Before Price Label(*for example "per month"): ','wpresidence-core').'</label><br />
                <input type="text" id="property_label_before" size="40" name="property_label_before" value="' . esc_html(get_post_meta($mypost, 'property_label_before', true)) . '">
                </p>
            </td>
        </tr>
    Thread Starter high8sky

    (@high8sky)

    In addition, there should be a thousand unit separation.

    Plugin Author Hector Cabrera

    (@hcabrera)

    How about this?

    /**
     * Parses custom content tags in WordPress Popular Posts.
     *
     * @param  string  $html    The HTML markup from the plugin.
     * @param  integer $post_id The post/page ID.
     * @return string
     */
    function wpp_parse_tags_in_popular_posts( $html, $post_id ){
    
        // Replace custom content tag {price} with actual price
        if ( false !== strpos($html, '{price}') ) {
            // Get price
            $price = esc_html(get_post_meta($post_id, 'property_price', true));
            $price_label_before = esc_html(get_post_meta($post_id, 'property_label_before', true));
            $price_label = esc_html(get_post_meta($post_id, 'property_label', true));
    
            // Replace {price} with the actual price
            $html = str_replace('{price}', $price_label_before . ' / ' .  number_format_i18n($price) . $price_label, $html);
        }
    
        return $html;
    }
    add_filter("wpp_parse_custom_content_tags", "wpp_parse_tags_in_popular_posts", 10, 2);
    Thread Starter high8sky

    (@high8sky)

    you are the best. Last but not least, please let us know.

    2000 /80 -> 2000 / 80

    https://www.xn--3v0bs6vzvense83w.com/wp-content/uploads/2016/11/1231231.jpg

    Plugin Author Hector Cabrera

    (@hcabrera)

    There’s already a blank space after the /:

    
    $html = str_replace('{price}', $price_label_before . ' / ' . number_format_i18n($price) . $price_label, $html);
    

    Not sure why it isn’t showing like that on your sidebar.

    Thread Starter high8sky

    (@high8sky)

    Resolved. Thank you.

    I wonder if I can ask for personal work.

    Plugin Author Hector Cabrera

    (@hcabrera)

    Yes @high8sky, I’m available for freelance dev work as well. Feel free to get in touch whenever you need help.

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘I want to get pricing information.’ is closed to new replies.