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)
Viewing 10 replies - 1 through 10 (of 10 total)
- The topic ‘Codes in functions.php not working’ is closed to new replies.