Plugin Directory

Changeset 3157667


Ignore:
Timestamp:
09/25/2024 02:34:51 PM (18 months ago)
Author:
tabbyai
Message:

New Product Catalogue Feature

Location:
tabby-checkout/trunk
Files:
4 added
9 edited

Legend:

Unmodified
Added
Removed
  • tabby-checkout/trunk/assets/blocks/tabby-installments/index.js

    r3049660 r3157667  
    44const registerPaymentMethod = window.wc.wcBlocksRegistry.registerPaymentMethod;
    55const getPaymentMethodData = window.wc.wcSettings.getPaymentMethodData;
     6const __ = window.wp.i18n.__;
    67
    78const settings = getPaymentMethodData( 'tabby_installments', {} );
     
    8081    },
    8182    ariaLabel: title,
     83    placeOrderButtonLabel: __(
     84        'Proceed to Tabby',
     85        'tabby-checkout'
     86    ),
    8287    supports: {
    8388        features: settings?.supports ?? []
  • tabby-checkout/trunk/includes/class-wc-gateway-tabby-checkout-base.php

    r3073241 r3157667  
    173173        return $res;
    174174    }
    175     public function get_order_total() {
     175    public function get_order_total($order = null) {
     176        if ($order) return (float)$order->get_total();
    176177        return WC()->cart ? parent::get_order_total() : 0;
    177178    }
     
    325326        };
    326327        $config = json_decode(static::getTabbyConfig(), true);
     328        // show module on checkout if there is no email/phone entered
     329        if (empty($config['buyer']['email']) || empty($config['buyer']['phone'])) {
     330            return true;
     331        }
    327332        $config['payment']['buyer'] = $this->getFrontBuyerObject();
    328333        $config['payment']['order_history'] = WC_Tabby_AJAX::getOrderHistoryObject(
     
    342347        $is_available = false;
    343348       
    344         $sha256 = hash('sha256', json_encode($request));
     349        $sha256 = hash('sha256', json_encode($this->get_cached_values($request)));
    345350        $tr_name = 'tabby_api_cache_' . $sha256;
    346351
     
    361366
    362367        return $is_available;
     368    }
     369
     370    protected function get_cached_values($request) {
     371        return [
     372            "lang"          => $request["lang"],
     373            "merchant_code" => $request["merchant_code"],
     374            "amount"        => $request["payment"]["amount"],
     375            "currency"      => $request["payment"]["currency"],
     376            "email"         => $request["payment"]["buyer"]["email"],
     377            "phone"         => $request["payment"]["buyer"]["phone"]
     378        ];
    363379    }
    364380
     
    395411    public function getPaymentObject($order) {
    396412        return [
    397             "amount"            => $this->formatAmount($this->get_order_total()),
     413            "amount"            => $this->formatAmount($this->get_order_total($order)),
    398414            "currency"          => WC_Tabby_Config::getTabbyCurrency(),
    399415            //"buyer_history"   => $this->getBuyerHistoryObject(),
     
    496512            } else {
    497513                wc_add_notice( $redirect_url->get_error_message(), 'error' );
    498                 return;
     514                return [
     515                    'result'    => 'failure',
     516                    'message'   => 'Sorry Tabby is unable to approve this purchase, please use an alternative payment method for your order.'
     517                ];
    499518            }
    500519        } catch (\Exception $e) {
  • tabby-checkout/trunk/includes/class-wc-settings-tab-tabby.php

    r3019225 r3157667  
    2626
    2727    public static function tabby_update_settings() {
     28        $share_feed_old = get_option('tabby_share_feed', 'yes');
    2829        woocommerce_update_options( static::tabby_checkout_api_settings([], 'tabby_api') );
    2930        WC_Tabby_Webhook::register();
     31        $share_feed_new = get_option('tabby_share_feed', 'yes');
     32        if ($share_feed_old !== 'yes' && $share_feed_new === 'yes') {
     33            WC_Tabby_Feed_Sharing::register();
     34        };
     35        if ($share_feed_new !== 'yes') {
     36            WC_Tabby_Feed_Sharing::unregister();
     37        };
    3038    }
    3139
     
    6573                'desc' => __( 'The following options are used to configure Tabby Checkout API', 'tabby-checkout' ),
    6674                'id' => 'tabby-checkout'
     75            );
     76            $settings_tabby[] = array(
     77                'name'     => __( 'Share product feed with Tabby', 'tabby-checkout' ),
     78                'id'       => 'tabby_share_feed',
     79                'type'     => 'checkbox',
     80                'default'  => 'yes'
    6781            );
    6882            $settings_tabby[] = array(
  • tabby-checkout/trunk/includes/class-wc-tabby-api.php

    r3098715 r3157667  
    7979            if (!empty($body)) {
    8080                $result = json_decode($body);
    81                 if (is_object($result) && property_exists($result, 'error')) {
     81                if (!property_exists($result, 'error')) {
     82                    $result->error = '';
    8283                    $msg .= $result->errorType . ': ' . $result->error;
    83                 };
     84                }
    8485                static::debug(['response - body - ', (array)$result]);
    8586            }
     
    112113        $storeURL = parse_url(get_site_url());
    113114
     115        $woo_dir = WP_PLUGIN_DIR . '/woocommerce/woocommerce.php';
     116        $woo_data = get_plugin_data($woo_dir);
     117
    114118        $log = array(
    115119            "status"  => $status,
     
    117121
    118122            "service"  => "woo",
     123            "sversion" => $woo_data['Version'],
    119124            "hostname" => $storeURL["host"],
    120125
  • tabby-checkout/trunk/includes/class-wc-tabby-config.php

    r3098715 r3157667  
    55    const ALLOWED_COUNTRIES  = [ 'AE', 'SA', 'BH', 'KW',  'QA'];
    66
     7    public static function getDefaultMerchantCode() {
     8        $currency_code = static::getTabbyCurrency();
     9
     10        if (($index = array_search($currency_code, static::ALLOWED_CURRENCIES)) !== false) {
     11            return static::ALLOWED_COUNTRIES[$index];
     12        }
     13
     14        return 'default';
     15    }
    716    public static function isAvailableForCountry($country_code) {
    817        if (($allowed = static::getConfiguredCountries()) === false) {
     
    1322    public static function getConfiguredCountries() {
    1423        return get_option('tabby_countries', false);
     24    }
     25    public static function getShareFeed() {
     26        return get_option('tabby_share_feed', 'yes') == 'yes';
    1527    }
    1628    public static function isAvailableForCurrency($currency_code = null) {
     
    3648    }
    3749    public static function isDisabledForSKU($sku) {
    38         $disabled_skus = array_filter(explode("\n", get_option('tabby_checkout_disable_for_sku', '')));
     50        $disabled_skus = array_map(
     51            function ($item) {return trim($item);},
     52            array_filter(explode("\n", get_option('tabby_checkout_disable_for_sku', '')))
     53        );
    3954        return in_array($sku, $disabled_skus);
    4055    }
  • tabby-checkout/trunk/includes/class-wc-tabby-webhook.php

    r2927757 r3157667  
    4040    }
    4141    public static function isNotAuthorized($response) {
    42         if (is_object($response) && property_exists($response, 'errorType') && $response->errorType == 'not_authorized') return true;
     42        if (is_object($response) && property_exists($response, 'errorType') && in_array($response->errorType, ['not_authorized', 'not_found'])) return true;
    4343        return false;
    4444    }
  • tabby-checkout/trunk/includes/class-wc-tabby.php

    r3049660 r3157667  
    1010        WC_Tabby_Cron::init();
    1111        WC_REST_Tabby_Controller::init();
     12        WC_Tabby_Feed_Sharing::init();
    1213
    1314        static::init_methods();
     
    2021    public static function init_methods() {
    2122        add_filter( 'woocommerce_payment_gateways', array(__CLASS__, 'add_checkout_methods'));
    22 
    2323        add_action( 'woocommerce_blocks_loaded', array(__CLASS__, 'woocommerce_blocks_support'));
    24 
    2524    }
    2625    public static function woocommerce_blocks_support() {
     
    5655        wp_schedule_single_event( time() + 60 , 'woocommerce_tabby_cancel_unpaid_orders' );
    5756        WC_Tabby_Webhook::register();
     57
     58        if (WC_Tabby_Config::getShareFeed()) {
     59            WC_Tabby_Feed_Sharing::register();
     60        }
    5861    }
    5962
     
    6164        wp_clear_scheduled_hook( 'woocommerce_tabby_cancel_unpaid_orders' );
    6265        WC_Tabby_Webhook::unregister();
     66
     67        if (WC_Tabby_Config::getShareFeed()) {
     68            WC_Tabby_Feed_Sharing::unregister();
     69        }
    6370    }
    6471   
     
    6673        load_plugin_textdomain( 'tabby-checkout', false, plugin_basename( dirname(__DIR__) ) . '/i18n/languages' );
    6774    }
    68 
    6975}
  • tabby-checkout/trunk/readme.txt

    r3098715 r3157667  
    44Requires at least: 5.7
    55Tested up to: 6.5
    6 Stable tag: 4.10.6
     6Stable tag: 5.0.8
    77Requires PHP: 7.0
    88License: GPLv3
     
    2828
    2929== Changelog ==
     30
     31= 5.0.8 =
     32
     33* Minor fixes
     34
     35= 5.0.0 =
     36
     37* New Product Catalogue Feature
    3038
    3139= 4.10.6 =
     
    201209If we share your personal information with our group companies or other third parties, we will take steps to protect your personal information in our contractual agreements with these third parties, and to require that they have appropriate technical and organisational security measures in place, in compliance with applicable data protection laws.
    202210
     211
     212== Plugin Update: New Product Catalogue Feature ==
     213We’ve introduced an exciting new feature to the Tabby WooCommerce plugin – the **Product Catalogue Feature**, designed to help you list your store’s products seamlessly on the Tabby Shop. Here are the advantages this feature brings to your business:
     214
     215**Advantages:**
     216* **Automated Product Listing:** Easily list your entire WooCommerce store inventory on the Tabby Shop without manual intervention.
     217* **Real-Time Stock Updates:** Keep your product listings up-to-date effortlessly, as the plugin automatically syncs inventory availability and reflects out-of-stock items in real time.
     218* **Increased Visibility:** Showcase your products to a broader audience by making them visible to all Tabby app users.
     219* **Traffic Generation:** Drive interested shoppers directly to your WooCommerce store, increasing clicks and potential sales.
     220* **Simplified Setup:** The feature is enabled by default, so there’s nothing you need to do. If needed, you can manage it in the Tabby API settings by simply enabling or disabling the appropriate checkbox.
     221
     222This feature helps you reach more shoppers and boost your store’s visibility through the Tabby platform.
     223
    203224== Tabby Promo ==
    204225Customers are not always aware of the different financing options available to them before they reach the checkout. Tabby promo helps your customers learn about the advantages and possibilities of alternative payment methods which has a great impact on the conversion rate and customers' awareness.
  • tabby-checkout/trunk/tabby-checkout.php

    r3098715 r3157667  
    44 * Plugin URI: https://tabby.ai/
    55 * Description: Tabby Checkout
    6  * Version: 4.10.6
     6 * Version: 5.0.8
    77 * Author: Tabby
    88 * Author URI: https://tabby.ai
     
    1414defined( 'ABSPATH' ) || exit;
    1515
    16 define ('MODULE_TABBY_CHECKOUT_VERSION', '4.10.6');
     16define ('MODULE_TABBY_CHECKOUT_VERSION', '5.0.8');
    1717define ('TABBY_CHECKOUT_DOMAIN', 'checkout.tabby.ai');
    1818define ('TABBY_CHECKOUT_API_DOMAIN', 'api.tabby.ai');
     19define ('TABBY_FEED_API_DOMAIN', 'plugins-api.tabby.ai');
    1920
    2021include 'includes/functions.php';
Note: See TracChangeset for help on using the changeset viewer.