Plugin Directory

Changeset 2972430


Ignore:
Timestamp:
09/28/2023 12:43:15 AM (3 years ago)
Author:
clearpayit
Message:

Release v3.6.1.

Location:
clearpay-gateway-for-woocommerce
Files:
1 deleted
14 edited
1 copied

Legend:

Unmodified
Added
Removed
  • clearpay-gateway-for-woocommerce/tags/3.6.1/class/WC_Gateway_Clearpay.php

    r2959052 r2972430  
    22222222            // }
    22232223
     2224            $attributes['data-platform'] = 'WooCommerce';
     2225
     2226            $page_type_mapping = [
     2227                'category-pages' => 'category',
     2228                'product-pages' => 'product',
     2229                'product-variant' => 'product-variant',
     2230                'cart-page' => 'cart'
     2231            ];
     2232            $attributes['data-page-type'] = $page_type_mapping[$context];
     2233
     2234            if ($context == 'cart-page') {
     2235                $item_skus = $this->get_cart_item_skus();
     2236                $item_categories = $this->get_cart_item_categories();
     2237            } else {
     2238                $item_skus = $product->get_sku();
     2239                $item_categories = $this->get_category_names_by_product($product);
     2240            }
     2241            $attributes['data-item-skus'] = $item_skus;
     2242            $attributes['data-item-categories'] = $item_categories;
     2243
    22242244            echo '<square-placement';
    22252245            foreach ($attributes as $key => $value) {
     
    22282248            echo '></square-placement>';
    22292249            wp_enqueue_script('square_marketplace_js');
     2250        }
     2251
     2252        /**
     2253         * Gets skus for items in cart as a comma-separated string
     2254         *
     2255         * @since 3.6.1
     2256         * @return String
     2257         */
     2258        private function get_cart_item_skus() {
     2259            $skus = [];
     2260            if (did_action('wp_loaded')) {
     2261                foreach (WC()->cart->get_cart() as $cart_item) {
     2262                    $product = $cart_item['data'];
     2263                    $skus[] = $product->get_sku();
     2264                }
     2265            }
     2266            return implode(',', $skus);
     2267        }
     2268
     2269        /**
     2270         * Gets category names given a product, return a comma-separated string or an array.
     2271         *
     2272         * @since 3.6.1
     2273         * @param WC_Product    $product
     2274         * @param Boolean   $return_array
     2275         * @return String|String[]
     2276         */
     2277        private function get_category_names_by_product($product, $return_array = false) {
     2278            $category_names = [];
     2279
     2280            if ($product instanceof WC_Product) {
     2281                $category_ids = $product->get_category_ids();
     2282
     2283                if (empty($category_ids) && $product instanceof WC_Product_Variation &&
     2284                    $parent_product = wc_get_product($product->get_parent_id())
     2285                ) {
     2286                    $category_ids = $parent_product->get_category_ids();
     2287                }
     2288
     2289                $category_names = array_map(
     2290                    function($cat_id) {
     2291                        $category = get_term_by('id', $cat_id, 'product_cat');
     2292                        if ($category) {
     2293                            return $category->name;
     2294                        }
     2295                    },
     2296                    $category_ids
     2297                );
     2298                $category_names = array_unique(array_filter($category_names));
     2299            }
     2300
     2301            return $return_array ? $category_names : implode(',', $category_names);
     2302        }
     2303
     2304        /**
     2305         * Loops through cart items and gets unique category names as a comma-separated string
     2306         *
     2307         * @since 3.6.1
     2308         * @return String
     2309         */
     2310        private function get_cart_item_categories() {
     2311            $category_names = [];
     2312            if (did_action('wp_loaded')) {
     2313                foreach (WC()->cart->get_cart() as $cart_item) {
     2314                    $product = $cart_item['data'];
     2315                    $product_category_names = $this->get_category_names_by_product($product, true);
     2316                    $category_names = array_merge($category_names, $product_category_names);
     2317                    $category_names = array_unique($category_names);
     2318                }
     2319            }
     2320            return implode(',', $category_names);
    22302321        }
    22312322
  • clearpay-gateway-for-woocommerce/tags/3.6.1/clearpay-gateway-for-woocommerce.php

    r2959052 r2972430  
    55 * Author: Clearpay
    66 * Author URI: https://www.clearpay.co.uk/
    7  * Version: 3.6.0
     7 * Version: 3.6.1
    88 * Text Domain: woo_clearpay
    99 * Domain Path: /languages/
    1010 * WC requires at least: 3.2.6
    11  * WC tested up to: 8.0.2
     11 * WC tested up to: 8.1.1
    1212 *
    1313 * Copyright: (c) 2021 Clearpay
     
    4747         *                                          the value in the comments above.
    4848         */
    49         public static $version = '3.6.0';
     49        public static $version = '3.6.1';
    5050
    5151        /**
  • clearpay-gateway-for-woocommerce/tags/3.6.1/readme.txt

    r2959052 r2972430  
    33Tags: woocommerce, clearpay
    44Requires at least: 4.8.3
    5 Tested up to: 6.3.0
    6 Stable tag: 3.6.0
     5Tested up to: 6.3.1
     6Stable tag: 3.6.1
    77License: GNU Public License
    88License URI: https://www.gnu.org/licenses/
     
    4040== Changelog ==
    4141
     42= 3.6.1 =
     43*Release Date: Thursday, 28 Sep 2023*
     44
     45* Added extra data attributes to messaging elements.
     46* Tested and verified support for WordPress 6.3.1 and WooCommerce 8.1.1.
     47
    4248= 3.6.0 =
    4349*Release Date: Monday, 28 Aug 2023*
  • clearpay-gateway-for-woocommerce/tags/3.6.1/vendor/autoload.php

    r2959052 r2972430  
    2323require_once __DIR__ . '/composer/autoload_real.php';
    2424
    25 return ComposerAutoloaderInit944fdff2186aa515758a109e6ee48d3e::getLoader();
     25return ComposerAutoloaderInit28353fa2aaa659c6a5bb5054fe0a7d25::getLoader();
  • clearpay-gateway-for-woocommerce/tags/3.6.1/vendor/composer/autoload_real.php

    r2959052 r2972430  
    33// autoload_real.php @generated by Composer
    44
    5 class ComposerAutoloaderInit944fdff2186aa515758a109e6ee48d3e
     5class ComposerAutoloaderInit28353fa2aaa659c6a5bb5054fe0a7d25
    66{
    77    private static $loader;
     
    2323        }
    2424
    25         spl_autoload_register(array('ComposerAutoloaderInit944fdff2186aa515758a109e6ee48d3e', 'loadClassLoader'), true, true);
     25        spl_autoload_register(array('ComposerAutoloaderInit28353fa2aaa659c6a5bb5054fe0a7d25', 'loadClassLoader'), true, true);
    2626        self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
    27         spl_autoload_unregister(array('ComposerAutoloaderInit944fdff2186aa515758a109e6ee48d3e', 'loadClassLoader'));
     27        spl_autoload_unregister(array('ComposerAutoloaderInit28353fa2aaa659c6a5bb5054fe0a7d25', 'loadClassLoader'));
    2828
    2929        require __DIR__ . '/autoload_static.php';
    30         call_user_func(\Composer\Autoload\ComposerStaticInit944fdff2186aa515758a109e6ee48d3e::getInitializer($loader));
     30        call_user_func(\Composer\Autoload\ComposerStaticInit28353fa2aaa659c6a5bb5054fe0a7d25::getInitializer($loader));
    3131
    3232        $loader->register(true);
  • clearpay-gateway-for-woocommerce/tags/3.6.1/vendor/composer/autoload_static.php

    r2959052 r2972430  
    55namespace Composer\Autoload;
    66
    7 class ComposerStaticInit944fdff2186aa515758a109e6ee48d3e
     7class ComposerStaticInit28353fa2aaa659c6a5bb5054fe0a7d25
    88{
    99    public static $prefixLengthsPsr4 = array (
     
    2828    {
    2929        return \Closure::bind(function () use ($loader) {
    30             $loader->prefixLengthsPsr4 = ComposerStaticInit944fdff2186aa515758a109e6ee48d3e::$prefixLengthsPsr4;
    31             $loader->prefixDirsPsr4 = ComposerStaticInit944fdff2186aa515758a109e6ee48d3e::$prefixDirsPsr4;
    32             $loader->classMap = ComposerStaticInit944fdff2186aa515758a109e6ee48d3e::$classMap;
     30            $loader->prefixLengthsPsr4 = ComposerStaticInit28353fa2aaa659c6a5bb5054fe0a7d25::$prefixLengthsPsr4;
     31            $loader->prefixDirsPsr4 = ComposerStaticInit28353fa2aaa659c6a5bb5054fe0a7d25::$prefixDirsPsr4;
     32            $loader->classMap = ComposerStaticInit28353fa2aaa659c6a5bb5054fe0a7d25::$classMap;
    3333
    3434        }, null, ClassLoader::class);
  • clearpay-gateway-for-woocommerce/tags/3.6.1/vendor/composer/installed.php

    r2959052 r2972430  
    44        'pretty_version' => 'dev-master',
    55        'version' => 'dev-master',
    6         'reference' => '3a7381e7096bf14d40a992c5a7e99aaadfae528d',
     6        'reference' => '6fb292f5312bd300225d794929165e2bf0fe4c72',
    77        'type' => 'library',
    88        'install_path' => __DIR__ . '/../../',
     
    1414            'pretty_version' => 'dev-master',
    1515            'version' => 'dev-master',
    16             'reference' => '3a7381e7096bf14d40a992c5a7e99aaadfae528d',
     16            'reference' => '6fb292f5312bd300225d794929165e2bf0fe4c72',
    1717            'type' => 'library',
    1818            'install_path' => __DIR__ . '/../../',
  • clearpay-gateway-for-woocommerce/trunk/class/WC_Gateway_Clearpay.php

    r2959052 r2972430  
    22222222            // }
    22232223
     2224            $attributes['data-platform'] = 'WooCommerce';
     2225
     2226            $page_type_mapping = [
     2227                'category-pages' => 'category',
     2228                'product-pages' => 'product',
     2229                'product-variant' => 'product-variant',
     2230                'cart-page' => 'cart'
     2231            ];
     2232            $attributes['data-page-type'] = $page_type_mapping[$context];
     2233
     2234            if ($context == 'cart-page') {
     2235                $item_skus = $this->get_cart_item_skus();
     2236                $item_categories = $this->get_cart_item_categories();
     2237            } else {
     2238                $item_skus = $product->get_sku();
     2239                $item_categories = $this->get_category_names_by_product($product);
     2240            }
     2241            $attributes['data-item-skus'] = $item_skus;
     2242            $attributes['data-item-categories'] = $item_categories;
     2243
    22242244            echo '<square-placement';
    22252245            foreach ($attributes as $key => $value) {
     
    22282248            echo '></square-placement>';
    22292249            wp_enqueue_script('square_marketplace_js');
     2250        }
     2251
     2252        /**
     2253         * Gets skus for items in cart as a comma-separated string
     2254         *
     2255         * @since 3.6.1
     2256         * @return String
     2257         */
     2258        private function get_cart_item_skus() {
     2259            $skus = [];
     2260            if (did_action('wp_loaded')) {
     2261                foreach (WC()->cart->get_cart() as $cart_item) {
     2262                    $product = $cart_item['data'];
     2263                    $skus[] = $product->get_sku();
     2264                }
     2265            }
     2266            return implode(',', $skus);
     2267        }
     2268
     2269        /**
     2270         * Gets category names given a product, return a comma-separated string or an array.
     2271         *
     2272         * @since 3.6.1
     2273         * @param WC_Product    $product
     2274         * @param Boolean   $return_array
     2275         * @return String|String[]
     2276         */
     2277        private function get_category_names_by_product($product, $return_array = false) {
     2278            $category_names = [];
     2279
     2280            if ($product instanceof WC_Product) {
     2281                $category_ids = $product->get_category_ids();
     2282
     2283                if (empty($category_ids) && $product instanceof WC_Product_Variation &&
     2284                    $parent_product = wc_get_product($product->get_parent_id())
     2285                ) {
     2286                    $category_ids = $parent_product->get_category_ids();
     2287                }
     2288
     2289                $category_names = array_map(
     2290                    function($cat_id) {
     2291                        $category = get_term_by('id', $cat_id, 'product_cat');
     2292                        if ($category) {
     2293                            return $category->name;
     2294                        }
     2295                    },
     2296                    $category_ids
     2297                );
     2298                $category_names = array_unique(array_filter($category_names));
     2299            }
     2300
     2301            return $return_array ? $category_names : implode(',', $category_names);
     2302        }
     2303
     2304        /**
     2305         * Loops through cart items and gets unique category names as a comma-separated string
     2306         *
     2307         * @since 3.6.1
     2308         * @return String
     2309         */
     2310        private function get_cart_item_categories() {
     2311            $category_names = [];
     2312            if (did_action('wp_loaded')) {
     2313                foreach (WC()->cart->get_cart() as $cart_item) {
     2314                    $product = $cart_item['data'];
     2315                    $product_category_names = $this->get_category_names_by_product($product, true);
     2316                    $category_names = array_merge($category_names, $product_category_names);
     2317                    $category_names = array_unique($category_names);
     2318                }
     2319            }
     2320            return implode(',', $category_names);
    22302321        }
    22312322
  • clearpay-gateway-for-woocommerce/trunk/clearpay-gateway-for-woocommerce.php

    r2959052 r2972430  
    55 * Author: Clearpay
    66 * Author URI: https://www.clearpay.co.uk/
    7  * Version: 3.6.0
     7 * Version: 3.6.1
    88 * Text Domain: woo_clearpay
    99 * Domain Path: /languages/
    1010 * WC requires at least: 3.2.6
    11  * WC tested up to: 8.0.2
     11 * WC tested up to: 8.1.1
    1212 *
    1313 * Copyright: (c) 2021 Clearpay
     
    4747         *                                          the value in the comments above.
    4848         */
    49         public static $version = '3.6.0';
     49        public static $version = '3.6.1';
    5050
    5151        /**
  • clearpay-gateway-for-woocommerce/trunk/readme.txt

    r2959052 r2972430  
    33Tags: woocommerce, clearpay
    44Requires at least: 4.8.3
    5 Tested up to: 6.3.0
    6 Stable tag: 3.6.0
     5Tested up to: 6.3.1
     6Stable tag: 3.6.1
    77License: GNU Public License
    88License URI: https://www.gnu.org/licenses/
     
    4040== Changelog ==
    4141
     42= 3.6.1 =
     43*Release Date: Thursday, 28 Sep 2023*
     44
     45* Added extra data attributes to messaging elements.
     46* Tested and verified support for WordPress 6.3.1 and WooCommerce 8.1.1.
     47
    4248= 3.6.0 =
    4349*Release Date: Monday, 28 Aug 2023*
  • clearpay-gateway-for-woocommerce/trunk/vendor/autoload.php

    r2959052 r2972430  
    2323require_once __DIR__ . '/composer/autoload_real.php';
    2424
    25 return ComposerAutoloaderInit944fdff2186aa515758a109e6ee48d3e::getLoader();
     25return ComposerAutoloaderInit28353fa2aaa659c6a5bb5054fe0a7d25::getLoader();
  • clearpay-gateway-for-woocommerce/trunk/vendor/composer/autoload_real.php

    r2959052 r2972430  
    33// autoload_real.php @generated by Composer
    44
    5 class ComposerAutoloaderInit944fdff2186aa515758a109e6ee48d3e
     5class ComposerAutoloaderInit28353fa2aaa659c6a5bb5054fe0a7d25
    66{
    77    private static $loader;
     
    2323        }
    2424
    25         spl_autoload_register(array('ComposerAutoloaderInit944fdff2186aa515758a109e6ee48d3e', 'loadClassLoader'), true, true);
     25        spl_autoload_register(array('ComposerAutoloaderInit28353fa2aaa659c6a5bb5054fe0a7d25', 'loadClassLoader'), true, true);
    2626        self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
    27         spl_autoload_unregister(array('ComposerAutoloaderInit944fdff2186aa515758a109e6ee48d3e', 'loadClassLoader'));
     27        spl_autoload_unregister(array('ComposerAutoloaderInit28353fa2aaa659c6a5bb5054fe0a7d25', 'loadClassLoader'));
    2828
    2929        require __DIR__ . '/autoload_static.php';
    30         call_user_func(\Composer\Autoload\ComposerStaticInit944fdff2186aa515758a109e6ee48d3e::getInitializer($loader));
     30        call_user_func(\Composer\Autoload\ComposerStaticInit28353fa2aaa659c6a5bb5054fe0a7d25::getInitializer($loader));
    3131
    3232        $loader->register(true);
  • clearpay-gateway-for-woocommerce/trunk/vendor/composer/autoload_static.php

    r2959052 r2972430  
    55namespace Composer\Autoload;
    66
    7 class ComposerStaticInit944fdff2186aa515758a109e6ee48d3e
     7class ComposerStaticInit28353fa2aaa659c6a5bb5054fe0a7d25
    88{
    99    public static $prefixLengthsPsr4 = array (
     
    2828    {
    2929        return \Closure::bind(function () use ($loader) {
    30             $loader->prefixLengthsPsr4 = ComposerStaticInit944fdff2186aa515758a109e6ee48d3e::$prefixLengthsPsr4;
    31             $loader->prefixDirsPsr4 = ComposerStaticInit944fdff2186aa515758a109e6ee48d3e::$prefixDirsPsr4;
    32             $loader->classMap = ComposerStaticInit944fdff2186aa515758a109e6ee48d3e::$classMap;
     30            $loader->prefixLengthsPsr4 = ComposerStaticInit28353fa2aaa659c6a5bb5054fe0a7d25::$prefixLengthsPsr4;
     31            $loader->prefixDirsPsr4 = ComposerStaticInit28353fa2aaa659c6a5bb5054fe0a7d25::$prefixDirsPsr4;
     32            $loader->classMap = ComposerStaticInit28353fa2aaa659c6a5bb5054fe0a7d25::$classMap;
    3333
    3434        }, null, ClassLoader::class);
  • clearpay-gateway-for-woocommerce/trunk/vendor/composer/installed.php

    r2959052 r2972430  
    44        'pretty_version' => 'dev-master',
    55        'version' => 'dev-master',
    6         'reference' => '3a7381e7096bf14d40a992c5a7e99aaadfae528d',
     6        'reference' => '6fb292f5312bd300225d794929165e2bf0fe4c72',
    77        'type' => 'library',
    88        'install_path' => __DIR__ . '/../../',
     
    1414            'pretty_version' => 'dev-master',
    1515            'version' => 'dev-master',
    16             'reference' => '3a7381e7096bf14d40a992c5a7e99aaadfae528d',
     16            'reference' => '6fb292f5312bd300225d794929165e2bf0fe4c72',
    1717            'type' => 'library',
    1818            'install_path' => __DIR__ . '/../../',
Note: See TracChangeset for help on using the changeset viewer.