I am trying to add a custom field to the cart page, and as it says in their documentation it seems to be easy to add custom field to checkout pages like shipping and billing. But I would like to add a field to the cart page. So, on my page I have woocommerce shortcode:
[woocommerce_cart]
I should be adding a field to the woocommerce cart, so creating child theme wouldn't work, from what I could read, because that would only change other sections of the page, and I need to add the field to the woocommerce cart, but how can I do that?
I have tried by adding this code snippet to the functions file of my theme Enfold.
functions-enfold.php:
* Add the field to the checkout
**/
add_action('woocommerce_cart_collaterals', 'my_custom_checkout_field');
function my_custom_checkout_field() {
echo '<div id="my_custom_checkout_field"><h2>'.__('My Field').'</h2>';
woocommerce_form_field( 'my_field_name', array(
'type' => 'text',
'class' => array('my-field-class form-row-wide'),
'label' => __('Fill in this field'),
'placeholder' => __('Enter something'),
));
echo '</div>';
}
But I got an error:
Parse error: syntax error, unexpected '*' in /nas/content/staging/bokashinorge/wp-content/themes/enfold/functions-enfold.php on line 1795
Even on deleting the code snippet and updating the file again, I was still getting the same error, and now I seem to locked because on refresh I keep getting the error all the time, and can't edit anything in the dashboard. How can I fix this, and add the field without getting errors?