Solved

textarea value

Posted on 2013-12-11
4
399 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
Comment Utility
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
Comment Utility
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 42

Accepted Solution

by:
Chris Stanyon earned 500 total points
Comment Utility
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
Comment Utility
Yeah, default did it thanks!
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Wordpress update causing pages to crash 1 18
CSS grid style change 2 13
PHP string issue 5 16
remove border from element 5 9
So you have coded your own WordPress plugin and now you want to allow users to upload images to a folder in the plugin folder rather than the default media location? Follow along and this article will show you how to do just that!
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

771 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

13 Experts available now in Live!

Get 1:1 Help Now