Martin Steimann
Forum Replies Created
-
AuthorPosts
-
Thank you for your reply, Kiran.
The invoice „To“ address order is now perfect!
The field for customers’s company name still gets only displayed by adding code to the functions.php of the child theme.
(Please note this code near the end)
/**
* show company name input field.
*//** * Open invoice links in new window. */ function wpi_snippet_190122_invoice_receipt_actions( $actions, $invoice ) { if ( ! empty( $actions ) ) { foreach ( $actions as $i => $action ) { $actions[ $i ]['attrs'] = 'target="_blank"'; } } return $actions; } add_filter( 'wpinv_invoice_receipt_actions', 'wpi_snippet_190122_invoice_receipt_actions', 10, 2 ); /** * Change address order on invoice. */ function wpi_snippet_190122_display_to_address( $output, $invoice ) { $billing_details = $invoice->get_user_info(); $output = '<div class="to col-xs-2"><strong>' . __( 'To:', 'invoicing' ) . '</strong></div>'; $output .= '<div class="wrapper col-xs-10">'; ob_start(); do_action( 'wpinv_display_to_address_top', $invoice ); $output .= ob_get_clean(); if ( $company = $billing_details['company'] ) { $output .= '<div class="company">' . wpautop( wp_kses_post( $company ) ) . '</div>'; } $output .= '<div class="name">' . esc_html( trim( $billing_details['first_name'] . ' ' . $billing_details['last_name'] ) ) . '</div>'; $address_row = ''; if ( $address = $billing_details['address'] ) { $address_row .= wpautop( wp_kses_post( $address ) ); } $address_fields = array(); if ( !empty( $billing_details['city'] ) ) { $address_fields[] = $billing_details['city']; } if ( !empty( $address_fields ) ) { $address_fields = implode( ", ", $address_fields ); if ( !empty( $billing_details['zip'] ) ) { $address_fields = $billing_details['zip'] . ' ' . $address_fields; } $address_row .= wpautop( wp_kses_post( $address_fields ) ); } if ( $address_row ) { $output .= '<div class="address">' . $address_row . '</div>'; } if ( $phone = $invoice->get_phone() ) { $output .= '<div class="phone">' . wp_sprintf( __( 'Phone: %s', 'invoicing' ), esc_html( $phone ) ) . '</div>'; } // Hide email form To address. //if ( $email = $invoice->get_email() ) { // $output .= '<div class="email">' . wp_sprintf( __( 'Email: %s' , 'invoicing'), esc_html( $email ) ) . '</div>'; //} ob_start(); do_action( 'wpinv_display_to_address_bottom', $invoice ); $output .= ob_get_clean(); $output .= '</div>'; return $output; } add_filter( 'wpinv_display_to_address', 'wpi_snippet_190122_display_to_address', 10, 2 ); /** * show company name input field. */ function _wpi_custom_checkout_company_info_display_fields( $billing_details ) { global $wpinv_euvat; if ( ! empty( $wpinv_euvat ) && ! $wpinv_euvat->allow_vat_rules() ) { $tax_label = __( $wpinv_euvat->get_vat_name(), 'invoicing' ); $company_mandatory = false; // Company name mandatory? $vat_number_mandatory = false; // Vat number mandatory? ?> <p class="wpi-cart-field wpi-col2 wpi-colf"> <label for="wpinv_company" class="wpi-label"><?php _e( 'Company Name', 'invoicing' );?><?php if ( $company_mandatory ) { echo '<span class="wpi-required">*</span>'; } ?></label> <?php echo wpinv_html_text( array( 'id' => 'wpinv_company_custom', 'name' => 'wpinv_company_custom', 'value' => $billing_details['company'], 'class' => 'wpi-input form-control', 'placeholder' => __( 'Company name', 'invoicing' ), 'required' => $company_mandatory, ) ); ?> </p> <p class="wpi-cart-field wpi-col2 wpi-coll"> <label for="wpinv_vat_number_custom" class="wpi-label"><?php echo wp_sprintf( __( '%s number', 'invoicing' ), $tax_label ); ?><?php if ( $vat_number_mandatory ) { echo '<span class="wpi-required">*</span>'; } ?></label> <?php echo wpinv_html_text( array( 'id' => 'wpinv_vat_number_custom', 'name' => 'wpinv_vat_number_custom', 'value' => $billing_details['vat_number'], 'class' => 'wpi-input form-control', 'placeholder' => wp_sprintf( __( '%s number', 'invoicing' ), $tax_label ), 'required' => $vat_number_mandatory, ) ); ?> </p> <?php } } add_action( 'wpinv_checkout_billing_fields_first', '_wpi_custom_checkout_company_info_display_fields', 10, 1 ); // Display at top //add_action( 'wpinv_checkout_billing_fields_last', '_wpi_custom_checkout_company_info_display_fields', 10, 1 ); // Display at bottom function _wpi_custom_checkout_company_info_set_fields() { global $wpinv_euvat; if ( isset( $_POST['wpinv_company_custom'] ) && isset( $_POST['wpinv_vat_number_custom'] ) && ! empty( $wpinv_euvat ) && ! $wpinv_euvat->allow_vat_rules() ) { $_POST['wpinv_company'] = $_POST['wpinv_company_custom']; $_POST['wpinv_vat_number'] = $_POST['wpinv_vat_number_custom']; } } add_action( 'wpinv_pre_process_checkout', '_wpi_custom_checkout_company_info_set_fields', 10 ); function _wpi_custom_checkout_company_info_save_fields( $post, $user_info, $valid_data ) { global $wpinv_euvat, $wpi_cart; if ( isset( $post['wpinv_company_custom'] ) && isset( $post['wpinv_vat_number_custom'] ) && ! empty( $wpinv_euvat ) && ! empty( $wpi_cart ) && ! $wpinv_euvat->allow_vat_rules() ) { $wpi_cart->set( 'company', $post['wpinv_company_custom'] ); $wpi_cart->set( 'vat_number', $post['wpinv_vat_number_custom'] ); $wpi_cart->save(); } } add_action( 'wpinv_checkout_before_gateway', '_wpi_custom_checkout_company_info_save_fields', 10, 3 );
If I cut out this Change address order on invoice-snippet, then the company name field is not displayed even if „force company name visibility“ is checked at the invoicing settings.
Can you please advise me (unfortunately I have no coding skills at all) wich part of the „_wpi_custom_checkout_company_info_display_fields“ I have to remove, so that the VAT number field is hidden? My only concern would be, that in hiding the VAT field the „first name“ and „second name“ fields would end up not being in the same row. (see attached screenshot)
I really wish you and your team could add the same functionality for setting up a invoice checkout form as in a GeoDirectory Listing form, where the admin can set up the required form fields and rearrange the order manually. This would give the admin unlimited possibilities to create a checkout form which suits the invoicing demands of the country he lives in. Maybe this could be implemented in a future version (or chargeable add-on) of this really helpful plugin?
Regards,
MartinThanks for your patience. We’re almost there.
Open invoice in new window works!
I have implemented all your recommenced code (e.g. Change Address Order and Display Company Name Field.)
Company Name Address field now shows up in the checkout form, as well as the VAT field. Still not sure if I have set all the right checkmarks in the invoicing plugin’s EU VAT SETTINGS. I made a screenshot and attached it (screenshot 1, sorry, only with german translation). Maybe it helps if I explain what I would like to achieve:
My customers live only in Germany. So there is no need for my customers to enter their VAT number. If someone tries to add a listing to my directory from another EU country, I will let them know by Email that they cannot add their listing.
With your provided code, both Company Name and VAT Number fields are displayed in the checkout form (see screenshot 2). Even if not mandatory – if a customer enters his VAT number „accidentally“, it gets displayed on his invoice with a title, which does not make sense (see screenshot 3) Of course I could translate it to something which makes sense, but I think the best solution for me would be that the VAT input field is not shown at all within invoice details of the checkout page. Only the much needed Company Name should be shown. Is this possible?
Regarding the address order – its almost perfect now. But I still need to have the Company’s name on top, followed the customer’s name. And I am almost sure I can figure out how to remove the colon after the ZIP code. You surly do, don’t you? The Country Name is not needed at all, and if displayed (it is right now, because I cannot leave the country field empty in the invoice details) should go into one extra line beneath it (but maybe that is too demanding). So the final result would be:
Grogor’s Demo Company
Gregor Mustermann
Demostreet 1
20251 Democity
DeutschlandOr
Grogor’s Demo Company
Gregor Mustermann
Demostreet 1
20251 Democity, DeutschlandAgain, I really appreciate how you and your team are sorting out all of my special requests!
Regards, Martin
Patch works, problem solved, thank you!
Thank you for testing. I am checking on a real device (iPhone 6s). The invoice history page scrolls perfectly fine. The issue is with the invoice page: members/dbff9f96d7503b93/invoices/
By the way: I can view the invoice history page after check out on the payment confirmation page. There it a button in the upper right corner which leads to the invoice history. Is this the only place where a user can get to this history page? On my profile page a tab „my invoice“ is shown, but no „my invoice history“, which ist okay for me. Just wondering if „invoice history“ adds any value and should be offered in an extra tab.
Thank you for your reply,Kiran!
1. now the „from“ Email is hidden, great!
2. I have implemented the patch and it works, thank you!
3. Sorry, I meant Customer’s company name field (yes, the name field is already there), so that 4. the company name gets displayed on the invoice’s address first, followed by the name.
If company name saved in checkout form then it will be displayed on invoice.
Do you mean the Checkmark in the invoice settings, which says „Force the display of the company name when paying“? I have checked this but there is no company name field in the checkout form.
5/6. in which function php do these lines of code go? includes/wpinv-general-functions.php?
If you want to disable VAT feature and want to show company fields then try the snippet provided here: https://wpinvoicing.com/support/topic/collect-company-info-even-when-not-required/#post-1077
Maybe this solves number 4. In which function php would I add the code mentioned in the link?
7. Its the payment confirmation page (please note attached screenshot). If you click on the button, it would be helpful if this action would open a new window.
Regards,
MartinThis reply has been marked as private.Thank you for the video, Kiran. The demonstrated functionality is not working within the KLEO Theme, which I have installed. Should I ask the developers at Seventhqueen for a fix?
Regard, MartinExcellent support, you’ve solved it! Thank you.
This reply has been marked as private.This reply has been marked as private.I’ve added your script to the child theme with no luck. Probably the wrong location?
Thanks Guust, and how about the diagonal overlay?
-
AuthorPosts