<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.2" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Support Forum - Topic: Coding Question</title>
		<link>http://www.kriesi.at/support/topic/coding-question</link>
		<description>Support Forum - Topic: Coding Question</description>
		<language>en-US</language>
		<pubDate>Fri, 24 May 2013 03:28:05 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.2</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>http://www.kriesi.at/support/search.php</link>
		</textInput>
		<atom:link href="http://www.kriesi.at/support/rss/topic/coding-question" rel="self" type="application/rss+xml" />

		<item>
			<title>Ismael on "Coding Question"</title>
			<link>http://www.kriesi.at/support/topic/coding-question#post-74599</link>
			<pubDate>Thu, 06 Sep 2012 00:40:31 +0000</pubDate>
			<dc:creator>Ismael</dc:creator>
			<guid isPermaLink="false">74599@http://www.kriesi.at/support/</guid>
			<description>&#60;p&#62;Hey,&#60;/p&#62;
&#60;p&#62;Glad Peter could help.&#60;/p&#62;
&#60;p&#62;Regards,&#60;br /&#62;
Ismael
&#60;/p&#62;</description>
		</item>
		<item>
			<title>minnoe on "Coding Question"</title>
			<link>http://www.kriesi.at/support/topic/coding-question#post-74588</link>
			<pubDate>Wed, 05 Sep 2012 22:40:16 +0000</pubDate>
			<dc:creator>minnoe</dc:creator>
			<guid isPermaLink="false">74588@http://www.kriesi.at/support/</guid>
			<description>&#60;p&#62;Thank you Peter. You've brought me closer to my ecommerce riches!&#60;br /&#62;
Minnoe
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Dude on "Coding Question"</title>
			<link>http://www.kriesi.at/support/topic/coding-question#post-74449</link>
			<pubDate>Wed, 05 Sep 2012 06:58:51 +0000</pubDate>
			<dc:creator>Dude</dc:creator>
			<guid isPermaLink="false">74449@http://www.kriesi.at/support/</guid>
			<description>&#60;p&#62;You use the same function name several times. (my_custom_checkout_field). Use following code instead:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;/**
