Empty Quote Email
-
Every now and then I occasionally get Blank or empty Product details in my email notifications, I’m talking about the “Product , Quantity and Subtotal” Table content, and the table “Header” show but the table data will be blank,
PS: Every thing above and below the table data in the mail works as expected, so it’s not a “WordPress Critical Error”
It is also important to mention that I added some custom code to add some fields and all, I’ll attach the code below as well,
Looking forward to hearing from you
Warm regards
<?php
/**
* HTML Template Email
*
* @package YITH\RequestAQuote
* @since 1.0.0
* @version 1.5.3
* @author YITH <[email protected]>
*
* @var $email_heading array
* @var $raq_data array
* @var $email
*/
// Fetching the user object using the email from $raq_data
$user = get_user_by('email', $raq_data['user_email']);
$username = $user ? $user->user_login : '';
$first_name = $user ? get_user_meta($user->ID, 'first_name', true) : '';
$last_name = $user ? get_user_meta($user->ID, 'last_name', true) : '';
$full_name = trim($first_name . ' ' . $last_name);
?>
<?php do_action( 'woocommerce_email_header', $email_heading, $email ); ?>
<p>
<?php
printf( esc_html__( 'You received a quote request from %s. The request is the following:', 'yith-woocommerce-request-a-quote' ), esc_html( $full_name ) );
echo '<br>';
printf( esc_html__( 'The Username is %s.', 'yith-woocommerce-request-a-quote' ), esc_html( $username ) );
echo '<br>';
printf( esc_html__( 'The Full Name is %s.', 'yith-woocommerce-request-a-quote' ), esc_html( $full_name ) );
echo '<br>';
printf( esc_html__( 'The Email Address is %s.', 'yith-woocommerce-request-a-quote' ), esc_html( $raq_data['user_email'] ) );
?>
</p>
<?php do_action( 'yith_ywraq_email_before_raq_table', $raq_data ); ?>
<h2><?php esc_html_e( 'Quote request', 'yith-woocommerce-request-a-quote' ); ?></h2>
<table cellspacing="0" cellpadding="6" style="width: 100%; border: 1px solid #eee; margin-bottom:30px" border="1" bordercolor="#eee">
<thead>
<tr>
<th scope="col" style="text-align:left; border: 1px solid #eee;"><?php esc_html_e( 'Product', 'yith-woocommerce-request-a-quote' ); ?></th>
<th scope="col" style="text-align:left; border: 1px solid #eee;"><?php esc_html_e( 'ISBNs', 'yith-woocommerce-request-a-quote' ); ?></th>
<th scope="col" style="text-align:left; border: 1px solid #eee;"><?php esc_html_e( 'Quantity', 'yith-woocommerce-request-a-quote' ); ?></th>
<th scope="col" style="text-align:left; border: 1px solid #eee;"><?php esc_html_e( 'Subtotal', 'yith-woocommerce-request-a-quote' ); ?></th>
</tr>
</thead>
<tbody>
<?php
if ( ! empty( $raq_data['raq_content'] ) ) :
foreach ( $raq_data['raq_content'] as $item ) :
$_product = isset( $item['variation_id'] ) ? wc_get_product( $item['variation_id'] ) : wc_get_product( $item['product_id'] );
if ( ! $_product ) {
continue;
}
$product_admin_link = '';
$posttype_object = get_post_type_object( get_post( $_product->get_id() )->post_type );
if ( ( $posttype_object ) && ( $posttype_object->_edit_link ) ) {
$product_admin_link = admin_url( sprintf( $posttype_object->_edit_link . '&action=edit', $_product->get_id() ) );
}
// Get the ACF field value for unique_id_number
$unique_id_number = get_field('unique_id_number', $_product->get_id());
?>
<tr>
<td scope="col" style="text-align:left;"><a href="<?php echo esc_url( $product_admin_link ); ?>"><?php echo wp_kses_post( $_product->get_title() ); ?></a>
<?php if ( isset( $item['variations'] ) ) : ?>
<small><?php echo wp_kses_post( yith_ywraq_get_product_meta( $item ) ); ?></small>
<?php endif ?>
</td>
<td scope="col" style="text-align:left;"><?php echo esc_html( $unique_id_number ); ?></td>
<td scope="col" style="text-align:left;"><?php echo esc_html( $item['quantity'] ); ?></td>
<td scope="col" style="text-align:left;"><?php echo wp_kses_post( WC()->cart->get_product_subtotal( $_product, (int) $item['quantity'] ) ); ?></td>
</tr>
<?php
endforeach;
endif;
?>
</tbody>
</table>
<?php do_action( 'yith_ywraq_email_after_raq_table', $raq_data ); ?>
<?php if ( ! empty( $raq_data['user_message'] ) ) : ?>
<h2><?php esc_html_e( 'Customer message', 'yith-woocommerce-request-a-quote' ); ?></h2>
<p><?php echo wp_kses_post( $raq_data['user_message'] ); ?></p>
<?php endif ?>
<h2><?php esc_html_e( 'Customer details', 'yith-woocommerce-request-a-quote' ); ?></h2>
<p><strong><?php esc_html_e( 'Username:', 'yith-woocommerce-request-a-quote' ); ?></strong> <?php echo esc_html( $username ); ?></p>
<p><strong><?php esc_html_e( 'Name:', 'yith-woocommerce-request-a-quote' ); ?></strong> <?php echo esc_html( $full_name ); ?></p>
<p><strong><?php esc_html_e( 'Email:', 'yith-woocommerce-request-a-quote' ); ?></strong> <a href="mailto:<?php echo esc_attr( $raq_data['user_email'] ); ?>"><?php echo esc_html( $raq_data['user_email'] ); ?></a></p>
<?php do_action( 'woocommerce_email_footer' ); ?>
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- You must be logged in to reply to this topic.