This topic has 4 replies, 3 voices, and was last updated 9 years, 1 months ago ago by Eva Kemp
Hello I need to add an alert box at my contact page
Look, just below the contact form.
Which is the .php file that I have to modify?
Thank you
Hello
You may modify wp-content/themes/royal/framework/theme-functions.php in line 1356.
Regards,
Brian Johnson
THank you,
a little help to find a simple error, but I didn’t know php code.
I’ve paste a tested code exactly in the indicated point function.php and I produce this error:
Which is asking to me to modify?
I don’t understand, I pass you text I paste in it.
What’s wrong???
Fatal error: Cannot redeclare my_custom_checkout_field() (previously declared in /var/www/vhosts/lococostyle.com/httpdocs/wp-content/themes/royal/functions.php:19) in /var/www/vhosts/lococostyle.com/httpdocs/wp-content/themes/royal/framework/theme-functions.php on line 1376
/**
* Add checkbox field to the checkout
**/
add_action(‘woocommerce_after_checkout_registration_form’, ‘my_custom_checkout_field’);
function my_custom_checkout_field( $checkout ) {
echo ‘<div id=”my-new-field”><h3>’.__(”).'</h3>’;
woocommerce_form_field( ‘my_checkbox’, array(
‘type’ => ‘checkbox’,
‘class’ => array(‘input-checkbox’),
‘label’ => __(‘Buyer (recipient) will be responsible for all customs fees, duties and import charges that are levied at time of delivery. Each country has their own customs rules and regulations so check on your own countries allowances and regulations if you’re unsure. Please, make sure your revise these costs before purchasing, we are not held responsible after order has been processed and has arrived to its respective destination.’),
‘required’ => true,
), $checkout->get_value( ‘my_checkbox’ ));
echo ‘</div>’;
}
/**
* Process the checkout
**/
add_action(‘woocommerce_checkout_process’, ‘my_custom_checkout_field_process’);
function my_custom_checkout_field_process() {
global $woocommerce;
// Check if set, if its not set add an error.
if (!$_POST[‘my_checkbox’])
wc_add_notice(‘You have to check all the alertbox in the page! Please check it and try again.’, ‘error’ );
}
/**
* Update the order meta with field value
**/
add_action(‘woocommerce_checkout_update_order_meta’, ‘my_custom_checkout_field_update_order_meta’);
function my_custom_checkout_field_update_order_meta( $order_id ) {
if ($_POST[‘my_checkbox’]) update_post_meta( $order_id, ‘My Checkbox’, esc_attr($_POST[‘my_checkbox’]));
}
Hello,
Where do you see the error?
Please show a page.
Regards,
Eva Kemp.
Tagged: contact, customization, page, themes, woocommerce, wordpress
You must be logged in to reply to this topic.Log in/Sign up