Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter ft981

    (@tomasp98)

    I have tried but still, I can’t get the field to be displayed in the attachment. However, I do see the value in the woocommerce backoffice. I can also see it on the invoice preview. The problem comes when the automatic mail is sent with the attached file, it disappears there. The field contains value because I can see it in the order details. Could it be that it has something to do with the function? The mail is being executed before the function and that is why when the attachment is sent the value will be null. But I dont know if thats the problem

    Here is the code of the invoice.php

    table class="tabla100">
          <tr>
             <td>
                <h3>Presupuesto previo (no vinculante)</h3>
             </td>
             <td>
                [logo]
             </td>
          </tr>
          <tr>
             <td colspan="2" class="dataHeader">
                <b>Presupuesto:</b> <?php $this->order_number(); ?><br>
                <b>Cliente:</b> <?php $this->custom_field('billing_first_name'); ?>&nbsp;<?php $this->custom_field('billing_last_name'); ?>&nbps;<?php $this->billing_email(); ?><br>
                <b>Fecha:</b> <?php $this->invoice_date(); ?><br>
                <b>Delegacion:</b> <?php  $this->custom_field('_billing_wcj_checkout_field_2'); ?>
             </td>
          </tr>
       </table>

    Thread Starter ft981

    (@tomasp98)

    Of course, here is the code snipet

    Presupuesto: order_number(); ?>
    Cliente: custom_field('billing_first_name'); ?> custom_field('billing_last_name'); ?> billing_email(); ?>
    Fecha: invoice_date(); ?>
    Delegacion: custom_field('billing_wcj_checkout_field_2'); ?>

    The only field that is not showing me is the billing_wcj_checkout_field_2. I can see it in the page preview in the plugin, but it is not sent correctly when the invoice is sent to the mail

    This is the function I use to assign the value

    add_action( 'woocommerce_thankyou', 'bbloomer_alter_checkout_fields_after_order', 10, 1 );
    function bbloomer_alter_checkout_fields_after_order( $order_id ) {
    	
       $order = wc_get_order( $order_id );
       $delegacion = '';
    	
    	// TARGET-ZIP-CODE
    	$zonaTest= array( '12564', '23453');
    
    	// User ZIP-CODE 
    	$user_zip_zone =  $order->get_shipping_postcode();
    	if(empty($user_shipping_postcode))
    		$user_zip_zone = $order->get_billing_postcode();
    	
    
       if ( in_array( $user_zip_zone, $zonaTest)) {
          $delegacion = 'test test / test@test.com / test';
          update_post_meta( $order_id, '_billing_wcj_checkout_field_2', $delegacion );   
       }   
    }
Viewing 2 replies - 1 through 2 (of 2 total)