Price variable

#431288
  • Resolved Jean-baptiste
    Rank Math free

    Hello,

    I want to add the %wc_price% variable in the “price” part of a structured product data. However, the rank math variable adds the currency symbol (ex: €) before the price.

    In fact, I don’t want this symbol to appear, because I have an error message on the Google Search Console of my site: “Invalid price format in the “price” property (optional)”.

    Do you have a solution please?

    Thank you in advance,

    Sincerly,

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello,

    Thank you for contacting Rank Math for help with your custom product schema.

    I created a schema variable for price without currency symbol. Please use add the following code snippet to your child theme functions.php file and replace %wc_price% with %rm_price_nosymbol%

    
    add_action( 'rank_math/vars/register_extra_replacements', function(){
        rank_math_register_var_replacement(
            'rm_price_nosymbol',
            [
                'name'        => esc_html__( 'Product price without currency sign.', 'rank-math' ),
                'description' => esc_html__( 'Product price of the current product without currency sign', 'rank-math' ),
                'variable'    => 'rm_price_nosymbol',
                'example'     => 'rm_price_nosymbol_call_back()',
            ],
        'rm_price_nosymbol_call_back'
        );
    });
    function rm_price_nosymbol_call_back() {
        $product = wc_get_product();
        $price = $product->get_price();
        return $price;
    }
    

    Hope that helps. please let us know if you have questions.

    It working 🙂 Thank you !

    Good day

    Hello,

    We are super happy that we have addressed your concern. If you have any other questions in the future, know that we are here to help you.

    If you don’t mind us asking, could you please leave us a review (if you haven’t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post about your overall experience with Rank Math? We appreciate your time and patience.

    If you have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.

    Thank you.

Viewing 3 replies - 1 through 3 (of 3 total)

The ticket ‘Price variable’ is closed to new replies.