Title: Codes in functions.php not working
Last modified: June 9, 2022

---

# Codes in functions.php not working

 *  Resolved [hector0371](https://wordpress.org/support/users/hector0371/)
 * (@hector0371)
 * [4 years ago](https://wordpress.org/support/topic/codes-in-functions-php-not-working/)
 * I`ve been working on a multi-site wordpress, and I`m inserting some codes into
   functions.php in my activated child theme to make some customized features. Yet
   when I saved the file and refresh the page, nothing happened. The codes are listed
   below:
 *     ```
       <?php
       // Add custom Theme Functions here<?php
       // Exit if accessed directly
       if ( !defined( 'ABSPATH' ) ) exit;
   
       // BEGIN ENQUEUE PARENT ACTION
       // AUTO GENERATED - Do not modify or remove comment markers above or below:
   
       if ( !function_exists( 'chld_thm_cfg_locale_css' ) ):
           function chld_thm_cfg_locale_css( $uri ){
               if ( empty( $uri ) && is_rtl() && file_exists( get_template_directory() . '/rtl.css' ) )
                   $uri = get_template_directory_uri() . '/rtl.css';
               return $uri;
           }
       endif;
       add_filter( 'locale_stylesheet_uri', 'chld_thm_cfg_locale_css' );
   
       // END ENQUEUE PARENT ACTION
   
       /**
       * Change a currency symbol
       * 
       }
   
       add_filter('woocommerce_currency_symbol', 'change_existing_currency_symbol', 10, 2);
   
       function change_existing_currency_symbol( $currency_symbol, $currency ) {
   
       switch( $currency ) {
       case 'HeartToken': $currency_symbol = '$#￥' ; break ;//'$img'; break;
   
       }
       return $currency_symbol;
       }
   
       //   to child php functions
   
       /*
        * @snippet       Alter Product Pricing Part 1 - WooCommerce Product
        * @how-to        Get CustomizeWoo.com FREE
        * @author        Rodolfo Melogli
        * @compatible    WooCommerce 4.1
        * @donate $9     https://businessbloomer.com/bloomer-armada/
        */
   
       add_filter( 'woocommerce_get_price_html', 'bbloomer_alter_price_display', 100, 2 );
   
       function bbloomer_alter_price_display( $price_html, $product ) {
   
           // ONLY ON FRONTEND
          // if ( is_admin() ) return $price_html;
   
           // ONLY IF PRICE NOT NULL
          // if ( '' === $product->get_price() ) return $price_html;
   
           // IF CUSTOMER LOGGED IN, make every item price=1
           if ( wc_current_user_has_role( 'vendor') || wc_current_user_has_role( 'subscriber' )||wc_current_user_has_role( 'Super Admin' ) ) {
               $orig_price = '';//wc_get_price_to_display( $product );
               $price_html = '';//wc_price( $orig_price * 0.80 );
           }
   
           return $price_html;
   
       }
   
       /**
        * @snippet       Alter Product Pricing Part 2 - WooCommerce Cart/Checkout
        * @how-to        Get CustomizeWoo.com FREE
        * @author        Rodolfo Melogli
        * @compatible    WooCommerce 4.1
        * @donate $9     https://businessbloomer.com/bloomer-armada/
        */
   
       add_action( 'woocommerce_before_calculate_totals', 'bbloomer_alter_price_cart', 100 );
   
       function bbloomer_alter_price_cart( $cart ) {
   
   
   
          // if ( did_action( 'woocommerce_before_calculate_totals' ) >= 2 ) return;
   
           // IF CUSTOMER NOT LOGGED IN, DONT APPLY DISCOUNT
          // if ( ! wc_current_user_has_role( 'customer' ) ) return;
   
           // LOOP THROUGH CART ITEMS & each item price =1
           foreach ( $cart->get_cart() as $cart_item_key => $cart_item ) {
               $product = $cart_item['data'];
               $price = $product->get_price();
               $cart_item['data']->set_price(1); //set_price( $price * 0.80 );
           }
       }
       ?>
       ```
   
 * Can anyone tell me what`s the problem here?

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

 *  [Igor H](https://wordpress.org/support/users/ihereira/)
 * (@ihereira)
 * [4 years ago](https://wordpress.org/support/topic/codes-in-functions-php-not-working/#post-15724750)
 * Hello,
 * Please note that our support for custom code is really limited in our forum, 
   our support is oriented to clarify general questions or really specific lines
   of code if applicable.
 * For adding custom code into your site you can use [Code Snippets](https://wordpress.org/plugins/code-snippets/)
   to add custom PHP code into your site without directly accessing the functions.
   php file. Here is an [article](https://www.wpbeginner.com/plugins/how-to-easily-add-custom-code-in-wordpress-without-breaking-your-site/)
   that explains how to use the Code Snippets plugin.
 * Let us know if this worked for you.
 *  Thread Starter [hector0371](https://wordpress.org/support/users/hector0371/)
 * (@hector0371)
 * [4 years ago](https://wordpress.org/support/topic/codes-in-functions-php-not-working/#post-15726216)
 * I have tried code snippets, and it wont work either. By the way,I have been getting
   this “support is limited” reply these days while I saw other similar topics posted
   and answered. I am really getting confused now.
 *  [Daniel Munene N.](https://wordpress.org/support/users/danndumia/)
 * (@danndumia)
 * [4 years ago](https://wordpress.org/support/topic/codes-in-functions-php-not-working/#post-15726448)
 * Hey [@hector0371](https://wordpress.org/support/users/hector0371/)
 * I understand that the changes to your function.php are not reflected.
 * Could you try removing the PHP closing tag `?>` and see if it works.
 * Thanks
 *  [Rynald0s](https://wordpress.org/support/users/rynald0s/)
 * (@rynald0s)
 * Automattic Happiness Engineer
 * [4 years ago](https://wordpress.org/support/topic/codes-in-functions-php-not-working/#post-15726595)
 * Hi [@hector0371](https://wordpress.org/support/users/hector0371/).
 * > By the way,I have been getting this “support is limited” reply these days while
   > I saw other similar topics posted and answered. I am really getting confused
   > now.
 * As per the [Guide to the WooCommerce forum](https://wordpress.org/support/topic/guide-to-the-woocommerce-forum/),
   we will try to help with basic customization (CSS and PHP), but this will mostly
   consist out of guiding you to the right place for finding help. This forum is
   mostly focused on resolving issues with core configuration and its intended functionality.
 * With that said, Code snippets is very much multisite compatible, so the problem
   wouldn’t be there.
 * In regard to nothing happening after saving your changes, do keep in mind that
   each function outputs in a different area on your site — the currency symbol 
   change will be individual product and archive page, vs the price adjustment in
   the second set of your code that would be on the cart page.
 * As for your actual code ..
 * a) your currency symbol function is wrong. I am not sure what the HeartToken 
   reference is, but that isn’t a default currency or correct case unless that is
   added by another plugin. Please reference the correct code here: [https://woocommerce.com/document/change-a-currency-symbol/](https://woocommerce.com/document/change-a-currency-symbol/)
 * b) the functions added to adjust the pricing > you have commented a bunch of 
   the code out. In addition to that, you have’t set any values in your `function
   bbloomer_alter_price_display` function for `$price_html` to return price = 1
 * c) the last part to apply the price = 1 to each product does work and is output
   in the cart.
 * Cheers!
    -  This reply was modified 4 years ago by [Rynald0s](https://wordpress.org/support/users/rynald0s/).
    -  This reply was modified 4 years ago by [Rynald0s](https://wordpress.org/support/users/rynald0s/).
 *  Thread Starter [hector0371](https://wordpress.org/support/users/hector0371/)
 * (@hector0371)
 * [4 years ago](https://wordpress.org/support/topic/codes-in-functions-php-not-working/#post-15728108)
 * My deepest thanks for you, Rynald! Thank you for pointing out the problem in 
   my codes. I am starting to work on that right now.
 * I have been searching for numerous documents and blogs these days, trying to 
   customize woocommerce. But many new problems just keep popping up. That is why
   I have to seek for real-person guidance. Sometimes I hesitate doing so, feeling
   that it is not polite for asking others such questions, as they are not core-
   based modifications from the start.
    Would you mind if I post follow-up questions
   on debugging these codes?
 * I am really grateful for you answering this question so far.
 *  [Margaret S. woo-hc](https://wordpress.org/support/users/margaretwporg/)
 * (@margaretwporg)
 * [4 years ago](https://wordpress.org/support/topic/codes-in-functions-php-not-working/#post-15728138)
 * Hi [@hector0371](https://wordpress.org/support/users/hector0371/)
 * Glad we could be of help!
 * Kindly be informed that support for custom coding is beyond the [scope of support](https://woocommerce.com/support-policy/)
   we are able to provide in this forum. This particular forum is for questions 
   that are related to the WooCommerce core features.
 * For development-oriented questions, we recommend reaching out at the following
   channels:
    - WooCommerce Developer Resources Portal: [https://developer.woocommerce.com/](https://developer.woocommerce.com/)
    - WooCommerce Slack Community: [https://woocommerce.com/community-slack/](https://woocommerce.com/community-slack/)
    - WooCommerce Community on Facebook: [https://www.facebook.com/groups/advanced.woocommerce/](https://www.facebook.com/groups/advanced.woocommerce/)
 * You may also be able to find someone willing to volunteer their time and knowledge
   in the free PHP support forum at [PHP Builder](http://board.phpbuilder.com/).
 * For continued support with customizations, yo can also consider hiring a developer
   or one of the customization experts listed at [https://woocommerce.com/customizations/](https://woocommerce.com/customizations/).
 * I hope you find this information helpful.
 *  Thread Starter [hector0371](https://wordpress.org/support/users/hector0371/)
 * (@hector0371)
 * [4 years ago](https://wordpress.org/support/topic/codes-in-functions-php-not-working/#post-15728549)
 * I just finished the debugging process. Most of the problems are solved, thanks
   to your help! one problem left behind:
 * How to add a custom currency symbol via local .png file?
 * In the codes listed above I already knew how to add custom currency symbol like“
   $” or “#”, but what should i do if I want to show a .png picture here?
 *  [Margaret S. woo-hc](https://wordpress.org/support/users/margaretwporg/)
 * (@margaretwporg)
 * [4 years ago](https://wordpress.org/support/topic/codes-in-functions-php-not-working/#post-15729024)
 * Hi [@hector0371](https://wordpress.org/support/users/hector0371/)
 * Glad to know that many of the problems are solved.
 * > How to add a custom currency symbol via local .png file?
 * I found some plugins and code that allow adding a custom currency symbol (you
   may already be aware of some of these), but whether there is a provision to have
   a .png image file for a symbol or not is something that needs to be tested/inquired.
   We recommend reaching out to the plugins’ support team with the query.
 * – [https://wordpress.org/plugins/custom-currency-for-woocommerce/](https://wordpress.org/plugins/custom-currency-for-woocommerce/)
   –
   [https://www.cloudways.com/blog/add-custom-currency-symbol-in-woocommerce/](https://www.cloudways.com/blog/add-custom-currency-symbol-in-woocommerce/)–
   [https://woocommerce.com/document/change-a-currency-symbol/](https://woocommerce.com/document/change-a-currency-symbol/)–
   [https://woocommerce.com/document/add-a-custom-currency-symbol/](https://woocommerce.com/document/add-a-custom-currency-symbol/)
 * It is likely that to achieve the desired output some customization will be needed,
   which, however, happens to fall outside the [scope of support](https://woocommerce.com/support-policy/)
   we are able to provide on this forum. This particular forum is for questions 
   that are related to the WooCommerce core features.
 * Therefore we encourage you to reach out at the development related support channels
   shared above.
 * Cheers
 *  [Rynald0s](https://wordpress.org/support/users/rynald0s/)
 * (@rynald0s)
 * Automattic Happiness Engineer
 * [4 years ago](https://wordpress.org/support/topic/codes-in-functions-php-not-working/#post-15729745)
 * Hi [@hector0371](https://wordpress.org/support/users/hector0371/).
 * > How to add a custom currency symbol via local .png file?
   > In the codes listed above I already knew how to add custom currency symbol 
   > like “$” or “#”, but what should i do if I want to show a .png picture here?
 * A .png picture might be a bit overkill, and as mentioned, may require more customization
   than necessary. Furthermore, the output, in my personal opinion, would’t look
   good (cosmetically).
 * You can however, as a easier workaround, simply copy ad paste a emoji into the`
   $currency_symbol` if the idea is to show the currency flag (as most folks do).
   It would look like this:
 *     ```
       add_filter('woocommerce_currency_symbol', 'change_existing_currency_symbol', 10, 2);
   
       function change_existing_currency_symbol( $currency_symbol, $currency ) {
            switch( $currency ) {
                 case 'USD': $currency_symbol = '🇦🇺 $'; break;
            }
            return $currency_symbol;
       }
       ```
   
 * And the output would look like this: [https://snipboard.io/fmrT4g.jpg](https://snipboard.io/fmrT4g.jpg)
 * There are many sites you can grab the emojies from, such as [https://getemoji.com/](https://getemoji.com/)
   and [https://www.emojicopy.com/](https://www.emojicopy.com/)
 * Cheers!
 *  [Margaret S. woo-hc](https://wordpress.org/support/users/margaretwporg/)
 * (@margaretwporg)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/codes-in-functions-php-not-working/#post-15751004)
 * We’ve not heard back from you in a while, so I’m marking this thread as resolved.
   Hopefully, the above info was helpful.
 * If you have further questions, please feel free to open a new topic.

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

The topic ‘Codes in functions.php not working’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce/assets/icon.svg?rev=3234504)
 * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce/reviews/)

 * 10 replies
 * 5 participants
 * Last reply from: [Margaret S. woo-hc](https://wordpress.org/support/users/margaretwporg/)
 * Last activity: [3 years, 11 months ago](https://wordpress.org/support/topic/codes-in-functions-php-not-working/#post-15751004)
 * Status: resolved