how to edit woocamrece schema

#461390
  • Resolved Alishahavi
    Rank Math free

    Hello

    how to edit Offers > Price Currency schema without change woocamrece Currency options settings ??

    for woocamrece product

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

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

    Rank Math uses the currency set in your WooCommerce options by default. To modify/set the currency, you can use and customize this filter:

    /**
     * Filter to change the product schema data.
     * @param array $entity Snippet Data
     * @return array
     */
    add_filter( "rank_math/snippet/rich_snippet_product_entity", function( $entity ) {
     return $entity;
    });

    The filter should be added to your active theme’s functions.php file. Here’s another way to apply the filter using the rankmath.php file:
    https://rankmath.com/kb/filters-hooks-api-developer/#adding-filters-and-hooks-in-rank-math-php

    Hope that helps.

    Thank you.

    thanks for helpful answer 🙂

    sorry , how to edit this code for change currency ??

    Should I replace the offer and currency variables with $entity?

    Hello,

    You can use the following code snippet to change the price currency:

    
    add_filter( 'rank_math/snippet/rich_snippet_product_entity', function( $entity ) {
        $entity['offers']['priceCurrency'] = 'EUR';
        return $entity;
    });
    

    Change the currency to the desired one if not Euros.

    Don’t hesitate to get in touch if you have any other questions.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

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

The ticket ‘how to edit woocamrece schema’ is closed to new replies.