• 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 15 replies - 1 through 15 (of 18 total)
  • Plugin Author vendidero

    (@vendidero)

    Hi there,

    no, that’s not possible. The mandate contains the mandatory information to generate the mandate and nothing else ??

    Cheers

    Thread Starter Hughsp

    (@rescaes)

    Hi again,

    That’s true, legally there’s no need for anything else. I was just wondering if there was a simple way to include it for a specific purpose we need… it’s a pity!

    Thanks!

    Plugin Author vendidero

    (@vendidero)

    Thread Starter Hughsp

    (@rescaes)

    Hi again,

    Oh wow!??… that is definitely premium support!????… Thanks very much, but truth is I don’t really know how to use it. I added the code in the file and tried to add ‘#billing_email’ in the get_mandate_text_checkout_fields function following the other variables model but didn’t work… but I have to say I don’t really know what I’m doing ?????♂?

    Plugin Author vendidero

    (@vendidero)

    Hi there,

    you’ll need to add the shortcode registered to your mandate text within the settings. E.g.:

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

    Now add [email] as a placeholder to your mandate text. This snippet will only work in case you’ve replaced all the files changed within the git commit in your Germanized installation. Otherwise you’ll have to wait until the next update.

    Cheers

    Thread Starter Hughsp

    (@rescaes)

    Hi!

    Holly cow!… that worked perfectly!????????… Yeah, I had to replace the files??

    10 over 10????… Thanks so much!

    Thread Starter Hughsp

    (@rescaes)

    Hi again!

    Sorry to open this again ?????♂? but… It turned out to work almost ok when making an order from the front-end (shop-cart-checkout)… the mandate preview is ok but the email sent with the mandate shows the value of the filter empty.

    Now, when creating an order from the admin back-end and then accesing the paying url, the shortcode from the filter shows nothing (empty) in the mandate preview and also in the email sent… is that expected or am I doing something wrong?

    Also, the “mandatory field message” in red letters for the IBAN and BIC fields sometimes shows up before typing anything and others stays even after typing correctly the info (tested in incognito windows and Chrome/Firefox)… ?????♂? … but I can live with that.

    Thanks! ??

    • This reply was modified 3 years, 4 months ago by Hughsp.
    • This reply was modified 3 years, 4 months ago by Hughsp.
    Plugin Author vendidero

    (@vendidero)

    Hi,

    the email sent with the mandate shows the value of the filter empty.

    For the order data you’ll need another filter as the way the data is called is different from the checkout. Find the filter here: https://github.com/vendidero/woocommerce-germanized/blob/master/includes/gateways/direct-debit/class-wc-gzd-gateway-direct-debit.php#L847

    That does apply for the pay-for-order endpoint as well, as the order has already been submitted.

    Also, the “mandatory field message” in red letters for the IBAN and BIC fields sometimes shows up before typing anything and others stays even after typing correctly the info

    This seems like a JS bug to me. Did you try that with a default theme activated and all plugins but Woo and Germanized deactivated?

    Cheers

    Thread Starter Hughsp

    (@rescaes)

    Dear Vendidero,

    Your level of commitment keeps amazing me, replying in such short notice specially considering it’s a Saturday??…

    For the order data you’ll need another filter as the way the data is called is different from the checkout. Find the filter here: https://github.com/vendidero/woocommerce-germanized/blob/master/includes/gateways/direct-debit/class-wc-gzd-gateway-direct-debit.php#L847

    I’m glad it sounds like a small thing to solve ??… Unfortunately, I have the understanding level of programming of a dumb monkey (not a regular one) in front of a keyboard??. I tried several times my best using your previous code as reference, but nothing happened. ??

    This seems like a JS bug to me. Did you try that with a default theme activated and all plugins but Woo and Germanized deactivated?

    I was gonna say exactly that, a JS bug ??… .Yeah, “Twenty, twenty” and only Woo and Germanized. Here’s a screenshot: https://snipboard.io/462vrS.jpg
    Even if correct (fake data but autogenerated correctly) the field is marked as mandatory… Actually with my theme it’s not a red frame but a whole text message in red letters. Hope it helps.

    Once again, thanks a trillion.

    Plugin Author vendidero

    (@vendidero)

    Hi there,

    depending on which data you would like to add to the mandate you’ll have to use the filter like this:

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

    The data will be replaced just like the checkout placeholders within your mandate.

    Even if correct (fake data but autogenerated correctly) the field is marked as mandatory

    I’ve fixed the validation issue here: https://github.com/vendidero/woocommerce-germanized/commit/6af3746be21e8d15a9eb01c16b53995961c4f04d

    Cheers

    Thread Starter Hughsp

    (@rescaes)

    Hello again…

    Thanks for providing the filter! I was close, but not enough….

    It actually works fine for the mandate sent by email (it shows the email) but not in the mandate preview during the checkout (order created from admin’s backend).. it shows “[email]” ?????♂?

    Also, still testing but I think there is an incompatibility if I use both the filters (for both front-end and back-end orders)… If I name the shortcodes differently there is always one of them showing in the mail. I.e: If I make the order from the front-end, it shows the email but right by it also shows “[email_back]”…. I had to name one shortcode [email_front] and the other [email_back]… If named the same, the order gets stuck when paying for order.

    I’m sorry for beind a pain!?????♂?…

    Thanks!!

    Plugin Author vendidero

    (@vendidero)

    Hi,

    to make this work you’ll have to explicitly enable your first filter (my_child_register_mandate_shortcode) to check whether order data is available and use that order data instead, e.g.:

    function my_child_register_mandate_shortcode( $params ) {
      $params['email'] = '#billing_email';
    
      $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;
    }

    As you can see it is not a trivial task to support all the different endpoints with such a customization.

    Cheers

    Thread Starter Hughsp

    (@rescaes)

    Thanks again, I’m gonna test it… sorry! I edited my previous comment while you replied…

    As you can see it is not a trivial task to support all the different endpoints with such a customization.

    Belive me that, from the perspective of a person with a 0 programming base, you look like a demigod to me for what you are capable of doing and I appreciate your effort and efficiency.????????

    Thread Starter Hughsp

    (@rescaes)

    Hi again,

    Ok, I tested it but couldn’t make it work… I found myself with (your) 3 filters and don’t know how to combine them right in my functions.php to make all of them work for orders from the front and backend, preview and email mandates.

    Not your fault, you already did too much (as you said, not a trivial task!) and I don’t want to keep abusing of your free work, it’s just too complex for me. But I’m sure this will be very helpful for others with more programming skills than me!… So congratulations again for your great support. We’ll try to find an alternative to the customization if possible.

    Thanks again for your great work!

    Plugin Author vendidero

    (@vendidero)

    Hi there,

    actually there are only 2 filters necessary. So bringing it all together:

    // Checkout and pay for order endpoint
    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';
    
      $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;
    }

    But yes, I’d guess it would be good to let a developer implement such non-trivial things for you.

    Cheers

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