Support » Plugin: Quotes for WooCommerce » Email Templates html in foreach $args

  • Resolved sinalarteweb

    (@sinalarteweb)


    According to “Email Templates” closed topic, I’m using the response of manticarodrigo (thanks a lot!).

    The only thing missing is a bit html to put the text smaller, but I can’t make it work in the echo sentence. Here’s the code:

    <table cellspacing="0" cellpadding="6" style="width: 100%; border: 1px solid #eee;" border="1" bordercolor="#eee">
    
    	<tbody>
    
    		<tr>
    			
    			<th style="text-align:center; border: 1px solid #eee;"><?php esc_html_e( 'Product', 'quote-wc' ); ?></th>
    
    			<th style="text-align:center; border: 1px solid #eee;"><?php esc_html_e( 'Quantity', 'quote-wc' ); ?></th>
    
    			<th style="text-align:center; border: 1px solid #eee;"><?php esc_html_e( 'Product Price', 'quote-wc' ); ?></th>
    
    		</tr>
    		
    	</tbody>
    
    		<?php
    		foreach ( $order_obj->get_items() as $items ) 
    		{
    			$args = array( 
    			'show_download_links' => $downloadable,
    			'show_sku' => true,
    			'show_purchase_note' => true,
    			'show_image' => true,
    			'image_size' => array( 25, 25 ));
    		}		
    			echo ($order_obj->email_order_items_table( $args )); 
    		
    		?>
    
    </table>
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Pinal Shah

    (@pinalshah)

    Hi @sinalarteweb,

    Can you kindly let me know what have you tried so far?

    You can add the font-size changes in the style attribute of the th tag.

    Please let me know if that helps.

    Thanks,
    Pinal

    Thread Starter sinalarteweb

    (@sinalarteweb)

    Hi @pinalshah ,

    If I change the style in th, only changes my table headers.
    At first I was able to manage the individual style when you have the code for the cycle with td, but this way, not all the information is displayed (images for example).

    Code with td
    Problem: Don’t know how to put the images and variation informations

    <?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
    		}
    		?>

    Code without td
    Problem: The array shows all the information I need, but since it’s array, I can’t ungroup to style each information.

    <?php
    		foreach ( $order_obj->get_items() as $items ) 
    		{			
    		$args = array('show_download_links' => $downloadable, 'show_sku' => true,'show_purchase_note' => true,'show_image' => true,'image_size' => array( 25, 25 ));	
    		}
    		echo ($order_obj->email_order_items_table( $args )); 
    		
    		?>
    </table>

    Hope I was clear.
    Thanks in advanced

    Plugin Author Pinal Shah

    (@pinalshah)

    Hi @sinalarteweb,

    I’m unsure if it will be possible to make styling changes when using an existing WC function. You could probably check if the arguments allow for any styling changes.

    Thanks,
    Pinal

    Thread Starter sinalarteweb

    (@sinalarteweb)

    Hi @pinalshah ,

    I solve this topic making a workaround on the email-order-items.php. I copy the file to my child theme and made the styling changes there, so the request-new-quote.php is done. The echo ($order_obj->email_order_items_table( $args )); loads exactly what I need, with the right style.

    But now I’m dealing with other situation in the template new-request-sent-customer.php. I would like the customer to see all the information as request-new-quote.php but not the price.

    I notice you use the if ($display_price) which is good, but how can I insert the image, sku and variations? If I put echo ($order_obj->email_order_items_table( $args )); the price is shown and I can’t have another personalized email-order-items.php in my child theme.

    I try to copy the line “get_name”, and change to “get_sku”, but it didn’t work.

    <td style="text-align:left; border: 1px solid #eee;"><?php echo wp_kses_post( $items->get_sku() ); ?></td>

    Thanks!

    Plugin Author Pinal Shah

    (@pinalshah)

    Hi @sinalarteweb,

    The get_sku() applies on the product object and not the order items.

    You can fetch the SKU inside the existing foreach loop as below:

    1. Fetch the product ID: $product_id = $items->get_product_id();
    2. Fetch the product object using the product ID: $_product = wc_get_product( $product_id );
    3. Fetch the SKU: $sku = $_product->get_sku()

    I hope you enjoy using the plugin. Please consider leaving a review for the plugin here.

    Thanks,
    Pinal

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.