• Resolved ytian03

    (@ytian03)


    Hello,
    
    Can anyone help me with my problem? We had this custom plugin in a while and we noticed that when the user put special characters, it will trigger infinite loop on the server or the server/page just keep on loading.
    
    My question is how can I restrict the user on inputting special characters on the specific field.
    
    Here is a sample code from the custom plugin.
    
    // checkout page, show purchase order field
    
    add_action( 'woocommerce_after_order_notes', 'pof_purchase_order_field' );
    function pof_purchase_order_field( $checkout ) {
    print 'Purchase Order NEW
    
    '.PHP_EOL; woocommerce_form_field( '_purchase_order', array( 'type' => 'text', 'class' => array('pof_purchase_order_field form-row-wide'), 'label' => 'Purchase Order', 'placeholder' => 'Purchase Order', 'required' => false, 'maxlength' => 15, ), $checkout->get_value( '_purchase_order' )); print ''.PHP_EOL;
    } // end function
    
    // place order, validate the purchase order field
    add_action('woocommerce_checkout_process', 'pof_validate_purchase_order_field');
    function pof_validate_purchase_order_field() {
    return;
    // check if set, if its not set add an error.
    if ( ! $_POST['_purchase_order'] ) {
    wc_add_notice( 'The Purchase Order field may not be empty.', 'error' );
    }
    } // end function
    
    // save order, save purchase order field
    
    add_action( 'woocommerce_new_order', 'pof_new_order' );
    function pof_new_order( $order_id ) {
    if( isset( $_POST['_purchase_order'] ) ) {
    $purchase_order = $_POST['_purchase_order'];
    $previous_value = get_post_meta( $order_id, '_purchase_order', true );
    update_post_meta( $order_id, '_purchase_order', $purchase_order, $previous_value );
    }
    } // end function
    
    // thankyou and view order pages, show purchase order field
Viewing 1 replies (of 1 total)
  • Hi @ytian03

    Thanks for reaching out!

    Can anyone help me with my problem? We had this custom plugin in a while and we noticed that when the user put special characters, it will trigger infinite loop on the server or the server/page just keep on loading.

    I understand that you are using a custom plugin on your site and you’re having issues with it.

    This is a bit of a complicated topic that would need some customization to address. Unfortunately, custom coding is not something we can assist with directly. However, I’ll keep this thread open for a bit to see if anyone from the community can lend a hand.

    If you have any other questions related to development or custom coding, don’t hesitate to reach out to some of the great resources we have available for support. The WooCommerce community is filled with talented open-source developers, and many of them are active on the channels listed below:

    Hope this helps!

Viewing 1 replies (of 1 total)
  • The topic ‘Infinite loop when inserting special character’ is closed to new replies.