Plugin Directory

Changeset 3073241


Ignore:
Timestamp:
04/18/2024 02:58:48 PM (2 years ago)
Author:
tabbyai
Message:

Fix merchant code country selection order

Location:
tabby-checkout
Files:
5 edited
29 copied

Legend:

Unmodified
Added
Removed
  • tabby-checkout/tags/4.10.4/includes/class-wc-gateway-tabby-checkout-base.php

    r3053766 r3073241  
    291291    public function getMerchantCode($order = null) {
    292292        if ($order) {
    293             $code = $order->get_shipping_country() ?: $order->get_billing_country();
     293            $code = $order->get_billing_country() ?: $order->get_shipping_country();
    294294        } else {
    295             $code = WC()->customer->get_shipping_country() ?: WC()->customer->get_billing_country();
     295            $code = WC()->customer->get_billing_country() ?: WC()->customer->get_shipping_country();
    296296        }
    297297        if ($code == 'undefined' || empty($code)) $code = wc_get_base_location()['country'];
     
    340340        ];
    341341
    342         $result = WC_Tabby_Api::request('checkout', 'POST', $request);
    343 
    344         if ($result && property_exists($result, 'status') && $result->status == 'created') {
    345             if (property_exists($result->configuration->available_products, static::TABBY_METHOD_CODE)) {
    346                 return true;
     342        $is_available = false;
     343       
     344        $sha256 = hash('sha256', json_encode($request));
     345        $tr_name = 'tabby_api_cache_' . $sha256;
     346
     347        if (($available_products = get_transient($tr_name)) === false) {
     348            $result = WC_Tabby_Api::request('checkout', 'POST', $request);
     349
     350            if ($result && property_exists($result, 'status') && $result->status == 'created') {
     351                $available_products = $result->configuration->available_products;
     352            } else {
     353                $available_products = new \StdClass();
    347354            }
    348        }
    349 
    350         return false;
     355            set_transient($tr_name, $available_products, HOUR_IN_SECONDS);
     356        }
     357
     358        if (is_object($available_products) && property_exists($available_products, static::TABBY_METHOD_CODE)) {
     359            $is_available = true;
     360        }
     361
     362        return $is_available;
    351363    }
    352364
  • tabby-checkout/tags/4.10.4/includes/class-wc-tabby-ajax.php

    r3049660 r3073241  
    3636        if (!$email) return $result;
    3737
     38        $sha256 = hash('sha256', json_encode([$email, $phone]));
     39        $tr_name = 'tabby_oh_' . $sha256;
     40        if (($order_history = get_transient($tr_name)) !== false) {
     41            return $order_history;
     42        }
     43
    3844        $wc2tabby = [
    3945            //'pending' => 'processing',
     
    6066            }
    6167        }
     68
     69        set_transient($tr_name, $result, HOUR_IN_SECONDS);
     70
    6271        return $result;
    6372    }
  • tabby-checkout/tags/4.10.4/includes/class-wc-tabby-promo.php

    r3049660 r3073241  
    208208    }
    209209    public static function getMaxPrice() {
    210         return get_option('tabby_checkout_promo_price', 0);
     210        return (int)get_option('tabby_checkout_promo_price', 0);
    211211    }
    212212    public static function getMinTotal() {
    213         return get_option('tabby_checkout_promo_min_total', 0);
     213        return (int)get_option('tabby_checkout_promo_min_total', 0);
    214214    }
    215215    public static function getEmail() {
  • tabby-checkout/tags/4.10.4/readme.txt

    r3053766 r3073241  
    44Requires at least: 5.7
    55Tested up to: 6.5
    6 Stable tag: 4.10.1
     6Stable tag: 4.10.4
    77Requires PHP: 7.0
    88License: GPLv3
     
    2828
    2929== Changelog ==
     30
     31= 4.10.4 =
     32
     33* Fix merchant code country selection order
     34
     35= 4.10.2 =
     36
     37* Cache added for prescoring and order history
    3038
    3139= 4.10.1 =
  • tabby-checkout/tags/4.10.4/tabby-checkout.php

    r3053766 r3073241  
    44 * Plugin URI: https://tabby.ai/
    55 * Description: Tabby Checkout
    6  * Version: 4.10.1
     6 * Version: 4.10.4
    77 * Author: Tabby
    88 * Author URI: https://tabby.ai
     
    1414defined( 'ABSPATH' ) || exit;
    1515
    16 define ('MODULE_TABBY_CHECKOUT_VERSION', '4.10.1');
     16define ('MODULE_TABBY_CHECKOUT_VERSION', '4.10.4');
    1717define ('TABBY_CHECKOUT_DOMAIN', 'checkout.tabby.ai');
    1818define ('TABBY_CHECKOUT_API_DOMAIN', 'api.tabby.ai');
  • tabby-checkout/trunk/includes/class-wc-gateway-tabby-checkout-base.php

    r3053766 r3073241  
    291291    public function getMerchantCode($order = null) {
    292292        if ($order) {
    293             $code = $order->get_shipping_country() ?: $order->get_billing_country();
     293            $code = $order->get_billing_country() ?: $order->get_shipping_country();
    294294        } else {
    295             $code = WC()->customer->get_shipping_country() ?: WC()->customer->get_billing_country();
     295            $code = WC()->customer->get_billing_country() ?: WC()->customer->get_shipping_country();
    296296        }
    297297        if ($code == 'undefined' || empty($code)) $code = wc_get_base_location()['country'];
     
    340340        ];
    341341
    342         $result = WC_Tabby_Api::request('checkout', 'POST', $request);
    343 
    344         if ($result && property_exists($result, 'status') && $result->status == 'created') {
    345             if (property_exists($result->configuration->available_products, static::TABBY_METHOD_CODE)) {
    346                 return true;
     342        $is_available = false;
     343       
     344        $sha256 = hash('sha256', json_encode($request));
     345        $tr_name = 'tabby_api_cache_' . $sha256;
     346
     347        if (($available_products = get_transient($tr_name)) === false) {
     348            $result = WC_Tabby_Api::request('checkout', 'POST', $request);
     349
     350            if ($result && property_exists($result, 'status') && $result->status == 'created') {
     351                $available_products = $result->configuration->available_products;
     352            } else {
     353                $available_products = new \StdClass();
    347354            }
    348        }
    349 
    350         return false;
     355            set_transient($tr_name, $available_products, HOUR_IN_SECONDS);
     356        }
     357
     358        if (is_object($available_products) && property_exists($available_products, static::TABBY_METHOD_CODE)) {
     359            $is_available = true;
     360        }
     361
     362        return $is_available;
    351363    }
    352364
  • tabby-checkout/trunk/includes/class-wc-tabby-ajax.php

    r3049660 r3073241  
    3636        if (!$email) return $result;
    3737
     38        $sha256 = hash('sha256', json_encode([$email, $phone]));
     39        $tr_name = 'tabby_oh_' . $sha256;
     40        if (($order_history = get_transient($tr_name)) !== false) {
     41            return $order_history;
     42        }
     43
    3844        $wc2tabby = [
    3945            //'pending' => 'processing',
     
    6066            }
    6167        }
     68
     69        set_transient($tr_name, $result, HOUR_IN_SECONDS);
     70
    6271        return $result;
    6372    }
  • tabby-checkout/trunk/includes/class-wc-tabby-promo.php

    r3049660 r3073241  
    208208    }
    209209    public static function getMaxPrice() {
    210         return get_option('tabby_checkout_promo_price', 0);
     210        return (int)get_option('tabby_checkout_promo_price', 0);
    211211    }
    212212    public static function getMinTotal() {
    213         return get_option('tabby_checkout_promo_min_total', 0);
     213        return (int)get_option('tabby_checkout_promo_min_total', 0);
    214214    }
    215215    public static function getEmail() {
  • tabby-checkout/trunk/readme.txt

    r3053766 r3073241  
    44Requires at least: 5.7
    55Tested up to: 6.5
    6 Stable tag: 4.10.1
     6Stable tag: 4.10.4
    77Requires PHP: 7.0
    88License: GPLv3
     
    2828
    2929== Changelog ==
     30
     31= 4.10.4 =
     32
     33* Fix merchant code country selection order
     34
     35= 4.10.2 =
     36
     37* Cache added for prescoring and order history
    3038
    3139= 4.10.1 =
  • tabby-checkout/trunk/tabby-checkout.php

    r3053766 r3073241  
    44 * Plugin URI: https://tabby.ai/
    55 * Description: Tabby Checkout
    6  * Version: 4.10.1
     6 * Version: 4.10.4
    77 * Author: Tabby
    88 * Author URI: https://tabby.ai
     
    1414defined( 'ABSPATH' ) || exit;
    1515
    16 define ('MODULE_TABBY_CHECKOUT_VERSION', '4.10.1');
     16define ('MODULE_TABBY_CHECKOUT_VERSION', '4.10.4');
    1717define ('TABBY_CHECKOUT_DOMAIN', 'checkout.tabby.ai');
    1818define ('TABBY_CHECKOUT_API_DOMAIN', 'api.tabby.ai');
Note: See TracChangeset for help on using the changeset viewer.