• Our products are displayed in the EGP currency symbol in Google Rich Results, which is not our selling currency. Our selling currency is SAR (?.?). We reached out to the Google Help Community, and they said that the problem is that our visible content contains currency references such as ?.? (Saudi riyal symbol). However, the source code does not have this symbol.

    They proposed to mention the ISO 4217 currency code in one source code container with a price and without attachments, just like we have: 

    <p class="price"><span class="woocommerce-Price-amount amount"><bdi>302.00&nbsp;<span class="woocommerce-Price-currencySymbol">?.?</span></bdi></span> <small class="woocommerce-price-suffix">???? ???????</small></p>

    e.g.: <p>Price: <b>302 SAR</b> ?.?</p>

    I have already informed them that we have implemented the currency symbol ?.? (Saudi riyal symbol) using ?. ? codes. However, they advised us to try their solution. My question is, how can we implement this solution?

    Thanks

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

Viewing 1 replies (of 1 total)
  • Hi,

    To implement the solution suggested by Google and include the ISO 4217 currency code in your source code container, you can modify the way you display the price on your WooCommerce product pages. Here’s how you can do it:

    1. Modify Price Display:
      Locate the template file responsible for displaying the product price. This is usually the single-product/price.php file in your theme’s WooCommerce folder. If it doesn’t exist, you might need to create it.
    2. Edit the Template File:
      Open the price.php file in a code editor and modify it as follows:
       <?php
       /**
        * Single Product Price
        *
        * This template can be overridden by copying it to yourtheme/woocommerce/single-product/price.php.
        *
        * @package WooCommerce/Templates
        * @version 3.8.0
        */
    
       defined( 'ABSPATH' ) || exit;
    
       global $product;
    
       // Get the product price and currency symbol
       $price = wc_get_price_to_display( $product );
       $currency_symbol = get_woocommerce_currency_symbol();
    
       // Get the ISO 4217 currency code
       $currency_code = get_woocommerce_currency();
    
       // Display the price with currency code
       ?>
       <p class="price">
           <?php echo sprintf( __( 'Price: <b>%1$s %2$s</b> %3$s', 'woocommerce' ), $price, $currency_code, $currency_symbol ); ?>
       </p>

    In this modified template, we’re getting the price, currency symbol, and currency code separately and then displaying them in the desired format.

    1. Save and Test:
      Save the modified price.php file. Clear any caching if you’re using a caching plugin. Then, visit your WooCommerce product pages to see if the price is displayed in the format you want, with the ISO 4217 currency code included.

    By following these steps, you’re providing a clear association between the currency code and the displayed price, as requested by Google. This should help with displaying the correct currency symbol in Google Rich Results.

    Remember that template file locations and names might vary based on your theme, so adjust the path accordingly. If you’re not comfortable making these changes yourself, it’s recommended to seek assistance from a developer or someone familiar with WooCommerce customization.

Viewing 1 replies (of 1 total)
  • The topic ‘Change currency symbol in source code’ is closed to new replies.