• There is an older forum post which answers this question. But the answer is inside a picture that is an expired link and cannot be viewed.
    So anyway I thought I would show the solution here so it might help people wanting to do the same thing. I was trying to add the SKU part numbers to emails sent as part of the Request New quote email. But get_sku() does not work on the object I was trying it on. In request-new-quote.php –

    under the foreach loop –
    foreach ( $order_obj->get_items() as $items ) {
    $product = $items->get_product(); // get_sku() can only be used on the product object

    and then in your table you can add a new line
    <td style=”text-align:left; border: 1px solid #eee;”><?php echo wp_kses_post( $product->get_sku() ); ?></td>

    Gavin

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author pinal.shah

    (@pinalshah)

    Hi Gavin,

    Thank you for posting the solution here. I’m sure it will help any future users of the plugin trying to achieve the same.

    Thanks,
    Pinal

    Hi,

    I am trying to follow Gavin’s solution and apologies I have little coding experience
    and as Gavin said the link is no longer working with solution.
    Perhaps I am missing another bit of code. I just want all email to display the SKU as we have variable products and at the moment when email sent we cannot see the variations so SKU helpful.

    Any help would be greatly appreciated

    <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( 'SKU', '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 ) {
    $product = $items->get_product();
    			?>
     			<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>
                    <td style="text-align:left; border: 1px solid #eee;"><?php echo wp_kses_post( $product->get_sku() ); ?></td>
    			</tr>
    			<?php
    		}
    
    	</tbody>
    </table>
    
    Plugin Author pinal.shah

    (@pinalshah)

    Hi @austpack,

    I presume the above code is causing the data to be displayed incorrectly. i.e. SKU is displayed in the last column instead of being displayed in the second column. This is due to the fact that you’ve arranged the <td> tags differently as compared to the <th> tags.

    The correct solution would be something as below:

    <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( 'SKU', '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 ) {
    $product = $items->get_product();
    			?>
     			<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 wp_kses_post( $product->get_sku() ); ?></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>

    Please let me know if this helps.

    Thanks,
    Pinal

    Hi @pinalshah

    Thank you so much that worked :).

    I really appreciate this plugin and can’t wait for the updates it is very intuitive to how a quote process works.

    Thank you

    Plugin Author pinal.shah

    (@pinalshah)

    Hi @austpack,

    I’m glad to know that helped. Thanks for appreciating the plugin. It would help me immensely if you would be so kind as to consider rating the plugin here.

    Thanks,
    Pinal

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Add SKU to the order list in the Request Email’ is closed to new replies.