Support » Plugin: F4 Salutation Fields for WooCommerce » Salutation inside E-Mails

  • Resolved milo1988

    (@milo1988)


    I’m not that familiar with php, so hopefully you could help me out. Your plugin is working great in our checkout area, but i won’t show the salutation inside the order E-Mails. We’re using storefront as the theme and checkoutwc for the checkout.

    The PHP Snippet wich is inside customer-on-hold-order.php is

    <p><?php printf( esc_html__( ' {salutation} Hi %s,', 'woocommerce' ), esc_html( $order->get_billing_first_name() ) ); ?></p>

    But i won’t show the salutation. What exactly is am i doing wrong? Our goal is it to show it like this “Sehr geehrte Frau Nadine Muster”. Hope you could help me out

    • This topic was modified 5 months, 3 weeks ago by milo1988.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author F4

    (@faktorvier)

    Hi @milo1988

    The following snippet should output the salutation like your desired goal:

    <p>
      <?php
        $salutation = get_post_meta($order->get_id(), '_billing_salutation', true);
    
        printf(
          '%s %s',
          $salutation === 'mr' ? 'Sehr geehrter Herr' : 'Sehr geehrte Frau',
          esc_html( $order->get_formatted_billing_full_name()),
        );
      ?>
    </p>

    The snippet is not tested. If there’s an error or its not working at all, feel free to contact us again!

    Thread Starter milo1988

    (@milo1988)

    Thank you so much. Exactly what i was looking for

    Giulio Alfonso

    (@senjoralfonso)

    Hi, in the standard e-mails there is just

    <p><?php printf( esc_html__( ‘Hi %s,’, ‘woocommerce’ ), esc_html( $user_login ) ); ?></p>

    without the order-id, is it also possible to use the salutation there?

    Plugin Author F4

    (@faktorvier)

    Hi @senjoralfonso

    This should work:

    <p>
    	<?php
    		$salutation = get_user_meta($user_id, 'billing_salutation', true);
    		
    		if(!empty($salutation)) {
    			$salutation_label =  \F4\WCSF\Core\Hooks::get_option_label($salutation); 
    			
    			printf( esc_html__( ‘Hi %s,’, ‘woocommerce’ ), esc_html( "{$salutation_label} {$user_login}" ) );
    		} else {
    			printf( esc_html__( ‘Hi %s,’, ‘woocommerce’ ), esc_html( $user_login ) );
    		}
    	?>
    </p>
    

    Let me know if its not working or not what you’ve expected.

    With your code as help, I wrote this, which is working for me:

    `<?php
    $salutation = get_user_meta($user_id, ‘billing_salutation’, true);

    printf(
    ‘%s %s’,
    $salutation === ‘mr’ ? ‘Sehr geehrter Herr’ : ‘Sehr geehrte Frau’,
    esc_html( $user_login ),
    );
    ?>`

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