Title: PHP Functions
Last modified: November 20, 2019

---

# PHP Functions

 *  [cartonbuiltmodels](https://wordpress.org/support/users/cartonbuiltmodels/)
 * (@cartonbuiltmodels)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/php-functions-3/)
 * Hello,
 * I am using the Zakra theme with the woo commerce plug-in.
 * I am trying to add a function that displays in the shopping cart the amount that
   a customer must order in order to get free shipping.
 * This is a link to the instructions.
 * [https://www.tychesoftwares.com/display-the-remaining-cost-for-customer-to-avail-free-shipping-on-your-woocommerce-store/](https://www.tychesoftwares.com/display-the-remaining-cost-for-customer-to-avail-free-shipping-on-your-woocommerce-store/)
 * At the bottom of that page is a code that I show below.
 * When I follow the instructions and add that code to the functions PHP page I 
   get an error”
 *  of type E_PARSE was caused in line 375 of the file /home/tryal1/public_html/
   cartonbuiltmodels/wp-content/themes/zakra/functions.php. Error message: syntax
   error, unexpected ‘
 * . ”
 * Is there an error in the code?
 * Am I adding it incorrectly as to the location or something else?
 * Or is there something in the Zakra code that does not allow this to work properly?
 * <?php
    add_action( ‘woocommerce_before_cart’, ‘wc_add_notice_free_shipping’ );
   function wc_add_notice_free_shipping() {
 *  $free_shipping_settings = get_option(‘woocommerce_free_shipping_1_settings’);
   
   $amount_for_free_shipping = $free_shipping_settings[‘min_amount’]; $cart = WC()-
   >cart->subtotal; $remaining = $amount_for_free_shipping – $cart; if( $amount_for_free_shipping
   > $cart ){ $notice = sprintf( “Add %s worth more products to get free shipping”,
   wc_price($remaining)); wc_print_notice( $notice , ‘notice’ ); }
 * }
    ?>
 * Thank you for the time.
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fphp-functions-3%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 1 replies (of 1 total)

 *  [Shreejana-ThemeGrill Support](https://wordpress.org/support/users/shreejanakc/)
 * (@shreejanakc)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/php-functions-3/#post-12162563)
 * Hey [@cartonbuiltmodels](https://wordpress.org/support/users/cartonbuiltmodels/),
 * Please create a child theme and write your code into the child theme functions.
   php file. You should not code on the main parent theme file. Refer: [https://themegrill.com/blog/tutorial-creating-wordpress-child-theme/](https://themegrill.com/blog/tutorial-creating-wordpress-child-theme/)
 * There are several syntax errors on the code you mentioned above.
 * Syntax error correction:
 *     ```
       add_action( 'woocommerce_before_cart', 'wc_add_notice_free_shipping' );
       function wc_add_notice_free_shipping() {
   
       	$free_shipping_settings = get_option('woocommerce_free_shipping_1_settings');
       	$amount_for_free_shipping = $free_shipping_settings['min_amount'];
       	$cart = WC()->cart->subtotal;
       	$remaining = $amount_for_free_shipping - $cart;
       	if( $amount_for_free_shipping > $cart ){
       	$notice = sprintf( 'Add %s worth more products to get free shipping', wc_price($remaining));
       	wc_print_notice( $notice , 'notice' );
       }
   
       }
       ```
   
 * Note: The above code is not tested but only syntax errors are corrected.
 * Please let us know if you have any further queries.
 * Thanks.
    -  This reply was modified 6 years, 6 months ago by [Shreejana-ThemeGrill Support](https://wordpress.org/support/users/shreejanakc/).

Viewing 1 replies (of 1 total)

The topic ‘PHP Functions’ is closed to new replies.

 * ![](https://i0.wp.com/themes.svn.wordpress.org/zakra/4.2.1/screenshot.jpg)
 * Zakra
 * [Support Threads](https://wordpress.org/support/theme/zakra/)
 * [Active Topics](https://wordpress.org/support/theme/zakra/active/)
 * [Unresolved Topics](https://wordpress.org/support/theme/zakra/unresolved/)
 * [Reviews](https://wordpress.org/support/theme/zakra/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Shreejana-ThemeGrill Support](https://wordpress.org/support/users/shreejanakc/)
 * Last activity: [6 years, 6 months ago](https://wordpress.org/support/topic/php-functions-3/#post-12162563)
 * Status: not resolved