woocommerce_gzd_checkout_validation

Validate checkbox data.

Description

woocommerce_gzd_checkout_validation( $posted ); 

Parameters (1)

0. $posted
The posted.

Usage

  1. if ( !function_exists( 'woocommerce_gzd_checkout_validation' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce-germanized/includes/wc-gzd-template-functions.php'; 
  3.  
  4. // The posted. 
  5. $posted = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = woocommerce_gzd_checkout_validation($posted); 
  9.  

Defined (1)

The function is defined in the following location(s).

/includes/wc-gzd-template-functions.php  
  1. function woocommerce_gzd_checkout_validation( $posted ) { 
  2. if ( ! isset( $_POST[ 'woocommerce_checkout_update_totals' ] ) ) { 
  3.  
  4. if ( ! isset( $_POST[ 'legal' ] ) && get_option( 'woocommerce_gzd_display_checkout_legal_no_checkbox' ) == 'no' ) 
  5. wc_add_notice( wc_gzd_get_legal_text_error(), error ); 
  6.  
  7. // Check if cart contains downloadable product 
  8. $items = WC()->cart->get_cart(); 
  9. $is_downloadable = false; 
  10. $is_service = false; 
  11.  
  12. if ( ! empty( $items ) && ( get_option( 'woocommerce_gzd_checkout_legal_digital_checkbox' ) === 'yes' || get_option( 'woocommerce_gzd_checkout_legal_service_checkbox' ) === 'yes' ) ) { 
  13.  
  14. foreach ( $items as $cart_item_key => $values ) { 
  15.  
  16. $_product = apply_filters( 'woocommerce_cart_item_product', $values[ 'data' ], $values, $cart_item_key ); 
  17.  
  18. if ( wc_gzd_is_revocation_exempt( $_product ) ) 
  19. $is_downloadable = true; 
  20.  
  21. if ( wc_gzd_is_revocation_exempt( $_product, service ) ) 
  22. $is_service = true; 
  23.  
  24.  
  25. if ( get_option( 'woocommerce_gzd_checkout_legal_digital_checkbox' ) === 'yes' && $is_downloadable && ! isset( $_POST[ 'download-revocate' ] ) ) 
  26. wc_add_notice( wc_gzd_get_legal_text_digital_error(), error ); 
  27.  
  28. if ( get_option( 'woocommerce_gzd_checkout_legal_service_checkbox' ) === 'yes' && $is_service && ! isset( $_POST[ 'service-revocate' ] ) ) 
  29. wc_add_notice( wc_gzd_get_legal_text_service_error(), error ); 
  30.  
  31. if ( ( wc_gzd_is_parcel_delivery_data_transfer_checkbox_enabled( wc_gzd_get_chosen_shipping_rates( array( 'value' => 'id' ) ) ) && get_option( 'woocommerce_gzd_checkout_legal_parcel_delivery_checkbox_required' ) === 'yes' ) && ! isset( $_POST[ 'parcel-delivery' ] ) ) 
  32. wc_add_notice( __( 'Please accept our parcel delivery agreement', 'woocommerce-germanized' ), error );