/** * Validate checkbox data */ function woocommerce_gzd_checkout_validation($posted) { if (!isset($_POST['woocommerce_checkout_update_totals'])) { if (!isset($_POST['legal']) && get_option('woocommerce_gzd_display_checkout_legal_no_checkbox') == 'no') { wc_add_notice(wc_gzd_get_legal_text_error(), 'error'); } // Check if cart contains downloadable product $items = WC()->cart->get_cart(); $is_downloadable = false; if (!empty($items) && get_option('woocommerce_gzd_checkout_legal_digital_checkbox') == 'yes') { foreach ($items as $cart_item_key => $values) { $_product = apply_filters('woocommerce_cart_item_product', $values['data'], $values, $cart_item_key); if (wc_gzd_is_revocation_exempt($_product)) { $is_downloadable = true; } } } if ($is_downloadable && !isset($_POST['download-revocate'])) { wc_add_notice(wc_gzd_get_legal_text_digital_error(), 'error'); } } }
/** * Validate checkbox data */ function woocommerce_gzd_checkout_validation($posted) { if (!isset($_POST['woocommerce_checkout_update_totals'])) { if (!isset($_POST['legal']) && get_option('woocommerce_gzd_display_checkout_legal_no_checkbox') == 'no') { wc_add_notice(wc_gzd_get_legal_text_error(), 'error'); } // Check if cart contains downloadable product $items = WC()->cart->get_cart(); $is_downloadable = false; if (!empty($items) && get_option('woocommerce_gzd_checkout_legal_digital_checkbox') == 'yes') { foreach ($items as $cart_item_key => $values) { $_product = apply_filters('woocommerce_cart_item_product', $values['data'], $values, $cart_item_key); if (wc_gzd_is_revocation_exempt($_product)) { $is_downloadable = true; } } } if ($is_downloadable && !isset($_POST['download-revocate'])) { wc_add_notice(__('To retrieve direct access to digital content you have to agree to the loss of your right of withdrawal.', 'woocommerce-germanized'), 'error'); } } }