Product price customization in Schema

#530266
  • Resolved Hamid Taherbakhsh
    Rank Math free

    I want to add a zero to the end of the product price in the WooCommerce schema, i.e. price *10
    Thank you for guiding me

    add_filter( ‘rank_math/snippet/rich_snippet_product_entity’, function( $entity ) {
    $entity[‘offers’][‘price’] = ‘؟’;
    return $entity;
    });

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

    Thank you for contacting Rank Math and bringing your concern to our attention.

    You can use the following filter on your site to multiply the price in your Product Schema with 10:

    add_filter( 'rank_math/snippet/rich_snippet_product_entity', function( $entity ) {
        if ( isset( $entity['offers'] ) ) {
    	    $updated_price =  $entity['offers']['price'];
    	    $entity['offers']['price'] = number_format((float)$updated_price * 10, 2, '.', '');
        }
        return $entity;
    } );
    

    It will only change the price on your Product Schema.

    Here is a guide you can follow to add the filter:
    https://rankmath.com/kb/wordpress-hooks-actions-filters/

    Let us know how it goes.

    Thank you.

    ​​​​​​​

    Excellent
    Thank you for your guidance. This code is working fine

    Hello,

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

    If you don’t mind me 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 do 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 ‘Product price customization in Schema’ is closed to new replies.