Home Forums WoodMart support forum I want to add a snippet to add checkbox to my woocommerce login/register page.

I want to add a snippet to add checkbox to my woocommerce login/register page.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #113501

    Khalid_xdrkzx
    Participant

    I want to add a snippet to add checkbox to my woocommerce login/register page. Where should i put it i tried my child theme functions.php but the changes are getting reverted. And if i put the code in style.css it shows there are 69 errors so should i try it?

    The code

    /**
    * @snippet Add Privacy Policy Checkbox @ WooCommerce My Account Registration Form
    * @how-to Watch tutorial @ https://businessbloomer.com/?p=19055
    * @sourcecode https://businessbloomer.com/?p=74128
    * @author Rodolfo Melogli
    * @testedwith WooCommerce 3.5.1
    * @donate $9 https://businessbloomer.com/bloomer-armada/
    */

    add_action( ‘woocommerce_register_form’, ‘bbloomer_add_registration_privacy_policy’, 11 );

    function bbloomer_add_registration_privacy_policy() {

    woocommerce_form_field( ‘privacy_policy_reg’, array(
    ‘type’ => ‘checkbox’,
    ‘class’ => array(‘form-row privacy’),
    ‘label_class’ => array(‘woocommerce-form__label woocommerce-form__label-for-checkbox checkbox’),
    ‘input_class’ => array(‘woocommerce-form__input woocommerce-form__input-checkbox input-checkbox’),
    ‘required’ => true,
    ‘label’ => ‘I\’ve read and accept the Privacy Policy‘,
    ));

    }

    // Show error if user does not tick

    add_filter( ‘woocommerce_registration_errors’, ‘bbloomer_validate_privacy_registration’, 10, 3 );

    function bbloomer_validate_privacy_registration( $errors, $username, $email ) {
    if ( ! is_checkout() ) {
    if ( ! (int) isset( $_POST[‘privacy_policy_reg’] ) ) {
    $errors->add( ‘privacy_policy_reg_error’, __( ‘Privacy Policy consent is required!’, ‘woocommerce’ ) );
    }
    }
    return $errors;
    }

    #113509

    Artem Temos
    Keymaster

    Hi,

    It is a PHP code and to make it executable you need to put it to the functions.php file in the child theme.

    Regards

    #113512

    Khalid_xdrkzx
    Participant

    Thanks Artem for the Quick response,

    But my php inst accepting this code its reverting to default and i am getting a popup to change it with SFTP. What should i do?

    #113527

    Artem Temos
    Keymaster

    There is may be some problem with your files permissions. Contact your hosting provider for help resolving this.

Viewing 4 posts - 1 through 4 (of 4 total)