Skip to main content
deleted 686 characters in body; edited title
Source Link
Pieter Goosen
  • 55.4k
  • 23
  • 115
  • 209

update Update post meta in woocommerce order frontend

<?php
                                     global $post;


                                     if ( isset( $_POST['submit'] ) )
                                     {
                                     if( ! isset( $post ) ) {
                                     echo 'Error: Nichts ausgewählt';
                                     die();
                                     }
                                     else if( ! isset( $_POST['frontstrasse'] ) && ! empty( $_POST['frontstrasse'] ) ){
                                     echo 'Error: Strasse Not Set';
                                     die();
                                     }


                                     update_post_meta( $order->id, 'frontstrasse', sanitize_text_field( $_POST['Strasse'] ) );
                                     }


                                     $istrasse = get_post_meta($order->id, 'Strasse', true );


                                     echo print_r($istrasse);
                                     ?>

 
                                     <form method="post" action="">
                                     <input type='text' name='frontstrasse' value='<?php echo isset($istrasse) ? $istrasse : ''; ?>' />
                                     <input type='submit' value='save' />
                                     </form>

update post meta in woocommerce order frontend

<?php
                                     global $post;


                                     if ( isset( $_POST['submit'] ) )
                                     {
                                     if( ! isset( $post ) ) {
                                     echo 'Error: Nichts ausgewählt';
                                     die();
                                     }
                                     else if( ! isset( $_POST['frontstrasse'] ) && ! empty( $_POST['frontstrasse'] ) ){
                                     echo 'Error: Strasse Not Set';
                                     die();
                                     }


                                     update_post_meta( $order->id, 'frontstrasse', sanitize_text_field( $_POST['Strasse'] ) );
                                     }


                                     $istrasse = get_post_meta($order->id, 'Strasse', true );


                                     echo print_r($istrasse);
                                     ?>

 
                                     <form method="post" action="">
                                     <input type='text' name='frontstrasse' value='<?php echo isset($istrasse) ? $istrasse : ''; ?>' />
                                     <input type='submit' value='save' />
                                     </form>

Update post meta in woocommerce order frontend

<?php
 global $post;


 if ( isset( $_POST['submit'] ) )
 {
 if( ! isset( $post ) ) {
 echo 'Error: Nichts ausgewählt';
 die();
 }
 else if( ! isset( $_POST['frontstrasse'] ) && ! empty( $_POST['frontstrasse'] ) ){
 echo 'Error: Strasse Not Set';
 die();
 }


 update_post_meta( $order->id, 'frontstrasse', sanitize_text_field( $_POST['Strasse'] ) );
 }


 $istrasse = get_post_meta($order->id, 'Strasse', true );


 echo print_r($istrasse);
 ?>
 <form method="post" action="">
 <input type='text' name='frontstrasse' value='<?php echo isset($istrasse) ? $istrasse : ''; ?>' />
 <input type='submit' value='save' />
 </form>
Source Link

update post meta in woocommerce order frontend

I will that the custome can update in the order the custom fileds (who was insert in the checkout page)

I have this code in the order-details.php Page but it show only the value in the input but he don't update with the new value

<?php
                                     global $post;


                                     if ( isset( $_POST['submit'] ) )
                                     {
                                     if( ! isset( $post ) ) {
                                     echo 'Error: Nichts ausgewählt';
                                     die();
                                     }
                                     else if( ! isset( $_POST['frontstrasse'] ) && ! empty( $_POST['frontstrasse'] ) ){
                                     echo 'Error: Strasse Not Set';
                                     die();
                                     }


                                     update_post_meta( $order->id, 'frontstrasse', sanitize_text_field( $_POST['Strasse'] ) );
                                     }


                                     $istrasse = get_post_meta($order->id, 'Strasse', true );


                                     echo print_r($istrasse);
                                     ?>


                                     <form method="post" action="">
                                     <input type='text' name='frontstrasse' value='<?php echo isset($istrasse) ? $istrasse : ''; ?>' />
                                     <input type='submit' value='save' />
                                     </form>