Data from Check-out fields not showing in Email Notification
-
Hello Pinal!
I’ve just about got this plugin completely setup!
I’m just having troubles including some data from the check-out fields into the email notification.I have copied the request-new-quote.php to the correct folder and have made some changes that are applying, but am getting “Internal Server Error” when I try creating the variables. When I remove the variables that I add, the “Internal Server Error” goes away, and the process works, but without the data from the fields that I’d like in the email notification.
Any assistance would be a great help!
Here is my code thus far:
<?php /** * Request New Quote email * * @package Quotes for WooCommerce/Email Templates */ $order_obj = new WC_order( $order->order_id ); // translators: Billing Name. $opening_paragraph = __( 'A request for quote has been made by %s and is awaiting your attention. The details of the order are as follows:', 'quote-wc' ); ?> <?php do_action( 'woocommerce_email_header', $email_heading ); ?> <?php $billing_first_name = ( version_compare( WOOCOMMERCE_VERSION, '3.0.0' ) < 0 ) ? $order_obj->billing_first_name : $order_obj->get_billing_first_name(); $billing_last_name = ( version_compare( WOOCOMMERCE_VERSION, '3.0.0' ) < 0 ) ? $order_obj->billing_last_name : $order_obj->get_billing_last_name(); //START - (New Fields) These were added in order to include the Rental Start Date, Rental Term, and Quote Notes variables $start_date = ( version_compare( WOOCOMMERCE_VERSION, '3.0.0' ) < 0 ) ? $order_obj->start_date : $order_obj->get_start_date(); $rental_term = ( version_compare( WOOCOMMERCE_VERSION, '3.0.0' ) < 0 ) ? $order_obj->rental_term : $order_obj->get_rental_term(); $order_comments = ( version_compare( WOOCOMMERCE_VERSION, '3.0.0' ) < 0 ) ? $order_obj->order_comments : $order_obj->get_order_comments(); //END - (New Fields) if ( $order && $billing_first_name && $billing_last_name ) : ?> <p><?php echo sprintf( esc_html( $opening_paragraph ), esc_html( $billing_first_name . ' ' . $billing_last_name ) ); ?></p> <?php endif; ?> <table cellspacing="0" cellpadding="6" style="width: 100%; border: 1px solid #eee;" border="1" bordercolor="#eee"> <tbody> <tr> <th style="text-align:left; border: 1px solid #eee;"><?php esc_html_e( 'Product', 'quote-wc' ); ?></th> <th style="text-align:left; border: 1px solid #eee;"><?php esc_html_e( 'Quantity', 'quote-wc' ); ?></th> <th style="text-align:left; border: 1px solid #eee;"><?php esc_html_e( 'Product Price', 'quote-wc' ); ?></th> </tr> <?php foreach ( $order_obj->get_items() as $items ) { ?> <tr> <td style="text-align:left; border: 1px solid #eee;"><?php echo wp_kses_post( $items->get_name() ); ?></td> <td style="text-align:left; border: 1px solid #eee;"><?php echo esc_attr( $items->get_quantity() ); ?></td> <td style="text-align:left; border: 1px solid #eee;"><?php echo wp_kses_post( $order_obj->get_formatted_line_subtotal( $items ) ); ?></td> </tr> <?php } ?> </tbody> </table> <!-- START - (New Field Data Insertion) Rental Start Date, Rental Term, and Quote Notes fields placed in email notification here. --> <br> <p><?php echo "Requested Start Date: ";?><?php echo esc_html( $start_date );?></p> <p><?php echo "Rental Term: ";?><?php echo esc_html( $rental_term );?></p> <p><?php echo "Additional Notes: ";?><?php echo esc_html( $order_comments );?></p> <!-- END - (New Field Data Insertion) Rental Start Date, Rental Term, and Quote Notes fields placed in email notification here. --> <p><?php esc_html_e( 'This order is awaiting a quote.', 'quote-wc' ); ?></p> <p> <?php // translators: Admin Url for payment. echo wp_kses_post( make_clickable( sprintf( __( 'You can view and edit this order in the dashboard here: %s', 'quote-wc' ), esc_url( admin_url( 'post.php?post=' . $order->order_id . '&action=edit' ) ) ) ) ); ?> </p> <?php do_action( 'woocommerce_email_customer_details', $order_obj, $sent_to_admin, $plain_text, $email ); ?> <?php do_action( 'woocommerce_email_footer' ); ?>
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Data from Check-out fields not showing in Email Notification’ is closed to new replies.