Stamped.IO integration

#50895
  • Resolved peeyoosh kumar
    Rank Math pro

    Hello:

    Pratik from your support team helped us in adding custom code using code snippet to get “aggregate rating” and “review” errors fixed earlier on this thread here : https://support.rankmath.com/ticket/stamped-aggregate-rating-review-error/.

    Although we moved from standard theme to Oxygen builder and during transition missed to copy the code snipped which was provided.

    We are extremely sorry to bother again for the same, but can you please help by sharing the code again.

    Regards

Viewing 15 replies - 1 through 15 (of 16 total)
  • Hello:

    To update i was able to find the code snippet but i am unable to find the function which should enclose it. Please help.

    $stampedDBData = get_post_meta( $post->ID, 'stamped_io_product_reviews_new', true );
              if ( ! empty( $stampedDBData['rating'] ) ) {
                       $entity['aggregateRating'] = [
                                 '@type' => 'AggregateRating',
                                 'ratingValue' => $stampedDBData['rating'],
                                 'bestRating' => 5,
                                 'ratingCount' => $stampedDBData['count'],
                                 'reviewCount' => $stampedDBData['count'],

    Hello,

    Thank you for contacting Rank Math today.

    Allow us to consult about the specific code used to resolve the issue and we will get back to you.

    Looking forward to helping you. Thank you.

    ​​​​​​

    Hello,

    Please use following filter code:

    
    add_filter( 'rank_math/snippet/rich_snippet_product_entity', function( $entity ) {
    	$stampedDBData = get_post_meta( $post->ID, 'stamped_io_product_reviews_new', true );
    	if ( ! empty( $stampedDBData['rating'] ) ) {
    		$entity['aggregateRating'] = [
    			'@type' => 'AggregateRating',
    			'ratingValue' => $stampedDBData['rating'],
    			'bestRating' => 5,
    			'ratingCount' => $stampedDBData['count'],
    			'reviewCount' => $stampedDBData['count'],
    		]
    	}
    	return $entity;
    });
    

    I hope that helps.

    Hi Pratik:

    Thanks a ton for your help. Appreciate it.

    Although when we are using the same in code snippet it says for line 11
    “Parse error : syntax error, unexpected ‘}’, expecting ‘;’ on line 11

    Please suggest. Sorry i am not a developer so i have no clue on this.

    Hello,

    I just checked the code again, it should work fine. Please try adding the code in functions.php file before the closing PHP tag i.e ?>

    I hope that helps.

    Hello Pratik:

    I am sorry, but since we are using Oxygen we do not have an option to use Themefunctions.php since there is no theme.

    We can only add the code using code snippet plugin and in that it gives the same error as mentioned earlier.

    please help.

    Regards

    Hello,

    Thanks for getting in touch with us today.

    We would be happy to help in this. Please edit the first post on this ticket and include your WP logins in the designated Sensitive Data section.
    Sensitive Data Section

    It is completely secure and only our support staff has access to that section. If you want, you can use the below plugin to generate a temporary login URL to your website and share that with us instead:

    https://wordpress.org/plugins/temporary-login-without-password/

    You can use the above plugin in conjunction with the WP Security Audit Log to monitor what changes our staff might make on your website (if any):

    https://wordpress.org/plugins/wp-security-audit-log/

    We really look forward to helping you.

    Hello,

    I have updated the sensitive data as requested. Can you please check further?

    Thank you.

    Todd
    Rank Math free

    Hi,

    Every website has a theme and every theme has a functions.php file.

    Yours is no different.

    I have added the code for you and here’s a screenshot for reference:
    null

    Hope that helps.

    Hello:

    I am not sure if the edit has come into effect since we are still getting the same errors in Google Structure data.

    aggregateRating
    The aggregateRating field is recommended. Please provide a value if available.
    warningreview
    The review field is recommended. Please provide a value if available.

    Regards

    Hello,

    Thank you for contacting Rank Math today.

    The changes made on the theme don’t seem to be taking effect on the frontend.
    I’ve just tried to install the Health check and Troubleshooting plugin to test the changes on a different theme with caching plugins disabled but this seems to have broken your site.
    Please login to your site via FTP and rename the Health check & troubleshooting folder on your wp-content/plugins directory to restore your site.

    Looking forward to helping you. Thank you.

    ​​​​​​

    I have renamed the folder and added a _backup to the name.

    As i mentioned earlier, theme is being disabled with Oxygen builder been running on site. So any changes made in theme functions.php does not come into effect. For the same reason we are using Code Snippet plugin to put any code snippet we wish to run instead of themefunctions.php.

    I would request not to install any plugin on the site since it is a live site and we loose business if it goes down.

    Regards

    Hello,

    Thank you for contacting Rank Math today.

    I’ve modified the code on the snippet plugin to the following, could you please check if this is working as expected:

    add_filter( 'rank_math/snippet/rich_snippet_product_entity', function( $entity ) {
    	global $product;
    	$stampedDBData = get_post_meta( $product->get_id(), 'stamped_io_product_reviews_new', true );
    	if ( $product->is_type( 'variable' )) {
    		$variations = $product->get_available_variations();
    		foreach ( $variations as $key => $variation ) {
    			$entity['offers'][ $key ]['gtin14'] = get_post_meta( $variation['variation_id'], '_wpm_gtin_code', true );
    		}
    	} else {
    		$entity['gtin14'] = $product->get_meta( '_wpm_gtin_code' );
    		$entity['aggregateRating'] = [
    			'@type' => 'AggregateRating',
    			'ratingValue' => $stampedDBData['rating'],
    			'bestRating' => 5,
    			'ratingCount' => $stampedDBData['count'],
    			'reviewCount' => $stampedDBData['count'],
    		];
    	}
    
    	return $entity;
    });

    Looking forward to helping you. Thank you.

    ​​​​​​

    Hello:

    It does work for simple products. But for variable products it gives the same error as earlier.

    Regards

    Hello,

    I have updated the sensitive data as requested. Can you please check further?

    Thank you.

    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 15 replies - 1 through 15 (of 16 total)

The ticket ‘Stamped.IO integration’ is closed to new replies.