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.
This website uses cookies

We use cookies to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners who may combine it with other information that you’ve provided to them or that they’ve collected from your use of their services.

Cookies are small text files that can be used by websites to make a user's experience more efficient.

The law states that we can store cookies on your device if they are strictly necessary for the operation of this site. For all other types of cookies we need your permission. This means that cookies which are categorized as necessary, are processed based on GDPR Art. 6 (1) (f). All other cookies, meaning those from the categories preferences and marketing, are processed based on GDPR Art. 6 (1) (a) GDPR.

This site uses different types of cookies. Some cookies are placed by third party services that appear on our pages.

You can at any time change or withdraw your consent from the Cookie Declaration on our website.

Learn more about who we are, how you can contact us and how we process personal data in our Privacy Policy.

Please state your consent ID and date when you contact us regarding your consent.