Plugin Directory

Changeset 3216397


Ignore:
Timestamp:
01/03/2025 10:29:00 AM (15 months ago)
Author:
thegeneration
Message:

Tagging version 3.1.4

Location:
svea-checkout-for-woocommerce
Files:
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • svea-checkout-for-woocommerce/tags/3.1.4/inc/Session_Table.php

    r3172745 r3216397  
    229229            $version = get_option( self::DB_VERSION_KEY, '0.0.0' );
    230230
    231             if ( version_compare( $version, '1.0.0', '<' ) ) {
    232                 $this->update_database_1();
    233                 $version = '1.0.0';
     231            if ( version_compare( $version, '2.0.0', '<' ) ) {
     232                $this->update_database_2();
     233                $version = '2.0.0';
    234234                update_option( self::DB_VERSION_KEY, $version );
    235235            }
     
    244244
    245245    /**
    246      * Update to version 1.0.0
    247      *
    248      * @return void
    249      */
    250     public function update_database_1() {
    251         global $wpdb;
    252 
    253         $table_name = $wpdb->prefix . self::$table;
    254         $charset_collate = $wpdb->get_charset_collate();
    255 
    256         // Setup new table if not already exists
    257         if ( $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $table_name ) ) !== $table_name ) {
    258             $sql = "CREATE TABLE $table_name (
    259                 id bigint(20) NOT NULL AUTO_INCREMENT,
    260                 sco_session_token varchar(255) NOT NULL,
    261                 wc_session_key varchar(255) NOT NULL,
    262                 expires varchar(255) NOT NULL,
    263                 PRIMARY KEY  (id),
    264                 INDEX sco_session_token (sco_session_token),
    265                 INDEX wc_session_key (wc_session_key)
    266             ) $charset_collate;";
    267             require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
    268             dbDelta( $sql );
    269         }
    270 
    271         // Add cron to delete older entries
    272         if ( ! wp_next_scheduled( self::CRON_NAME ) ) {
    273             wp_schedule_event( time(), 'daily', self::CRON_NAME );
     246     * Update version to 2.0.0
     247     * This is a temporary fix to handle orders that are affected by the bug introduced in 3.1.1
     248     *
     249     * @return void
     250     */
     251    public function update_database_2() {
     252        global $wpdb;
     253
     254        // Find all orders with the "awaiting-svea" status without wc-prefix
     255        $order_ids = $wpdb->get_col(
     256            $wpdb->prepare(
     257                "SELECT id FROM %i WHERE status = 'awaiting-svea'",
     258                $wpdb->prefix . 'wc_orders'
     259            )
     260        );
     261
     262        foreach ( $order_ids as $order_id ) {
     263            $wc_order = wc_get_order( $order_id );
     264
     265            if ( ! $wc_order ) {
     266                continue;
     267            }
     268
     269            $svea_order_id = $wc_order->get_meta( '_svea_co_order_id' );
     270
     271            if ( ! $svea_order_id ) {
     272                continue;
     273            }
     274
     275            $wpdb->update(
     276                $wpdb->prefix . 'wc_orders',
     277                [ 'status' => 'wc-awaiting-svea' ],
     278                [ 'id' => $order_id ]
     279            );
     280
     281            WC_Gateway_Svea_Checkout::log(
     282                sprintf( 'Found order with "awaiting-svea" status, scheduling a check. WC ID: %s, Svea ID: %s', $order_id, $svea_order_id )
     283            );
     284
     285            wp_schedule_single_event( time() + MINUTE_IN_SECONDS, 'sco_check_pa_order_status', [ $svea_order_id ] );
    274286        }
    275287    }
  • svea-checkout-for-woocommerce/tags/3.1.4/readme.txt

    r3206818 r3216397  
    1010License: Apache 2.0
    1111License URI: https://www.apache.org/licenses/LICENSE-2.0
    12 Stable tag: 3.1.3
     12Stable tag: 3.1.4
    1313
    1414Supercharge your WooCommerce Store with powerful features to pay via Svea Checkout!
     
    8686== Upgrade Notice ==
    8787
     88= 3.1.4 =
     893.1.4 is a patch release
     90
     91= 3.1.3 =
     923.1.3 is a patch release
     93
    8894= 3.1.2 =
    89953.1.2 is a patch release
     
    352358
    353359== Changelog ==
     360
     361= 3.1.4 2024-01-03 =
     362- Change priority of post status registration to fix issues where "Awaiting Svea" would be registered in WooCommerce but not as a WP post status.
    354363
    355364= 3.1.3 2024-12-12 =
  • svea-checkout-for-woocommerce/tags/3.1.4/svea-checkout-for-woocommerce.php

    r3206818 r3216397  
    1414 * Plugin URI: https://wordpress.org/plugins/svea-checkout-for-woocommerce/
    1515 * Description: Process payments in WooCommerce via Svea Checkout.
    16  * Version: 3.1.3
     16 * Version: 3.1.4
    1717 * Requires Plugins: woocommerce
    1818 * Author: The Generation AB
     
    4747         * Version of plugin
    4848         */
    49         const VERSION = '3.1.3';
     49        const VERSION = '3.1.4';
    5050
    5151        /**
     
    249249            add_action( 'plugins_loaded', [ $this, 'init_gateways' ] );
    250250            add_filter( 'woocommerce_shipping_methods', [ $this, 'init_shipping_methods' ] );
    251             add_action( 'init', [ $this, 'init_admin' ] );
     251            add_action( 'init', [ $this, 'init_admin' ], 1 );
    252252            add_action( 'admin_init', [ $this, 'check_compatibility' ] );
    253253            add_action( 'admin_notices', [ $this, 'display_admin_notices' ] );
     
    288288            $this->instore = new Instore();
    289289            $this->instore->init();
     290
     291            $this->session_table = new Session_Table();
     292            $this->session_table->init();
    290293        }
    291294
  • svea-checkout-for-woocommerce/trunk/inc/Session_Table.php

    r3172745 r3216397  
    229229            $version = get_option( self::DB_VERSION_KEY, '0.0.0' );
    230230
    231             if ( version_compare( $version, '1.0.0', '<' ) ) {
    232                 $this->update_database_1();
    233                 $version = '1.0.0';
     231            if ( version_compare( $version, '2.0.0', '<' ) ) {
     232                $this->update_database_2();
     233                $version = '2.0.0';
    234234                update_option( self::DB_VERSION_KEY, $version );
    235235            }
     
    244244
    245245    /**
    246      * Update to version 1.0.0
    247      *
    248      * @return void
    249      */
    250     public function update_database_1() {
    251         global $wpdb;
    252 
    253         $table_name = $wpdb->prefix . self::$table;
    254         $charset_collate = $wpdb->get_charset_collate();
    255 
    256         // Setup new table if not already exists
    257         if ( $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $table_name ) ) !== $table_name ) {
    258             $sql = "CREATE TABLE $table_name (
    259                 id bigint(20) NOT NULL AUTO_INCREMENT,
    260                 sco_session_token varchar(255) NOT NULL,
    261                 wc_session_key varchar(255) NOT NULL,
    262                 expires varchar(255) NOT NULL,
    263                 PRIMARY KEY  (id),
    264                 INDEX sco_session_token (sco_session_token),
    265                 INDEX wc_session_key (wc_session_key)
    266             ) $charset_collate;";
    267             require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
    268             dbDelta( $sql );
    269         }
    270 
    271         // Add cron to delete older entries
    272         if ( ! wp_next_scheduled( self::CRON_NAME ) ) {
    273             wp_schedule_event( time(), 'daily', self::CRON_NAME );
     246     * Update version to 2.0.0
     247     * This is a temporary fix to handle orders that are affected by the bug introduced in 3.1.1
     248     *
     249     * @return void
     250     */
     251    public function update_database_2() {
     252        global $wpdb;
     253
     254        // Find all orders with the "awaiting-svea" status without wc-prefix
     255        $order_ids = $wpdb->get_col(
     256            $wpdb->prepare(
     257                "SELECT id FROM %i WHERE status = 'awaiting-svea'",
     258                $wpdb->prefix . 'wc_orders'
     259            )
     260        );
     261
     262        foreach ( $order_ids as $order_id ) {
     263            $wc_order = wc_get_order( $order_id );
     264
     265            if ( ! $wc_order ) {
     266                continue;
     267            }
     268
     269            $svea_order_id = $wc_order->get_meta( '_svea_co_order_id' );
     270
     271            if ( ! $svea_order_id ) {
     272                continue;
     273            }
     274
     275            $wpdb->update(
     276                $wpdb->prefix . 'wc_orders',
     277                [ 'status' => 'wc-awaiting-svea' ],
     278                [ 'id' => $order_id ]
     279            );
     280
     281            WC_Gateway_Svea_Checkout::log(
     282                sprintf( 'Found order with "awaiting-svea" status, scheduling a check. WC ID: %s, Svea ID: %s', $order_id, $svea_order_id )
     283            );
     284
     285            wp_schedule_single_event( time() + MINUTE_IN_SECONDS, 'sco_check_pa_order_status', [ $svea_order_id ] );
    274286        }
    275287    }
  • svea-checkout-for-woocommerce/trunk/readme.txt

    r3206818 r3216397  
    1010License: Apache 2.0
    1111License URI: https://www.apache.org/licenses/LICENSE-2.0
    12 Stable tag: 3.1.3
     12Stable tag: 3.1.4
    1313
    1414Supercharge your WooCommerce Store with powerful features to pay via Svea Checkout!
     
    8686== Upgrade Notice ==
    8787
     88= 3.1.4 =
     893.1.4 is a patch release
     90
     91= 3.1.3 =
     923.1.3 is a patch release
     93
    8894= 3.1.2 =
    89953.1.2 is a patch release
     
    352358
    353359== Changelog ==
     360
     361= 3.1.4 2024-01-03 =
     362- Change priority of post status registration to fix issues where "Awaiting Svea" would be registered in WooCommerce but not as a WP post status.
    354363
    355364= 3.1.3 2024-12-12 =
  • svea-checkout-for-woocommerce/trunk/svea-checkout-for-woocommerce.php

    r3206818 r3216397  
    1414 * Plugin URI: https://wordpress.org/plugins/svea-checkout-for-woocommerce/
    1515 * Description: Process payments in WooCommerce via Svea Checkout.
    16  * Version: 3.1.3
     16 * Version: 3.1.4
    1717 * Requires Plugins: woocommerce
    1818 * Author: The Generation AB
     
    4747         * Version of plugin
    4848         */
    49         const VERSION = '3.1.3';
     49        const VERSION = '3.1.4';
    5050
    5151        /**
     
    249249            add_action( 'plugins_loaded', [ $this, 'init_gateways' ] );
    250250            add_filter( 'woocommerce_shipping_methods', [ $this, 'init_shipping_methods' ] );
    251             add_action( 'init', [ $this, 'init_admin' ] );
     251            add_action( 'init', [ $this, 'init_admin' ], 1 );
    252252            add_action( 'admin_init', [ $this, 'check_compatibility' ] );
    253253            add_action( 'admin_notices', [ $this, 'display_admin_notices' ] );
     
    288288            $this->instore = new Instore();
    289289            $this->instore->init();
     290
     291            $this->session_table = new Session_Table();
     292            $this->session_table->init();
    290293        }
    291294
Note: See TracChangeset for help on using the changeset viewer.