Solved

textarea value

Posted on 2013-12-11
4
401 Views
Last Modified: 2013-12-11
I'm trying to modify some wordpress files and I don't know what the "value" is called within a text area.

The textarea is created with this code:
$this->checkout_fields['order']	= array(
			'order_comments' => array(
				'type' => 'textarea',
				'class' => array('notes'),
				'label' => __( 'Order Notes', 'woocommerce' ),
				'placeholder' => _x('Notes about your order, e.g. special notes for delivery.', 'placeholder', 'woocommerce')
				)
			);

		$this->checkout_fields = apply_filters( 'woocommerce_checkout_fields', $this->checkout_fields );

		do_action( 'woocommerce_checkout_init', $this );

Open in new window


I need to put a value of a variable in that textarea.  I tried the following code but it does nothing.
$this->checkout_fields['order']	= array(
			'order_comments' => array(
				'type' => 'textarea',
				'class' => array('notes'),
				'label' => __( 'Order Notes', 'woocommerce' ),
				'placeholder' => _x('Notes about your order, e.g. special notes for delivery.', 'placeholder', 'woocommerce')
                'value' => $giftmsg
				)
			);

		$this->checkout_fields = apply_filters( 'woocommerce_checkout_fields', $this->checkout_fields );

		do_action( 'woocommerce_checkout_init', $this );

Open in new window

0
Comment
Question by:N R
  • 2
4 Comments
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 39712015
The "value" might actually be working.  Try removing the placeholder or replacing the contents of the placeholder string with the $giftmsg variable.  You will want to use double quotes to get variable substitution.
0
 
LVL 11

Author Comment

by:N R
ID: 39712025
If I put the variable in the contents of the placeholder my $giftmsg does show up so I know the variable is being populated.  But I need it to be the value of the field not just a placeholder.
0
 
LVL 43

Accepted Solution

by:
Chris Stanyon earned 500 total points
ID: 39712032
I think you might want to try 'default' instead of value:

$this->checkout_fields['order']	= array(
   'order_comments' => array(
      'type' => 'textarea',
      'class' => array('notes'),
      'label' => __( 'Order Notes', 'woocommerce' ),
      'placeholder' => _x('Notes about your order, e.g. special notes for delivery.', 'placeholder', 'woocommerce'),
      'default' => $giftmsg
   )
);

Open in new window

You also have a comma missing after your 'placeholder' key
0
 
LVL 11

Author Closing Comment

by:N R
ID: 39712041
Yeah, default did it thanks!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Problem with a CSS in a page 2 25
Wordpress Carousel Size 1 14
updating the date data 12 20
bootstrap footer centering and expand problems 7 21
This article discusses how to create an extensible mechanism for linked drop downs.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
The purpose of this video is to demonstrate how to reset a WordPress password if you are locked out and cannot reset the password. A typical use would be if you cannot access the email to which WordPress would send the password recovery email to…
The viewer will learn how to count occurrences of each item in an array.

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now