Terms of use checkbox

Hello, I have inserted this php snippet to insert a check box to be accepted with some conditions of use.

// Mostrar campo obligatorio Términos y condiciones en el checkout
// @autora - Ruth Gascón https://ruthgascon.com
     
function anadir_terminos_checkout() {
woocommerce_form_field( 'terminos_condiciones', array(
    'type'      => 'checkbox',
    'required'  => true,
    'label'     => __('He leído y acepto las <a target="blank" href="https://autotrabajo.com/condiciones-de-contratacion/">condiciones generales de contratación.</a>'),
)); 
}
 
add_action( 'woocommerce_review_order_before_submit', 'anadir_terminos_checkout', 9 );
 
// Mostrar mensaje de error si no se aceptan los Términos y condiciones    
    
function mostrar_error_terminos() {
    if ( ! (int) isset( $_POST['terminos_condiciones'] ) ) {
        wc_add_notice(('Por favor acepta las condiciones generales de contratación'), 'error');
    }
}
 
add_action( 'woocommerce_checkout_process', 'mostrar_error_terminos' );
 
// Añade campo en el pedido
function anadir_campo_terminos_en_pedido( $order_id ) {
    if ( ! empty( $_POST['terminos_condiciones'] ) ) {
        update_post_meta( $order_id, 'Terminos y condiciones aceptadas', sanitize_text_field( $_POST['terminos_condiciones'] ) );
    }
}
 
add_action( 'woocommerce_checkout_update_order_meta', 'anadir_campo_terminos_en_pedido' );

But I would like to insert another one like this in the Experthive screen to add a new ad. So that it appears at the bottom of the screen after filling in all the fields. Can you help me to know what function or line I have to change in my previous code so that it appears there.
Thank you very much.

Translated with DeepL Translate: The world's most accurate translator (free version)

Please try using the existing options in HivePress/Settings/Listings/Submission section, if you select the Terms page here a check box will appear automatically. WooCommerce has the same option in their settings, so this code snippet may not be required if you mean adding a checkbox with Terms & Conditions to the listing submission & checkout forms.

Thank you yevhen. But I need you to have 2 check boxes on the advertising screen. That’s why I need to implement that code.

One checkbox for privacy policy and another checkbox for terms of use

Please try this PHP snippet to add an additional checkbox when a user adds listing

add_filter(
	'hivepress/v1/forms/listing_submit',
	function ( $form ) {
		$form['fields']['custom_listing_policy_approve'] = [
			'caption' => 'custom text here',
			'type'    => 'checkbox',
			'required' => true,
			'_order' => 1000,
		];

		return $form;
	},
	1000
);

Thank you, it works very well

Yevhen, I need a line text to appear before the accept checkbox. This new text must appear on the top line and then one below must appear the acceptance box that you have explained to me with the previous fragment. In the Other line

Thank you

Sorry for the inconvenience, but customization is beyond our support scope - it includes fixing bugs and guidance about the available features.

If customizations are required for your site, please try customizing it using the collection of code snippets Search · user:hivepress · GitHub and other developer resources, or consider hiring someone for custom work https://fwd.cx/hLhc73mQCD9R

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.