checkbox general conditions of sale in order validation

Hello,


I'd like to have a checkbox to accept the general terms and conditions of sale during order confirmation, and to prevent the order from being processed if this box is not checked.


I can't find a way to integrate this into the payment confirmation page...


Cheers


Stephane

Comments

  • Hi,

    Sorry, but it is not Betheme related question.

    You should contact WooCommerce support instead.


    Best regards

  • Hello,


    However, it's a native WooCommerce function to have the terms and conditions of sale accepted by checking a box on the order confirmation page.


    Whereas, BeTheme only displays a line with the page links, but no acceptance checkbox...


    Even trying to add code to my functions.php file doesn't work...

    Here's my code:

    add_action('woocommerce_new_order', 'auto_set_on_hold_for_manual_payments', 10, 1);

    function auto_set_on_hold_for_manual_payments($order_id) {

      $order = wc_get_order($order_id);

      if (in_array($order->get_payment_method(), ['bacs', 'cheque']) && $order->get_status() === 'pending') {

        $order->update_status('on-hold');

      }

    }

    // Ajouter une case à cocher obligatoire pour accepter les CGV sur la page de commande

    add_action('woocommerce_review_order_before_submit', 'ajouter_case_cgv_obligatoire', 10);

    function ajouter_case_cgv_obligatoire() {

      echo '<div class="form-row cgv-checkbox" style="margin-bottom: 20px;">';

      woocommerce_form_field('cgv_checkbox', [

        'type'   => 'checkbox',

        'class'  => ['form-row'],

            'label'    => 'J\'ai lu et j\'accepte les <a href="https://www.souvenirsetcollections.fr/conditions-generales-de-vente/" target="_blank">Conditions Générales de Vente</a>',

        'required' => true,

      ]);

      echo '</div>';

    }


    // Empêcher la commande si la case n’est pas cochée

    add_action('woocommerce_checkout_process', 'verifier_case_cgv_obligatoire');

    function verifier_case_cgv_obligatoire() {

      if (!isset($_POST['cgv_checkbox'])) {

        wc_add_notice(__('Vous devez accepter les Conditions Générales de Vente pour finaliser votre commande.'), 'error');

      }

    }



    I don't understand why this would depend on WooCommerce and not the theme?


    Best regards,


    Stéphane

  • Please do a test and switch to another theme like Twenty Twenty-Five to check how it works there.

    When you do it, please let me know about the results.


    Thanks

  • Well... with the theme change, I also have the same problem ;-/

  • If I create a checkout template... would I be able to add this checkbox?

  • This indicated that it is not related to the theme itself, but to WooCommerce.

    That is why you should not hesitate and contact Woo support regarding this.

    No, in templates, there is no option to add your own checkboxes.


    Best regards

Sign In or Register to comment.