• Resolved Hughsp

    (@rescaes)


    Hi all,

    I apologize if the answer to my question is in the official documentation, but my german in pretty rusty.

    Is it possible to include in the Mandate (using a shortcode?) any standard field of the Woocommerce billing information (asked during checkout) like the phone number or email address ?

    Thank you!

Viewing 3 replies - 16 through 18 (of 18 total)
  • Thread Starter Hughsp

    (@rescaes)

    Thanks for putting it all together… We copied/paste your code directly in our functions.php from scratch but when using [email] in the mandate text, it shows empty in the mandate preview when paying order with the link from the order backend.?????♂?

    Thanks for your helpful determination!

    Plugin Author vendidero

    (@vendidero)

    Hi there,

    my bad. You’ll need an additional filter:

    // Checkout data
    add_filter( 'woocommerce_gzd_direct_debit_mandate_text_checkout_fields', 'my_child_register_mandate_shortcode', 10 );
    
    function my_child_register_mandate_shortcode( $params ) {
      $params['email'] = '#billing_email';
      return $params;
    }
    
    // Register pay for order data
    add_filter( 'woocommerce_gzd_direct_debit_mandate_checkout_placeholders', 'my_child_register_mandate_params', 10 );
    
    function my_child_register_mandate_params( $params ) {
      $order_key = isset( $_GET['order_key'] ) ? wc_clean( wp_unslash( $_GET['order_key'] ) ) : '';
    
       if ( ! empty( $order_key ) ) {
         $order_id = wc_get_order_id_by_order_key( $order_key );
    
    	if ( $order_id && ( $order = wc_get_order( $order_id ) ) ) {
    	    if ( current_user_can( 'pay_for_order', $order_id ) ) {
    		$params['email'] = $order->get_billing_email();	    
    	    }
            }
        }
       return $params;
    }
    
    // Order data only (e.g. emails)
    add_filter( 'woocommerce_gzd_direct_debit_mandate_order_placeholders', 'my_child_register_mandate_order_shortcode', 10, 2 );
    
    function my_child_register_mandate_order_shortcode( $params, $order ) {
      $params['email'] = $order->get_billing_email();
    
      return $params;
    }
    Thread Starter Hughsp

    (@rescaes)

    Hi again,

    It’s incredibe how easy can you make it look ??..

    It works flawlessly now both in front/back ends and in preview/email…

    Still amazed…

    Thanks so much!

Viewing 3 replies - 16 through 18 (of 18 total)
  • The topic ‘WC billing info in Mandate’ is closed to new replies.