• Jean Claude

    (@darkhost)


    Dear PPOM Development Team,

    I am currently experiencing an issue with integrating product prices managed by PPOM fields into the Rank Math schema. The problem is that because in backend on single product the price is set to 0 because I use PPOM prices, the offer schema for Rank Math takes the price 0 and add it in the schema instead of adding actual price from PPOM.

    The Rank Math support team suggested using their filter:

    dd_filter('rank_math/snippet/rich_snippet_product_entity', function($entity) {
        $entity['offers']['price'] = 'PPOM-price'; // Change to actual value from PPOM
        return $entity;
    });

    However, I am struggling to fetch the PPOM product price dynamically. They said to get in touch with you guys and ask for help to edit the code to fetch the product price from PPOM.

    I have tried the following approaches in detail:

    1. Custom PHP Code: I created various functions to extract the PPOM price from product meta fields and used these functions to override the price in the Rank Math schema. Despite trying multiple variations and ensuring the functions fetched the correct meta keys, the price still consistently showed as “0” in the schema output.
    2. JavaScript Modifications: I tried to use JavaScript to dynamically update the Twitter meta tags and Rank Math schema after the page had fully loaded. This approach involved fetching the price from hidden input fields and then updating the corresponding meta tags. However, even after multiple iterations and debugging, the updated price did not reflect in the meta tags, and the schema still displayed “0”.
    3. WooCommerce Filters: I attempted to use WooCommerce filters such as woocommerce_product_get_price and woocommerce_product_get_regular_price to modify the product price dynamically. These filters worked for displaying the correct price on the product page, but unfortunately, they did not result in the updated price being used in the Rank Math schema or other meta tags.
    4. PPOM Hooks: I explored and implemented several PPOM hooks like ppom_after_ppom_fields, ppom_hooks_convert_price(), and others. I integrated these hooks with Rank Math’s schema filter to update the price after the PPOM fields were rendered. Despite all these attempts, the Rank Math schema continued to show a price of “0”.
    5. Direct Rank Math Filter Customizations: I directly modified the Rank Math schema using the rank_math/snippet/rich_snippet_product_entity filter as recommended. I combined it with PPOM-specific hooks and custom functions, but the price value remained incorrect. Even when manually assigning the fetched PPOM price, it would not reflect correctly.
    6. JavaScript Schema Updates: I also tried updating the Rank Math schema using JavaScript by finding the JSON-LD script on the page and modifying it in the browser. This method also failed, either due to conflicts with other scripts or due to browser restrictions on modifying structured data dynamically.

    Given these multiple failed attempts, I am reaching out to see if you could assist in providing the appropriate filter or method to fetch the correct product price from PPOM fields, so that I can successfully integrate it into the Rank Math schema.

    Any guidance or code examples you could provide would be greatly appreciated.

    You can see the schema for the products at: https://www.myboostpal.com

    Thank you!

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

  • You must be logged in to reply to this topic.