- This topic has 13 replies, 4 voices, and was last updated 2 years, 6 months ago by Leo.
-
AuthorPosts
-
June 30, 2022 at 3:19 am #2268992Usman
Hey everyone, I am working on an e-commerce store: kaptaanchappal.com.
The site is working fine but when I try to edit the home page (https://kaptaanchappal.com/wp-admin/post.php?post=899&action=edit) it shows an error.
”
There has been a critical error on this website. Please check your site admin email inbox for instructions.Learn more about troubleshooting WordPress.
”I haven’t found any email in the inbox. All other pages are editable except this. Anyone can guide me on this?
Looking Forward,
UsmanJune 30, 2022 at 3:44 am #2269007DavidStaffCustomer SupportHi there,
ask your host to enable debugging, they should then be able to provide a more detailed error log which can be used to diagnose the issue.
June 30, 2022 at 7:26 am #2269188UsmanHi @David thanks for replying.
I got the log file errors:
Fatal error: Uncaught Error: Call to a member function is_type() on null in /home/rapixqxb/kaptaanchappal.com/wp-content/themes/generatepress/functions.php:135 Stack trace: #0 /home/rapixqxb/kaptaanchappal.com/wp-includes/class-wp-hook.php(309): {closure}(‘Select options’) #1 /home/rapixqxb/kaptaanchappal.com/wp-includes/plugin.php(191): WP_Hook->apply_filters(‘Select options’, Array) #2 /home/rapixqxb/kaptaanchappal.com/wp-content/plugins/woocommerce/includes/class-wc-product-variable.php(60): apply_filters(‘woocommerce_pro…’, ‘Select options’, Object(WC_Product_Variable)) #3 /home/rapixqxb/kaptaanchappal.com/wp-content/plugins/woocommerce/packages/woocommerce-blocks/src/StoreApi/Schemas/V1/ProductSchema.php(477): WC_Product_Variable->add_to_cart_text() #4 [internal function]: Automattic\WooCommerce\StoreApi\Schemas\V1\ProductSchema->get_item_response(Object(WC_Product_Variable)) #5 /home/rapixqxb/kaptaanchappal.com/wp-content/plugins/woocommerce/packages/woocommerce-blocks/src/BlockTypes/AbstractProductGrid.php(104): in /home/rapixqxb/kaptaanchappal.com/wp-content/themes/generatepress/functions.php on line 135
My hosting providers asked me to consult with the theme providers.
Looking Forward,
June 30, 2022 at 7:42 am #2269197DavidStaffCustomer SupportIf you look at the error stack, the last line points to:
wp-content/themes/generatepress/functions.php on line 135
So thats line 135 of the Themes functions.php file.
But as you can see here:https://github.com/tomusborne/generatepress/blob/master/functions.php
The themes functions.php has only 122 lines. Which means that your functions.php has been modified on your site.
And i assuMe its the code that has been added there is breaking your site.Can you remove any additional code ?
June 30, 2022 at 9:15 am #2269446UsmanThe rest of code is:
function wplook_activate_gutenberg_products($can_edit, $post_type){ if($post_type == 'product'){ $can_edit = true; } return $can_edit; } add_filter('use_block_editor_for_post_type', 'wplook_activate_gutenberg_products', 10, 2); add_filter( 'woocommerce_product_add_to_cart_text', function( $text ) { global $product; if ( $product->is_type( 'variable' ) ) { $text = $product->is_purchasable() ? __( 'Size', 'woocommerce' ) : __( 'Read more', 'woocommerce' ); } else { $text = $product->is_purchasable() ? __( 'Buy Now', 'woocommerce' ) : __( 'Read more', 'woocommerce' ); } return $text; }, 10 );
135 line is
if ( $product->is_type( 'variable' ) ) {
June 30, 2022 at 10:21 am #2269524LeoStaffCustomer SupportYou will need to remove your custom code so the
function.php
file is exactly the same as the original file:
https://github.com/tomusborne/generatepress/blob/master/functions.phpYour filter code above can be added using one of these methods:
Adding PHP: https://docs.generatepress.com/article/adding-php/June 30, 2022 at 8:45 pm #2269825UsmanThanks, @Leo for the recommendation. I did it and now getting this error:
Fatal error: Uncaught Error: Call to a member function is_type() on null in /home/rapixqxb/kaptaanchappal.com/wp-content/plugins/code-snippets/php/snippet-ops.php(484) : eval()’d code:12 Stack trace: #0 /home/rapixqxb/kaptaanchappal.com/wp-includes/class-wp-hook.php(309): {closure}(‘Select options’) #1 /home/rapixqxb/kaptaanchappal.com/wp-includes/plugin.php(191): WP_Hook->apply_filters(‘Select options’, Array) #2 /home/rapixqxb/kaptaanchappal.com/wp-content/plugins/woocommerce/includes/class-wc-product-variable.php(60): apply_filters(‘woocommerce_pro…’, ‘Select options’, Object(WC_Product_Variable)) #3 /home/rapixqxb/kaptaanchappal.com/wp-content/plugins/woocommerce/packages/woocommerce-blocks/src/StoreApi/Schemas/V1/ProductSchema.php(477): WC_Product_Variable->add_to_cart_text() #4 [internal function]: Automattic\WooCommerce\StoreApi\Schemas\V1\ProductSchema->get_item_response(Object(WC_Product_Variable)) #5 /home/rapixqxb/kaptaanchappal.com/wp-content/plugins/woocommerce/packages/woocommerce-blocks/src/BlockTypes/Abs in /home/rapixqxb/kaptaanchappal.com/wp-content/plugins/code-snippets/php/snippet-ops.php(484) : eval()’d code on line 12
June 30, 2022 at 9:01 pm #2269834Fernando Customer SupportHi Usman,
To clarify, if you temporarily disable/remove this code you have here: https://generatepress.com/forums/topic/website-critical-error-while-editing-homepage/#post-2269446, does the error still exist?
Kindly let us know.
July 1, 2022 at 4:09 am #2270129UsmanHey @Fernando, thanks for the suggestion.
If I remove the code, it works fine. I was wondering if there is a way I can keep this code!
For now, I removed it.
July 1, 2022 at 5:39 am #2270193DavidStaffCustomer SupportTry changing this:
add_filter( 'woocommerce_product_add_to_cart_text', function( $text ) { global $product; if ( $product->is_type( 'variable' ) ) { $text = $product->is_purchasable() ? __( 'Size', 'woocommerce' ) : __( 'Read more', 'woocommerce' ); } else { $text = $product->is_purchasable() ? __( 'Buy Now', 'woocommerce' ) : __( 'Read more', 'woocommerce' ); } return $text; }, 10 );
to:
add_filter( 'woocommerce_product_add_to_cart_text', function( $text ) { if ( is_admin() ) { return; } global $product; if ( $product->is_type( 'variable' ) ) { $text = $product->is_purchasable() ? __( 'Size', 'woocommerce' ) : __( 'Read more', 'woocommerce' ); } else { $text = $product->is_purchasable() ? __( 'Buy Now', 'woocommerce' ) : __( 'Read more', 'woocommerce' ); } return $text; }, 10 );
And please this article on how to add PHP to your site:
https://docs.generatepress.com/article/adding-php/
If you continue to add the code to the parent themes functions.php they you will not be able to update the theme without losing that code.
July 1, 2022 at 8:22 am #2270482UsmanThank you @David for your efforts.
I did the above and in this way, I can edit that page but when I view it, it shows an error.
It seems like I need to delete that code only.
July 1, 2022 at 8:33 am #2270493DavidStaffCustomer SupportAre you using Woocommerce blocks on that page ?
July 9, 2022 at 6:57 am #2277783UsmanHey everyone, pardon me for the late reply.
I removed the code and everything is working fine. I can bear this.
But, can you guys assist me in setting up my homepage properly?
I want to display products category wise as https://kaptaanchappal.com but the problem is, the previous imported settings look nice but I tried the Woo widget at down that is not appealing much.
How can I display the products are GP does but category wise?
Will be thankfull.
July 9, 2022 at 11:26 am #2278094LeoStaffCustomer SupportCan you open a new topic for the separate question?
I’ll mark this one resolved.
-
AuthorPosts
- You must be logged in to reply to this topic.