Have you read this article?
Hello Stef,
No I have not! Thank you for the information. I will take a look and let you know how I weather.
Best Regards,
mbenatar
Hello Stef,
I started to implement the article but when I got to the step to install “My Custom Functions” plugin and insert the PHP code, I got this error message.I am not a coder so I don’t know how to debug and fix the error.
“Sorry but your code causes a “fatal error”, so it is not applied!
Please, check the code and try again.
mbenatar
So take it out. Refresh, start over. Where and how are you adding the code?
Okay so I tried to refresh my page and now I am getting this error message when I try and log back in to my wordpress admin. I entered the code into the code window of My Custom Functions.
“The site is experiencing technical difficulties. Please check your site admin email inbox for instructions.”
I have not received any email and can’t log back into my backend.
mbenatar
Do you have ftp access? Sounds like you added it using theme editor and not ftp.
Can you paste the code here exactly like you posted into your functions?
// add hidden field in order after checkout
add_action( ‘woocommerce_checkout_before_customer_details’, ‘my_custom_checkout_hidden_field’, 10, 1 );
function my_custom_checkout_hidden_field( $checkout ) {
foreach ( WC()->cart->get_cart() as $cart_item ) {
$product = $cart_item[‘data’];
if(!empty($product)){
$webinar_id = $product->get_attribute( ‘webinar_id’ );
// Output the hidden field
echo ‘<div id=”user_link_hidden_checkout_field”>
<input type=”hidden” class=”input-hidden” name=”webinar_id” id=”webinar_id” value=”‘ . $webinar_id . ‘”>
</div>’;
}
}
}
// save hidden field in the order
add_action( ‘woocommerce_checkout_update_order_meta’, ‘save_custom_checkout_hidden_field’, 10, 1 );
function save_custom_checkout_hidden_field( $order_id ) {
if ( ! empty( $_POST[‘webinar_id’] ) )
update_post_meta( $order_id, ‘_webinar_id’, sanitize_text_field( $_POST[‘webinar_id’] ) );
}
//only 1 prod in cart for WooC
add_filter( ‘woocommerce_add_to_cart_validation’, ‘bbloomer_only_one_in_cart’, 99, 2 );
function bbloomer_only_one_in_cart( $passed, $added_product_id ) {
// empty cart first: new item will replace previous
wc_empty_cart();
return $passed;
}
I do have ftp access through my web host. But I did enter the code in My Custom Functions in ‘Settings”
mbenatar
I am totally locked out of admin. I have ftp access but have no idea what to do.
Here is a message I got back from my host support. I don’t even know what it means.
I am unable to see any relevant files under the document root directory for the domain clinicalavianpathologyservices.com. Please update the files so that the site loads properly.
Please let me know if you need any further assistance.
[/home/rescuebi/clinicalavianpathologyservices.com]# ll
total 12
drwxr-xr-x 3 rescuebi rescuebi 4096 May 17 15:50 ./
drwx–x–x 33 rescuebi rescuebi 4096 May 17 15:50 ../
drwxr-xr-x 2 rescuebi rescuebi 4096 May 17 15:50 marten/
All the Best,
Arunlal Ashok,
Linux Systems Engineer
Acenet, Inc.
http://www.ace-host.net/
1.) You downloaded the plugin and then you added the script?
2.) Can you login to your FTP and rename that plugin folder?
3.) Then refresh the page.
Only the BD plugin rename
Okay, for some strange reason I was able to get back on the website admin through Google and delete “My Custom Functions” plugin.
So I am wondering why I had that issue? I want to try the process again but I am a bit concerned that the same thing will happen. I am pretty sure that I pasted the code correctly.
mbenatar
I tried it again and pasted the code. Got the same error message and the same thing happened again. So I uninstalled the plugin.
Yeah it’s hard for me to say without seeing what you’re doing exactly.