Plugin Directory

Changeset 3810567


Ignore:
Timestamp:
11/19/2026 03:03:20 AM (less than one hour ago)
Author:
giftlight
Message:

Giftlight 1.1.21 keeps the report available when an order read fails

Location:
giftlight
Files:
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • giftlight/tags/1.1.21/giftlight.php

    r3809506 r3810567  
    44 * Plugin URI:        https://giftlight.app/
    55 * Description:       A gift guide and a gift finder quiz built from your own WooCommerce products: by who it's for, what to spend and what they're into.
    6  * Version:           1.1.20
     6 * Version:           1.1.21
    77 * Requires at least: 6.3
    88 * Requires PHP:      7.4
    … …  
    2121}
    2222
    23 define( 'GIFTLIGHT_VERSION', '1.1.20' );
     23define( 'GIFTLIGHT_VERSION', '1.1.21' );
    2424define( 'GIFTLIGHT_FILE', __FILE__ );
    2525define( 'GIFTLIGHT_MAX_PRODUCTS', 300 );
  • giftlight/tags/1.1.21/readme.txt

    r3809506 r3810567  
    66Requires PHP: 7.4
    77Requires Plugins: woocommerce
    8 Stable tag: 1.1.20
     8Stable tag: 1.1.21
    99License: GPLv2 or later
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
  • giftlight/tags/1.1.21/sold.php

    r3800841 r3810567  
    116116 *
    117117 * @param string $from First included local calendar day.
    118  * @return array
     118 * @return array|null Null when the order results are incomplete or invalid.
    119119 */
    120120function giftlight_sold_orders( $from ) {
    … …  
    142142                do {
    143143                        $orders = wc_get_orders( $args );
     144                        if ( ! is_array( $orders ) ) {
     145                                return null;
     146                        }
    144147                        foreach ( $orders as $order ) {
     148                                if ( ! $order instanceof WC_Order ) {
     149                                        return null;
     150                                }
    145151                                $id = $order->get_id();
    146152                                if ( isset( $seen[ $id ] ) ) {
    … …  
    190196        }
    191197        if ( '' !== get_option( 'giftlight_sold_on', '' ) ) {
    192                 $sum = array_merge( $sum, giftlight_sold_orders( $from ) );
     198                try {
     199                        $orders = giftlight_sold_orders( $from );
     200                } catch ( Throwable $error ) {
     201                        $orders = null;
     202                }
     203                if ( null === $orders ) {
     204                        $sum['orders_unavailable'] = true;
     205                } else {
     206                        $sum = array_merge( $sum, $orders );
     207                }
    193208        }
    194209        return $sum;
    … …  
    420435function giftlight_sold_panel() {
    421436        $sum = giftlight_sold_summary( 30 );
     437        $unavailable = ! empty( $sum['orders_unavailable'] );
    422438        echo '<h2>' . esc_html__( '4. What your guide sold', 'giftlight' ) . '</h2>';
    423         if ( 0 === $sum['opened'] && 0 === $sum['added'] && 0 === $sum['orders'] ) {
     439        if ( ! $unavailable && 0 === $sum['opened'] && 0 === $sum['added'] && 0 === $sum['orders'] ) {
    424440                $message = giftlight_sold_on()
    425441                        ? __( 'Nothing yet. When a shopper opens a pick from your guide, this report starts counting.', 'giftlight' )
    … …  
    429445                return;
    430446        }
    431         $values = array();
    432         ksort( $sum['totals'] );
    433         foreach ( $sum['totals'] ?: array( get_woocommerce_currency() => 0.0 ) as $currency => $amount ) {
    434                 $values[] = esc_html( $currency ) . ' ' . wp_kses_post( wc_price( $amount, array( 'currency' => $currency ) ) );
    435         }
    436447        $rows = array(
    437448                __( 'Picks opened', 'giftlight' )     => esc_html( number_format_i18n( $sum['opened'] ) ),
    438449                __( 'Added to the cart', 'giftlight' ) => esc_html( number_format_i18n( $sum['added'] ) ),
    439                 __( 'Orders with a pick', 'giftlight' ) => esc_html( number_format_i18n( $sum['orders'] ) ),
    440                 __( 'Order value from picks', 'giftlight' ) => implode( '<br>', $values ),
    441450        );
     451        if ( $unavailable ) {
     452                echo '<p class="description" role="status">' . esc_html__( 'WooCommerce orders couldn’t be loaded. Reload this page to try again.', 'giftlight' ) . '</p>';
     453        } else {
     454                $values = array();
     455                ksort( $sum['totals'] );
     456                foreach ( $sum['totals'] ?: array( get_woocommerce_currency() => 0.0 ) as $currency => $amount ) {
     457                        $values[] = esc_html( $currency ) . ' ' . wp_kses_post( wc_price( $amount, array( 'currency' => $currency ) ) );
     458                }
     459                $rows[ __( 'Orders with a pick', 'giftlight' ) ] = esc_html( number_format_i18n( $sum['orders'] ) );
     460                $rows[ __( 'Order value from picks', 'giftlight' ) ] = implode( '<br>', $values );
     461        }
    442462        echo '<table class="widefat striped" style="max-width:420px"><tbody>';
    443463        foreach ( $rows as $label => $value ) {
    … …  
    445465        }
    446466        echo '</tbody></table>';
    447         echo '<p class="description" style="max-width:720px">' . esc_html__( 'The last 30 days. Orders use WooCommerce’s payment date, or the order date if it has none, and the current Processing or Completed status. Value comes from the picked items, before tax and shipping. Each currency is shown separately. Partial refunds stay in the displayed value.', 'giftlight' ) . '</p>';
     467        if ( ! $unavailable ) {
     468                echo '<p class="description" style="max-width:720px">' . esc_html__( 'The last 30 days. Orders use WooCommerce’s payment date, or the order date if it has none, and the current Processing or Completed status. Value comes from the picked items, before tax and shipping. Each currency is shown separately. Partial refunds stay in the displayed value.', 'giftlight' ) . '</p>';
     469        }
    448470        giftlight_sold_switch();
    449471}
  • giftlight/trunk/giftlight.php

    r3809506 r3810567  
    44 * Plugin URI:        https://giftlight.app/
    55 * Description:       A gift guide and a gift finder quiz built from your own WooCommerce products: by who it's for, what to spend and what they're into.
    6  * Version:           1.1.20
     6 * Version:           1.1.21
    77 * Requires at least: 6.3
    88 * Requires PHP:      7.4
    … …  
    2121}
    2222
    23 define( 'GIFTLIGHT_VERSION', '1.1.20' );
     23define( 'GIFTLIGHT_VERSION', '1.1.21' );
    2424define( 'GIFTLIGHT_FILE', __FILE__ );
    2525define( 'GIFTLIGHT_MAX_PRODUCTS', 300 );
  • giftlight/trunk/readme.txt

    r3809506 r3810567  
    66Requires PHP: 7.4
    77Requires Plugins: woocommerce
    8 Stable tag: 1.1.20
     8Stable tag: 1.1.21
    99License: GPLv2 or later
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
  • giftlight/trunk/sold.php

    r3800841 r3810567  
    116116 *
    117117 * @param string $from First included local calendar day.
    118  * @return array
     118 * @return array|null Null when the order results are incomplete or invalid.
    119119 */
    120120function giftlight_sold_orders( $from ) {
    … …  
    142142                do {
    143143                        $orders = wc_get_orders( $args );
     144                        if ( ! is_array( $orders ) ) {
     145                                return null;
     146                        }
    144147                        foreach ( $orders as $order ) {
     148                                if ( ! $order instanceof WC_Order ) {
     149                                        return null;
     150                                }
    145151                                $id = $order->get_id();
    146152                                if ( isset( $seen[ $id ] ) ) {
    … …  
    190196        }
    191197        if ( '' !== get_option( 'giftlight_sold_on', '' ) ) {
    192                 $sum = array_merge( $sum, giftlight_sold_orders( $from ) );
     198                try {
     199                        $orders = giftlight_sold_orders( $from );
     200                } catch ( Throwable $error ) {
     201                        $orders = null;
     202                }
     203                if ( null === $orders ) {
     204                        $sum['orders_unavailable'] = true;
     205                } else {
     206                        $sum = array_merge( $sum, $orders );
     207                }
    193208        }
    194209        return $sum;
    … …  
    420435function giftlight_sold_panel() {
    421436        $sum = giftlight_sold_summary( 30 );
     437        $unavailable = ! empty( $sum['orders_unavailable'] );
    422438        echo '<h2>' . esc_html__( '4. What your guide sold', 'giftlight' ) . '</h2>';
    423         if ( 0 === $sum['opened'] && 0 === $sum['added'] && 0 === $sum['orders'] ) {
     439        if ( ! $unavailable && 0 === $sum['opened'] && 0 === $sum['added'] && 0 === $sum['orders'] ) {
    424440                $message = giftlight_sold_on()
    425441                        ? __( 'Nothing yet. When a shopper opens a pick from your guide, this report starts counting.', 'giftlight' )
    … …  
    429445                return;
    430446        }
    431         $values = array();
    432         ksort( $sum['totals'] );
    433         foreach ( $sum['totals'] ?: array( get_woocommerce_currency() => 0.0 ) as $currency => $amount ) {
    434                 $values[] = esc_html( $currency ) . ' ' . wp_kses_post( wc_price( $amount, array( 'currency' => $currency ) ) );
    435         }
    436447        $rows = array(
    437448                __( 'Picks opened', 'giftlight' )     => esc_html( number_format_i18n( $sum['opened'] ) ),
    438449                __( 'Added to the cart', 'giftlight' ) => esc_html( number_format_i18n( $sum['added'] ) ),
    439                 __( 'Orders with a pick', 'giftlight' ) => esc_html( number_format_i18n( $sum['orders'] ) ),
    440                 __( 'Order value from picks', 'giftlight' ) => implode( '<br>', $values ),
    441450        );
     451        if ( $unavailable ) {
     452                echo '<p class="description" role="status">' . esc_html__( 'WooCommerce orders couldn’t be loaded. Reload this page to try again.', 'giftlight' ) . '</p>';
     453        } else {
     454                $values = array();
     455                ksort( $sum['totals'] );
     456                foreach ( $sum['totals'] ?: array( get_woocommerce_currency() => 0.0 ) as $currency => $amount ) {
     457                        $values[] = esc_html( $currency ) . ' ' . wp_kses_post( wc_price( $amount, array( 'currency' => $currency ) ) );
     458                }
     459                $rows[ __( 'Orders with a pick', 'giftlight' ) ] = esc_html( number_format_i18n( $sum['orders'] ) );
     460                $rows[ __( 'Order value from picks', 'giftlight' ) ] = implode( '<br>', $values );
     461        }
    442462        echo '<table class="widefat striped" style="max-width:420px"><tbody>';
    443463        foreach ( $rows as $label => $value ) {
    … …  
    445465        }
    446466        echo '</tbody></table>';
    447         echo '<p class="description" style="max-width:720px">' . esc_html__( 'The last 30 days. Orders use WooCommerce’s payment date, or the order date if it has none, and the current Processing or Completed status. Value comes from the picked items, before tax and shipping. Each currency is shown separately. Partial refunds stay in the displayed value.', 'giftlight' ) . '</p>';
     467        if ( ! $unavailable ) {
     468                echo '<p class="description" style="max-width:720px">' . esc_html__( 'The last 30 days. Orders use WooCommerce’s payment date, or the order date if it has none, and the current Processing or Completed status. Value comes from the picked items, before tax and shipping. Each currency is shown separately. Partial refunds stay in the displayed value.', 'giftlight' ) . '</p>';
     469        }
    448470        giftlight_sold_switch();
    449471}
Note: See TracChangeset for help on using the changeset viewer.