[Support request] Lost custom code with update.

Home Forums Support [Support request] Lost custom code with update.

Home Forums Support Lost custom code with update.

Viewing 7 posts - 16 through 22 (of 22 total)
  • Author
    Posts
  • #576696
    Sami

    Hello, so should everything work if i just copy paste all the custom code from parent theme folders to the child & then remove all the custom code in the parent theme folders?

    Also a silly question, but how am i supposed to avoid this from happening in the future? Am i supposed to have the parent theme active and have the custom code there? Or parent theme active?

    #576698
    Tom
    Lead Developer
    Lead Developer

    Yes, just be sure to completely remove the custom code from the parent theme before saving it in the child theme. PHP functions cannot be redeclared. If they already exist, you’ll run into errors.

    It’s best to just leave the parent theme along completely. All custom code should always go into a child theme.

    #576700
    Sami

    And i should have the child theme as the active theme?

    I try to remove all the custom code and add it to the child theme and let you know if i run into issues.

    #576715
    Sami

    Yeah it didn’t work, bunch of errors this time. Some parts of the website work perfectly now. For example the product page.

    The home page is completely broken though..

    Here are the errors, all in the functions file:

    Your PHP code changes were rolled back due to an error on line 76 of file wp-content/themes/generatepress-child/functions.php. Please fix and try saving again.

    Line 76: return $product->get_product_url();

    Uncaught Error: Call to undefined method WC_Product_Simple::get_product_url() in wp-content/themes/generatepress-child/functions.php:76
    Stack trace:
    #0 wp-includes/class-wp-hook.php(286): {closure}(‘https://consume…’, Object(WC_Product_Simple))
    #1 wp-includes/plugin.php(203): WP_Hook->apply_filters(‘https://consume…’, Array)
    #2 wp-content/themes/generatepress-child/functions.php(58): apply_filters(‘woocommerce_loo…’, ‘https://consume…’, Object(WC_Product_Simple))
    #3 wp-includes/class-wp-hook.php(286): woocommerce_custom_template_loop_product_link_open(”)
    #4 wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters(NULL, Array)
    #5 wp-includes/plugin.php(453): WP_Hook->do_action(Array)
    #6 /home2/drnldkmy/public_h

    #577202
    Tom
    Lead Developer
    Lead Developer

    That’s an error within the custom code you had written for you. Your developer needs to check to make sure get_product_url() is a valid method.

    #577621
    Sami

    Hello, the website crashed completely now. I don’t think there is anything wrong with the custom code. I have another website that only has different colors logos etc… with the exact same custom code theme plugins and everything and it works fine.

    But yeah i don’t think this is going to work. I will boot the whole thing and hire someone to fix it for me.

    Can you just answer me is the parent theme supposed to be the active theme or the child theme in order to avoid this from happening in the future?

    Thanks for your help.

    #577643
    Tom
    Lead Developer
    Lead Developer

    The child theme needs to be the active theme in order for the code within it to execute.

    Sorry I can’t be more helpful – the code itself seems to be the issue.

Viewing 7 posts - 16 through 22 (of 22 total)
  • You must be logged in to reply to this topic.