Solved

textarea value

Posted on 2013-12-11
4
403 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 109

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Find out what you should include to make the best professional email signature for your organization.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

778 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