-
AuthorPosts
-
July 22, 2018 at 11:40 am #988335
Hi
Why is it possible to send an order without accepting terms and conditions on the checkout page?
No error message.
The T&C page (AGB) is activated in WC.I copied the following codes from my active Flashlight website to the enfold-child > functions.php.
What works with Flashlight seems not to work with Enfold Child – or did I make a mistake?/* Customize "Terms and Conditions (AGB)" on the Checkout page */ add_filter( 'woocommerce_checkout_show_terms','avia_remove_default_tos'); add_action( 'woocommerce_review_order_before_submit','avia_add_tos_checkbox'); function avia_remove_default_tos() { return false; } function avia_add_tos_checkbox() { ?> <p class="form-row terms"> <label for="terms" class="checkbox"><?php _e( 'Ich habe die', 'woocommerce' ); ?> <a href="<?php echo esc_url( get_permalink(woocommerce_get_page_id('terms')) ); ?>" target="_blank"><?php _e( 'Allgemeinen Geschäftsbedingungen', 'woocommerce' ); ?></a> gelesen und akzeptiere diese.</label> <input type="checkbox" class="input-checkbox" name="terms" <?php checked( $terms_is_checked, true ); ?> id="terms" /> </p> <?php }
and
/** Store terms and conditions value within the database **/ add_action('woocommerce_checkout_update_order_meta', 'woo_save_terms_and_conditions_status'); function woo_save_terms_and_conditions_status( $order_id ) { if ($_POST['terms']) update_post_meta( $order_id, '_terms', esc_attr($_POST['terms'])); } add_action( 'woocommerce_admin_order_data_after_billing_address', 'woo_display_terms_and_conditions_status', 10, 1 ); function woo_display_terms_and_conditions_status($order){ $terms = get_post_meta( $order->id, '_terms', true ); $terms_status = ( $terms == 'on' ? __('accepted') : __('undefined') ); echo '<p><strong>'.__('Terms & conditions').':</strong> ' . $terms_status . '</p>'; }
Can you help, please?
Please feel free to send test orders to check.Thank you
Bruno- This topic was modified 6 years, 5 months ago by bruwa.
July 22, 2018 at 1:26 pm #988360Hey bruwa,
I didn’t check your code but as far as I know it’s not required. WooCommerce will add a “Terms and conditions” checkbox to the checkout page automatically if you set a “Terms and conditions”-page. Go to WooCommerce > Settings > Advanced and select an existing page from the “Terms and conditions” dropdown. Then save the options and WooCommerce should add a mandatory checkbox to the checkout page. You can also use a plugin like https://marketpress.de/shop/plugins/woocommerce-german-market/ if you need more customization settings.
Best regards,
DudeJuly 22, 2018 at 3:27 pm #988413Hi Dude
I don’t remember where I originally got the code from.
The reason why I used it is, that the T&C phrase is not translated to German (see screenshot in the private field).
– The plugin WoocCmmerce German is installed and activated – but apparently missing this translation
– the page “terms and conditions (AGB) exists and is setFrom an extensive Google search I learned that you can edit the T&C text in the customizer.
However: two questions remain:
– the customized text does not have the link the my T&C page (set as “AGB”) – if I add [terms] as shown in the customizer, the English version “terms_and_conditions” shows up.
– at the end of the customized text an asterisk shows up that seems not to serve any purpose and that I’m unable to removeThe relevant code for the TCC text can be found in woocommerce/includes/wc-template-functions.php (lines 738-741):
function wc_get_terms_and_conditions_checkbox_text() { /* translators: %s terms and conditions page name and link */ return trim( apply_filters( 'woocommerce_get_terms_and_conditions_checkbox_text', get_option( 'woocommerce_checkout_terms_and_conditions_checkbox_text', sprintf( __( 'I have read and agree to the website %s', 'woocommerce' ), '[terms]' ) ) ) ); }
Can you help me on how to add the missing link to my T&C page (AGB)?
My custom T&C line reads ” Ich habe die Allgemeinen Geschäftsbedingungen gelesen und akzeptiere sie”
A link should bring you to the page AGB set as my “T&C” page. .Can you suggest a way to solve the problem in the Enfold Child theme (functions.php?) instead of modifying the original file?
Best regards,
BrunoSources:
https://themeskills.com/edit-woocommerce-terms-conditions-checkbox-text/
https://woocommerce.wp-a2z.org/oik_api/wc_terms_and_conditions_checkbox_text/PS
My initial statement saying my code worked on a Flashlight site was wrong – I have just double-checked: it shows the same problem)- This reply was modified 6 years, 5 months ago by bruwa.
July 22, 2018 at 9:57 pm #988497Hey!
I added this code to the child theme functions.php to translate the toc label:add_filter('woocommerce_get_terms_and_conditions_checkbox_text', 'avia_translate_toc_label', 10, 1); function avia_translate_toc_label($label) { $url = esc_url(get_permalink(woocommerce_get_page_id('terms'))); $label = 'Ich habe die <a href="'.$url.'" target="_blank">Allgemeinen Geschäftsbedingungen</a> gelesen und akzeptiere diese.'; return $label; }
2) The asterisk is added by woocommerce and marks the checkbox as mandatory field. I added this code to the quick css field to hide it:
#top #payment label.woocommerce-form__label-for-checkbox .required{ display:none; }
Regards,
PeterJuly 22, 2018 at 10:15 pm #988502Peter
You made my day. Thank you so much!
To be honest: I never expected to get an answer over the weekend. Great Job.Best regards,
BrunoJuly 23, 2018 at 5:31 am #988586 -
AuthorPosts
- You must be logged in to reply to this topic.