0

i have add 4 custom fields in the checkout page (in functions.php )

Now i show the value in the Order page with

get_post_meta( $order->id, 'My Field', true )

I need that the customer can edit the Value on the order Page (front-end) if the order status is processing.

I dont know who can i make this.

I have try to use the acf Plugin (ACF Plugin)

for use this on the checkout page. But i found nothing and the support of acf dont anwser to this topic.

The next way was that i try to load the custom filed value as "default_value" of the acf input Plugin. But it dont work.

function my_acf_load_field( $field ) {

 //$acfstrasse = get_field('field_name', $post_id);
 $acfstrasse = get_post_meta( $order->id, 'Strasse', true );

 $field['default_value'] = $acfstrasse;
 return $field;

}
add_filter('acf/load_field/name=field_name', 'my_acf_load_field');

I hope you know a way that the customer can edit the value of the custom field on the order page (front-end)

Thanks !!

Sorry for my english. (German is my language)

0

I found a solution.

i have use this code on my order-details.php Page

 <?php
         global $post;

         $post = $order_id;

           if ( isset( $_POST['submit'] ) )
             {
                     echo 'Update nicht';
             } else  if ( ! empty( $_POST['frontstrasse'] ) ) {
            update_post_meta( $order_id, 'Strasse', sanitize_text_field( $_POST['frontstrasse'] ) );
            update_post_meta( $order_id, 'Haus-Nr', sanitize_text_field( $_POST['fronthausnr'] ) );


}
$istrasse = get_post_meta($order->id, 'Strasse', true );
$ihausnr = get_post_meta($order->id, 'Haus-Nr', true );

  ?>

 <form method="post" action="">
<label>Strasse</label><input type='text' name='frontstrasse' value='<?php echo $istrasse ?>' />
<label>Haus-Nr</label><input type='text' name='fronthausnr' value='<?php echo  $ihausnr ?>' />
<input type='submit' value='save' name='frontsubmit' />
 </form>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.