Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Need Help Removing Code from Function PHP WordPress


Hi - I am a (very) entrylevel user of Wordpress and have an issue with code in our function php. Prior to my start, a previous user added code to hide a coupon field that we now want to reappear. I don't know how to get rid of the code that was created to hide it (i tried just deleting the block to no avail, I kept getting an error). Is there an easy fix for this? I just want to get rid of the code to hide it. I provided a snapshot of the code.

Answers (8)


John Cotton answers:

If you start by commenting out the two lines that begin "add_filter" (so make them "// add_filter", that should tell you whether you've had the desired effect.

If you have, delete the two functions above.

Finally, do the same (comment, try, delete) for the remove_action line.

If that doesn't do it, it's somewhere else in your file.

David Holtz comments:

Sounds like there's a permissions issue that the questioner will need to resolve first ;(

John Cotton comments:

There does!


Cesar Contreras answers:

Just comment on the add_filter functions, but it seems that you have problems with the permissions to edit the file, try to enter your C-PANEL and edit it directly or with your FTP account.

or simply change the value within the "enabled" variable of each function. Here I leave the modified code:

function hide_coupon_field_on_cart( $enabled ) {
if( is_cart() ){
$enabled = true;
return $enabled;
add_filter( 'woocomerce_coupons_enabled', 'hide_coupon_field_on_cart' );

function hide_coupon_field_on_checkout( $enabled ) {
if( is_checkout() ){
$enabled = true;
return $enabled;
add_filter( 'woocomerce_coupons_enabled', 'hide_coupon_field_on_checkout' );


Arnav Joy answers:

Is your problem solved ?

Arnav Joy comments:

if you having problem you can provide me access at: [email protected] and I will solve it.


Navjot Singh answers:

Just comment out these two lines

by putting // in front of them like this

// add_filter('woocommerce_coupons_enabled','hide_coupon_field_on_cart');
// add_filter("woocommerce_coupons_enabled','hide_coupon_field_on_checkout');

That's all you need to do to get rid of the functionality.


Mohamed Ahmed answers:

Simply change these lines from





David Holtz answers:

What does the error say?

User180291 comments:

"Something went wrong. Your change may not have been saved. Please try again. There is also a chance that you may need to manually fix and upload the file over FTP."


Fahad Murtaza answers:

Copy the functions.php code, edit it locally and then upload via FTP. But looks to me there is a file permission issue as you are not able to edit it via wp admin. If that's the case, you need to fix that first.

You can use filezilla or some other FTP client to edit the file directly vi FTP.

Fahad Murtaza comments:

Follow John's advice for actual code editing. That is the safest way.


Romel Apuya answers:

Are you editing via wp-admin editor?
Best way to edit file is via FTP.
I have this experience where it throws an error on the admin code editor,but its already edited on the FTP.