Plugin Directory

Changeset 3017107


Ignore:
Timestamp:
01/03/2024 04:13:56 PM (2 years ago)
Author:
makecommerce
Message:

Release 3.4.2

Location:
makecommerce/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • makecommerce/trunk/README.txt

    r3013223 r3017107  
    44Requires at least: 5.6.1
    55Tested up to: 6.3.2
    6 Stable tag: 3.4.1
     6Stable tag: 3.4.2
    77Requires PHP: 7.4
    88License: GPLv2 or later
     
    8080
    8181== Changelog ==
     82
     83= 3.4.2 2024-01-03 =
     84* Fix - Orders with wrong or missing transaction ids
    8285
    8386= 3.4.1 2023-12-22 =
  • makecommerce/trunk/makecommerce.php

    r3013223 r3017107  
    1010 * Plugin URI:            https://makecommerce.net/
    1111 * Description:           Adds MakeCommerce payment gateway and Itella/Omniva/DPD parcel machine shipping methods to WooCommerce checkout
    12  * Version:               3.4.1
     12 * Version:               3.4.2
    1313 * Author:                Maksekeskus AS
    1414 * Author URI:            https://makecommerce.net/
     
    3232 * Start at version 3.0.0 and use SemVer - https://semver.org
    3333 */
    34 define( 'MAKECOMMERCE_VERSION', '3.4.1' );
     34define( 'MAKECOMMERCE_VERSION', '3.4.2' );
    3535define( 'MAKECOMMERCE_PLUGIN_ID', 'makecommerce' );
    3636
  • makecommerce/trunk/payment/gateway/woocommerce/woocommerce.php

    r3013223 r3017107  
    1414
    1515    public $id = MAKECOMMERCE_PLUGIN_ID;
    16     public $version = '3.4.1';
     16    public $version = '3.4.2';
    1717   
    1818    public $payment_return_url;
  • makecommerce/trunk/payment/payment.php

    r3012381 r3017107  
    1313namespace MakeCommerce;
    1414
     15use Automattic\WooCommerce\Utilities\OrderUtil;
    1516/**
    1617 * The payment functionality of the plugin.
     
    205206
    206207        // if we didn't find reference to an Order, we send user to shop landing-page. TODO: could be improved 
    207         if ( !$transactionId ) {
     208        if ( empty( $transactionId ) ) {
    208209            return $returnUrl;
    209210        }
     
    212213        $orderId = self::get_postid_using_metakey( '_makecommerce_transaction_id', $transactionId );
    213214
    214         //still nothing. Lets try matching _order_number (SCO doesnt seem to have transaction id, transaction is created via SCO instead)
    215         if ( $orderId == null ) {
    216             $orderId = self::get_postid_using_metakey( '_order_number', $reference );
    217         }
    218 
    219         //try using reference as orderId
    220         if ( !$orderId ) {
    221             $orderId = $reference;
    222         }
    223        
    224215        $order = wc_get_order( $orderId );
    225216       
    226217        // if we didn't find the Order, we send user to shop landing-page. TODO: could be improved
    227         if ( !$order->get_id() ) {
     218        if ( !$order || !$order->get_id() ) {
    228219            return $returnUrl;
    229220        }
     
    324315     */
    325316    public static function get_postid_using_metakey( $meta_key, $transactionId ) {
    326 
    327         $orders = wc_get_orders(
    328             [
    329                 'meta_query' => [
    330                     [
    331                         'meta_key' => $meta_key,
    332                         'meta_value' => $transactionId
    333                     ]
    334                 ]
    335             ]
    336         );
    337 
    338         foreach ( $orders as $order ) {
    339             $id = $order->get_id();
    340             if ( isset( $id ) ) {
    341                 return $id;
     317        global $wpdb;
     318
     319        if ( OrderUtil::custom_orders_table_usage_is_enabled() ) {
     320            // HPOS
     321            $results = $wpdb->get_results(
     322                $wpdb->prepare("
     323                    SELECT wp_wc_orders.id
     324                    FROM wp_wc_orders
     325                    INNER JOIN wp_wc_orders_meta AS meta ON meta.order_id = wp_wc_orders.id AND meta.meta_key = %s
     326                    WHERE meta.meta_value = %s
     327                    ",
     328                    $meta_key,
     329                    $transactionId
     330                )
     331            );
     332
     333            if ( isset( $results[0]->id ) ) {
     334                return $results[0]->id;
     335            }
     336        } else {
     337            // Legacy DB
     338            $wpdb->query("SELECT `post_id` FROM $wpdb->postmeta WHERE `meta_key` = '". $meta_key ."' AND `meta_value` = '" . $transactionId . "'");
     339
     340            if ( isset( $wpdb->last_result[0]->post_id ) ) {
     341                return $wpdb->last_result[0]->post_id;
    342342            }
    343343        }
Note: See TracChangeset for help on using the changeset viewer.