New features in Sliced Invoices v3.8.0 update

June 17, 2019
Sliced Invoices

Sliced Invoices v3.8.0 is now available. Here is a look at some of the new features introduced as of 3.8:

Enhanced client dropdown box on quote/invoice editing pages

We’ve talked with some users who told us they have hundreds or even thousands of clients, and having them all in one big dropdown was too cumbersome.  So we made a new “enhanced” client dropdown with a built-in search box, where you can type a few letters and find your client by name.

sliced-enhanced-client-dropdown

 

Changes to the way dates & timestamps are handled and stored

Handling dates and timestamps correctly has been a challenge over the years, in part because CMB2 (the 3rd-party library we use for our options and metaboxes) does not handle dates properly.  As of 3.8.0 we have finally changed the way we handle things like quote/invoice creation date, invoice due date, and quote valid until date.  In this case we are switching away from relying on CMB2’s datepicker functionality, and using our own instead.  This allowed us to solve several issues that up to now could not be solved within the existing framework.  It also allowed us to remove some clunky “patches” we had to implement in the past to get around CMB2’s deficiencies.

For the vast majority of users, these changes are seamless and most likely you won’t notice any change.  However if you are using custom templates, custom code snippets, or have done any other custom development with Sliced Invoices, there are some potentially breaking changes you should know about.

  • invoice_created/quote_created, invoice_due, and quote_valid_until are now stored as proper Unix (UTC-based) timestamps, not WP localized timestamps.
  • invoice_created/quote_created will be set at the UTC equivalent of 00:00:00 (beginning of day) in the local timezone.
  • invoice_due and quote_valid_until will be set at the UTC equivalent of 23:59:59 (end of day) in the local timezone.

We added some new utility functions in the Sliced_Shared class to help interact with dates and timestamps.  They are:

  • Sliced_Shared::get_local_date_from_timestamp
  • Sliced_Shared::get_local_date_i18n_from_timestamp
  • Sliced_Shared::get_local_timezone
  • Sliced_Shared::get_timestamp_from_local_time

To display dates correctly, we updated some of our built-in template tags to use these new functions.  If you are using custom template tags (for example, maybe you copy and pasted them into a custom template), you will need to update your code accordingly.

(If you are not using any custom templates or custom code, then you don’t have to do anything.)

if you have:
<?php echo date_i18n( get_option( 'date_format' ), (int) sliced_get_invoice_created() ) ?>
replace it with:
<?php echo Sliced_Shared::get_local_date_i18n_from_timestamp( sliced_get_invoice_created() ); ?>
if you have:
<?php echo date_i18n( get_option( 'date_format' ), (int) sliced_get_invoice_due() ) ?>
replace it with:
<?php echo Sliced_Shared::get_local_date_i18n_from_timestamp( sliced_get_invoice_due() ); ?>
if you have:
<?php echo date_i18n( get_option( 'date_format' ), (int) sliced_get_quote_created() ) ?>
replace it with:
<?php echo Sliced_Shared::get_local_date_i18n_from_timestamp( sliced_get_quote_created() ); ?>
if you have:
<?php echo date_i18n( get_option( 'date_format' ), (int) sliced_get_quote_valid() ) ?>
replace it with:
<?php echo Sliced_Shared::get_local_date_i18n_from_timestamp( sliced_get_quote_valid() ); ?>

We also changed the Client Area template along the same lines. If you are using a custom client area template (client-area.php), you will need to update the following:

if you have:
esc_html( date_i18n( get_option( 'date_format' ), sliced_get_created( $quote ) ) )
replace it with:
Sliced_Shared::get_local_date_i18n_from_timestamp( sliced_get_created( $quote ) )
if you have:
esc_html( date_i18n( get_option( 'date_format' ), sliced_get_created( $invoice ) ) )
replace it with:
Sliced_Shared::get_local_date_i18n_from_timestamp( sliced_get_created( $invoice ) )
if you have:
esc_html( date_i18n( get_option( 'date_format' ), sliced_get_invoice_due( $invoice ) ) )
replace it with:
Sliced_Shared::get_local_date_i18n_from_timestamp( sliced_get_invoice_due( $invoice ) )

 

Version 3.8.0 contains several other small fixes and enhancements, so please be sure to read the changelog to find out more.  If you have any questions or need help, let our support team know.

Cheers,
-The Team at Sliced Invoices