Problems adding a custom field for products in WooCommerce

Hi!

Basically I’m trying to follow what is suggested in the below link:

http://wordpress.org/support/topic/woocommerce-easy-permalink-solution?replies=16

I’m trying to add a custom field called “custom_permalink” when editing a product in WooCommerce.

The data is added and a yellow frame is flashing to acknowledge. But when I click the update button for the product the custom field is not added.

I read in the below post that it can be a problem with functions.php. But I never edited that file. Can you please advice?

http://wordpress.org/support/topic/custom-fields-wont-add-correctly-theme-problem?replies=3

I added the field custom_permalink through the plugin called: Custom Permalink

http://wordpress.org/plugins/custom-permalinks/

This plugin adds “custom_permalink” to the Custom fields dropdown menu.

When I add a value to custom_permalink and click the “Add custom field” button it flashes yellow. But when I click the Update button to update the product the value is cleared and not saved.

What can be wrong?

  • Michelle Shull
    • DEV MAN’s Apprentice

    Hi Peter!

    If the issue is in functions.php, it’s totally not your fault! And it’s an easy fix. : )

    Functions.php is a picky, picky file, and it is wont to break things if there are any extra blank lines in the file. Sometimes, other plugins will drop code into functions.php, and I’m guessing what happened here is that some code was added with an extra carriage return or line break.

    How to fix it: Use FTP to edit your functions PHP file with a plain text editor, like Notepad, Notepad++, or any other text editor that isn’t also a word processor, like Word or Pages. Word processors love to drop in extra lines and character you don’t need.

    Depending on how complex your site is, your functions.php file might be very short, or it could be several hundred lines long. That’s okay, because we’re not looking at any of the text, we’re looking for extra lines between functions, or an extra blank line at the very end of the file. Go through the file carefully, and gently delete or backspace away any extra lines. Spaces in the functions themselves are fine, we just don’t want entire blank lines.

    Save your file and re-upload it, and test the custom fields again.

    Let me know if this works for you!

  • Peter
    • New Recruit

    Hi,

    I tried to remove all the blank lines in functions.php. But it did unfortunately not solve the problem.

    What could be the error? Perhaps you can try it your self within my WP install to add the custom field? I can give you the login details.

    Thanks,

    Peter

  • Michelle Shull
    • DEV MAN’s Apprentice

    Hey Peter!

    I found this in the comments of the how-to thread, I think this might be your answer:

    make sure that you have your product permalinks set to the default in Settings > Permalinks. The rewrites listed above won’t work properly without that setting.

    Hope that helps!