* Add the field to the checkout
**/
add_action(&#38;#39;woocommerce_after_order_notes&#38;#39;, &#38;#39;minnoe_ordernotes_custom_checkout_field&#38;#39;);

function minnoe_ordernotes_custom_checkout_field( $checkout ) {
echo &#38;#39;&#38;lt;div id=&#38;quot;my_custom_checkout_field&#38;quot;&#38;gt;&#38;lt;h3&#38;gt;&#38;#39;.__(&#38;#39;Delivery Date&#38;#39;).&#38;#39;&#38;lt;/h3&#38;gt;&#38;#39;;
woocommerce_form_field( &#38;#39;delivery_date_name&#38;#39;, array(
&#38;#39;type&#38;#39; =&#38;gt; &#38;#39;text&#38;#39;, &#38;#39;class&#38;#39; =&#38;gt; array(&#38;#39;delivery-date-class form-row-wide&#38;#39;),
&#38;#39;label&#38;#39; =&#38;gt; __(&#38;#39;Eg. Tues, July 22.&#38;#39;),
&#38;#39;placeholder&#38;#39; =&#38;gt; __(&#38;#39;Date of Delivery&#38;#39;),
), $checkout-&#38;gt;get_value( &#38;#39;my_field_name&#38;#39; ));
echo &#38;#39;&#38;lt;/div&#38;gt;&#38;#39;;
}
/**
* Process the checkout
**/add_action(&#38;#39;woocommerce_checkout_process&#38;#39;, &#38;#39;minnoe_delivery_custom_checkout_field_process&#38;#39;);
function minnoe_delivery_custom_checkout_field_process() {
global $woocommerce;
// Check if set, if its not set add an error.
if (!$_POST[&#38;#39;delivery_date_name&#38;#39;])
$woocommerce-&#38;gt;add_error( __(&#38;#39;Please enter delivry date.&#38;#39;) );
}
/** * Update the order meta with field value
**/
add_action(&#38;#39;woocommerce_checkout_update_order_meta&#38;#39;, &#38;#39;minnoe_delivery_custom_checkout_field_update_order_meta&#38;#39;);
function minnoe_delivery_custom_checkout_field_update_order_meta( $order_id ) {
if ($_POST[&#38;#39;delivery_date_name&#38;#39;]) update_post_meta( $order_id, &#38;#39;Delivery Date&#38;#39;, esc_attr($_POST[&#38;#39;delivery_date_name&#38;#39;]));
}

/**
* Add the field to the checkout
**/
add_action(&#38;#39;woocommerce_after_order_notes&#38;#39;, &#38;#39;minnoe_notes_custom_checkout_field&#38;#39;);

function minnoe_notes_custom_checkout_field( $checkout ) {
echo &#38;#39;&#38;lt;div id=&#38;quot;my_custom_checkout_field&#38;quot;&#38;gt;&#38;lt;h3&#38;gt;&#38;#39;.__(&#38;#39;Recipeint Phone&#38;#39;).&#38;#39;&#38;lt;/h3&#38;gt;&#38;#39;;
woocommerce_form_field( &#38;#39;recipient_phone_name&#38;#39;, array(
&#38;#39;type&#38;#39; =&#38;gt; &#38;#39;text&#38;#39;, &#38;#39;class&#38;#39; =&#38;gt; array(&#38;#39;recipient-phone-class form-row-wide&#38;#39;),
&#38;#39;label&#38;#39; =&#38;gt; __(&#38;#39;Home &#38;amp; or Cell&#38;#39;),
&#38;#39;placeholder&#38;#39; =&#38;gt; __(&#38;#39;Both numbers would be great!&#38;#39;),
), $checkout-&#38;gt;get_value( &#38;#39;recipeint_phone_name&#38;#39; ));
echo &#38;#39;&#38;lt;/div&#38;gt;&#38;#39;;
}
/**
* Process the checkout
**/add_action(&#38;#39;woocommerce_checkout_process&#38;#39;, &#38;#39;minnoe_custom_checkout_field_process&#38;#39;);
function minnoe_custom_checkout_field_process() {
global $woocommerce;
// Check if set, if its not set add an error.
if (!$_POST[&#38;#39;recipeint_phone_name&#38;#39;])
$woocommerce-&#38;gt;add_error( __(&#38;#39;Please enter phone number.&#38;#39;) );
}
/** * Update the order meta with field value
**/
add_action(&#38;#39;woocommerce_checkout_update_order_meta&#38;#39;, &#38;#39;minnoe_custom_checkout_field_update_order_meta&#38;#39;);
function minnoe_custom_checkout_field_update_order_meta( $order_id ) {
if ($_POST[&#38;#39;delivery_date_name&#38;#39;]) update_post_meta( $order_id, &#38;#39;Recipient Phone&#38;#39;, esc_attr($_POST[&#38;#39;my_field_name&#38;#39;]));
}&#60;/code&#62;&#60;/pre&#62;</description>
		</item>
		<item>
			<title>minnoe on "Coding Question"</title>
			<link>http://www.kriesi.at/support/topic/coding-question#post-74413</link>
			<pubDate>Tue, 04 Sep 2012 23:31:53 +0000</pubDate>
			<dc:creator>minnoe</dc:creator>
			<guid isPermaLink="false">74413@http://www.kriesi.at/support/</guid>
			<description>&#60;p&#62;Hey Abundance-&#60;br /&#62;
I've added this coding to my functions.php file:&#60;/p&#62;
&#60;p&#62;/**&#60;br /&#62;
 * Add the field to the checkout&#60;br /&#62;
 **/&#60;br /&#62;
add_action('woocommerce_after_order_notes', 'my_custom_checkout_field');&#60;/p&#62;
&#60;p&#62;function my_custom_checkout_field( $checkout ) {&#60;br /&#62;
     echo '&#38;lt;div id=&#34;my_custom_checkout_field&#34;&#38;gt;&#38;lt;h3&#38;gt;'.__('Delivery Date').'&#38;lt;/h3&#38;gt;';&#60;br /&#62;
     woocommerce_form_field( 'delivery_date_name', array(&#60;br /&#62;
        'type'          =&#38;gt; 'text',        'class'         =&#38;gt; array('delivery-date-class form-row-wide'),&#60;br /&#62;
        'label'         =&#38;gt; __('Eg. Tues, July 22.'),&#60;br /&#62;
        'placeholder'       =&#38;gt; __('Date of Delivery'),&#60;br /&#62;
       ), $checkout-&#38;gt;get_value( 'my_field_name' ));&#60;br /&#62;
     echo '&#38;lt;/div&#38;gt;';&#60;br /&#62;
 }&#60;br /&#62;
/**&#60;br /&#62;
 * Process the checkout&#60;br /&#62;
 **/add_action('woocommerce_checkout_process', 'my_custom_checkout_field_process');&#60;br /&#62;
function my_custom_checkout_field_process() {&#60;br /&#62;
    global $woocommerce;&#60;br /&#62;
     // Check if set, if its not set add an error.&#60;br /&#62;
    if (!$_POST['delivery_date_name'])&#60;br /&#62;
         $woocommerce-&#38;gt;add_error( __('Please enter delivry date.') );&#60;br /&#62;
}&#60;br /&#62;
/** * Update the order meta with field value&#60;br /&#62;
 **/&#60;br /&#62;
add_action('woocommerce_checkout_update_order_meta', 'my_custom_checkout_field_update_order_meta');&#60;br /&#62;
 function my_custom_checkout_field_update_order_meta( $order_id ) {&#60;br /&#62;
    if ($_POST['delivery_date_name']) update_post_meta( $order_id, 'Delivery Date', esc_attr($_POST['delivery_date_name']));&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;WORKS GREAT! I can see my new custom field reads Delivery Date. The problem happens when I want to add another custom field to read Recipeint Phone. I add the following code right underneath the above:&#60;/p&#62;
&#60;p&#62;/**&#60;br /&#62;
 * Add the field to the checkout&#60;br /&#62;
 **/&#60;br /&#62;
add_action('woocommerce_after_order_notes', 'my_custom_checkout_field');&#60;/p&#62;
&#60;p&#62;function my_custom_checkout_field( $checkout ) {&#60;br /&#62;
     echo '&#38;lt;div id=&#34;my_custom_checkout_field&#34;&#38;gt;&#38;lt;h3&#38;gt;'.__('Recipeint Phone').'&#38;lt;/h3&#38;gt;';&#60;br /&#62;
     woocommerce_form_field( 'recipient_phone_name', array(&#60;br /&#62;
        'type'          =&#38;gt; 'text',        'class'         =&#38;gt; array('recipient-phone-class form-row-wide'),&#60;br /&#62;
        'label'         =&#38;gt; __('Home &#38;amp; or Cell'),&#60;br /&#62;
        'placeholder'       =&#38;gt; __('Both numbers would be great!'),&#60;br /&#62;
       ), $checkout-&#38;gt;get_value( 'recipeint_phone_name' ));&#60;br /&#62;
     echo '&#38;lt;/div&#38;gt;';&#60;br /&#62;
 }&#60;br /&#62;
/**&#60;br /&#62;
 * Process the checkout&#60;br /&#62;
 **/add_action('woocommerce_checkout_process', 'my_custom_checkout_field_process');&#60;br /&#62;
function my_custom_checkout_field_process() {&#60;br /&#62;
    global $woocommerce;&#60;br /&#62;
     // Check if set, if its not set add an error.&#60;br /&#62;
    if (!$_POST['recipeint_phone_name'])&#60;br /&#62;
         $woocommerce-&#38;gt;add_error( __('Please enter phone number.') );&#60;br /&#62;
}&#60;br /&#62;
/** * Update the order meta with field value&#60;br /&#62;
 **/&#60;br /&#62;
add_action('woocommerce_checkout_update_order_meta', 'my_custom_checkout_field_update_order_meta');&#60;br /&#62;
 function my_custom_checkout_field_update_order_meta( $order_id ) {&#60;br /&#62;
    if ($_POST['delivery_date_name']) update_post_meta( $order_id, 'Recipient Phone', esc_attr($_POST['my_field_name']));&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;My site just goes blank. Can someone tell me if there's something wrong with the second part of this coding?&#60;br /&#62;
Minnoe
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
