Plugin Directory

Changeset 2972429


Ignore:
Timestamp:
09/28/2023 12:34:46 AM (3 years ago)
Author:
afterpayit
Message:

Release v3.6.1.

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

Legend:

Unmodified
Added
Removed
  • afterpay-gateway-for-woocommerce/tags/3.6.1/afterpay-gateway-for-woocommerce.php

    r2959051 r2972429  
    55 * Author: Afterpay
    66 * Author URI: https://www.afterpay.com/
    7  * Version: 3.6.0
     7 * Version: 3.6.1
    88 * Text Domain: afterpay-gateway-for-woocommerce
    99 * WC requires at least: 3.2.6
    10  * WC tested up to: 8.0.2
     10 * WC tested up to: 8.1.1
    1111 *
    1212 * Copyright: (c) 2020 Afterpay
     
    4646         *                                          the value in the comments above.
    4747         */
    48         public static $version = '3.6.0';
     48        public static $version = '3.6.1';
    4949
    5050        /**
  • afterpay-gateway-for-woocommerce/tags/3.6.1/class/WC_Gateway_Afterpay.php

    r2959051 r2972429  
    22312231            // }
    22322232
     2233            $attributes['data-platform'] = 'WooCommerce';
     2234
     2235            $page_type_mapping = [
     2236                'category-pages' => 'category',
     2237                'product-pages' => 'product',
     2238                'product-variant' => 'product-variant',
     2239                'cart-page' => 'cart'
     2240            ];
     2241            $attributes['data-page-type'] = $page_type_mapping[$context];
     2242
     2243            if ($context == 'cart-page') {
     2244                $item_skus = $this->get_cart_item_skus();
     2245                $item_categories = $this->get_cart_item_categories();
     2246            } else {
     2247                $item_skus = $product->get_sku();
     2248                $item_categories = $this->get_category_names_by_product($product);
     2249            }
     2250            $attributes['data-item-skus'] = $item_skus;
     2251            $attributes['data-item-categories'] = $item_categories;
     2252
    22332253            echo '<square-placement';
    22342254            foreach ($attributes as $key => $value) {
     
    22372257            echo '></square-placement>';
    22382258            wp_enqueue_script('square_marketplace_js');
     2259        }
     2260
     2261        /**
     2262         * Gets skus for items in cart as a comma-separated string
     2263         *
     2264         * @since 3.6.1
     2265         * @return String
     2266         */
     2267        private function get_cart_item_skus() {
     2268            $skus = [];
     2269            if (did_action('wp_loaded')) {
     2270                foreach (WC()->cart->get_cart() as $cart_item) {
     2271                    $product = $cart_item['data'];
     2272                    $skus[] = $product->get_sku();
     2273                }
     2274            }
     2275            return implode(',', $skus);
     2276        }
     2277
     2278        /**
     2279         * Gets category names given a product, return a comma-separated string or an array.
     2280         *
     2281         * @since 3.6.1
     2282         * @param WC_Product    $product
     2283         * @param Boolean   $return_array
     2284         * @return String|String[]
     2285         */
     2286        private function get_category_names_by_product($product, $return_array = false) {
     2287            $category_names = [];
     2288
     2289            if ($product instanceof WC_Product) {
     2290                $category_ids = $product->get_category_ids();
     2291
     2292                if (empty($category_ids) && $product instanceof WC_Product_Variation &&
     2293                    $parent_product = wc_get_product($product->get_parent_id())
     2294                ) {
     2295                    $category_ids = $parent_product->get_category_ids();
     2296                }
     2297
     2298                $category_names = array_map(
     2299                    function($cat_id) {
     2300                        $category = get_term_by('id', $cat_id, 'product_cat');
     2301                        if ($category) {
     2302                            return $category->name;
     2303                        }
     2304                    },
     2305                    $category_ids
     2306                );
     2307                $category_names = array_unique(array_filter($category_names));
     2308            }
     2309
     2310            return $return_array ? $category_names : implode(',', $category_names);
     2311        }
     2312
     2313        /**
     2314         * Loops through cart items and gets unique category names as a comma-separated string
     2315         *
     2316         * @since 3.6.1
     2317         * @return String
     2318         */
     2319        private function get_cart_item_categories() {
     2320            $category_names = [];
     2321            if (did_action('wp_loaded')) {
     2322                foreach (WC()->cart->get_cart() as $cart_item) {
     2323                    $product = $cart_item['data'];
     2324                    $product_category_names = $this->get_category_names_by_product($product, true);
     2325                    $category_names = array_merge($category_names, $product_category_names);
     2326                    $category_names = array_unique($category_names);
     2327                }
     2328            }
     2329            return implode(',', $category_names);
    22392330        }
    22402331
  • afterpay-gateway-for-woocommerce/tags/3.6.1/readme.txt

    r2959051 r2972429  
    33Tags: woocommerce, afterpay
    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/
     
    3939
    4040== Changelog ==
     41
     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.
    4147
    4248= 3.6.0 =
  • afterpay-gateway-for-woocommerce/tags/3.6.1/vendor/autoload.php

    r2959051 r2972429  
    2323require_once __DIR__ . '/composer/autoload_real.php';
    2424
    25 return ComposerAutoloaderInit4875de1546ac4d9caa9f7de7df5885bc::getLoader();
     25return ComposerAutoloaderInitd1b79db0b8d59aaf8ea8aa86543d756f::getLoader();
  • afterpay-gateway-for-woocommerce/tags/3.6.1/vendor/composer/autoload_real.php

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

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

    r2959051 r2972429  
    44        'pretty_version' => 'dev-master',
    55        'version' => 'dev-master',
    6         'reference' => '73dda6190e37f65ea01abd032bba594233eee0d4',
     6        'reference' => '0fad5e51d0a6de8476a97c6d54bc409bbdf40fe2',
    77        'type' => 'library',
    88        'install_path' => __DIR__ . '/../../',
     
    1414            'pretty_version' => 'dev-master',
    1515            'version' => 'dev-master',
    16             'reference' => '73dda6190e37f65ea01abd032bba594233eee0d4',
     16            'reference' => '0fad5e51d0a6de8476a97c6d54bc409bbdf40fe2',
    1717            'type' => 'library',
    1818            'install_path' => __DIR__ . '/../../',
  • afterpay-gateway-for-woocommerce/trunk/afterpay-gateway-for-woocommerce.php

    r2959051 r2972429  
    55 * Author: Afterpay
    66 * Author URI: https://www.afterpay.com/
    7  * Version: 3.6.0
     7 * Version: 3.6.1
    88 * Text Domain: afterpay-gateway-for-woocommerce
    99 * WC requires at least: 3.2.6
    10  * WC tested up to: 8.0.2
     10 * WC tested up to: 8.1.1
    1111 *
    1212 * Copyright: (c) 2020 Afterpay
     
    4646         *                                          the value in the comments above.
    4747         */
    48         public static $version = '3.6.0';
     48        public static $version = '3.6.1';
    4949
    5050        /**
  • afterpay-gateway-for-woocommerce/trunk/class/WC_Gateway_Afterpay.php

    r2959051 r2972429  
    22312231            // }
    22322232
     2233            $attributes['data-platform'] = 'WooCommerce';
     2234
     2235            $page_type_mapping = [
     2236                'category-pages' => 'category',
     2237                'product-pages' => 'product',
     2238                'product-variant' => 'product-variant',
     2239                'cart-page' => 'cart'
     2240            ];
     2241            $attributes['data-page-type'] = $page_type_mapping[$context];
     2242
     2243            if ($context == 'cart-page') {
     2244                $item_skus = $this->get_cart_item_skus();
     2245                $item_categories = $this->get_cart_item_categories();
     2246            } else {
     2247                $item_skus = $product->get_sku();
     2248                $item_categories = $this->get_category_names_by_product($product);
     2249            }
     2250            $attributes['data-item-skus'] = $item_skus;
     2251            $attributes['data-item-categories'] = $item_categories;
     2252
    22332253            echo '<square-placement';
    22342254            foreach ($attributes as $key => $value) {
     
    22372257            echo '></square-placement>';
    22382258            wp_enqueue_script('square_marketplace_js');
     2259        }
     2260
     2261        /**
     2262         * Gets skus for items in cart as a comma-separated string
     2263         *
     2264         * @since 3.6.1
     2265         * @return String
     2266         */
     2267        private function get_cart_item_skus() {
     2268            $skus = [];
     2269            if (did_action('wp_loaded')) {
     2270                foreach (WC()->cart->get_cart() as $cart_item) {
     2271                    $product = $cart_item['data'];
     2272                    $skus[] = $product->get_sku();
     2273                }
     2274            }
     2275            return implode(',', $skus);
     2276        }
     2277
     2278        /**
     2279         * Gets category names given a product, return a comma-separated string or an array.
     2280         *
     2281         * @since 3.6.1
     2282         * @param WC_Product    $product
     2283         * @param Boolean   $return_array
     2284         * @return String|String[]
     2285         */
     2286        private function get_category_names_by_product($product, $return_array = false) {
     2287            $category_names = [];
     2288
     2289            if ($product instanceof WC_Product) {
     2290                $category_ids = $product->get_category_ids();
     2291
     2292                if (empty($category_ids) && $product instanceof WC_Product_Variation &&
     2293                    $parent_product = wc_get_product($product->get_parent_id())
     2294                ) {
     2295                    $category_ids = $parent_product->get_category_ids();
     2296                }
     2297
     2298                $category_names = array_map(
     2299                    function($cat_id) {
     2300                        $category = get_term_by('id', $cat_id, 'product_cat');
     2301                        if ($category) {
     2302                            return $category->name;
     2303                        }
     2304                    },
     2305                    $category_ids
     2306                );
     2307                $category_names = array_unique(array_filter($category_names));
     2308            }
     2309
     2310            return $return_array ? $category_names : implode(',', $category_names);
     2311        }
     2312
     2313        /**
     2314         * Loops through cart items and gets unique category names as a comma-separated string
     2315         *
     2316         * @since 3.6.1
     2317         * @return String
     2318         */
     2319        private function get_cart_item_categories() {
     2320            $category_names = [];
     2321            if (did_action('wp_loaded')) {
     2322                foreach (WC()->cart->get_cart() as $cart_item) {
     2323                    $product = $cart_item['data'];
     2324                    $product_category_names = $this->get_category_names_by_product($product, true);
     2325                    $category_names = array_merge($category_names, $product_category_names);
     2326                    $category_names = array_unique($category_names);
     2327                }
     2328            }
     2329            return implode(',', $category_names);
    22392330        }
    22402331
  • afterpay-gateway-for-woocommerce/trunk/readme.txt

    r2959051 r2972429  
    33Tags: woocommerce, afterpay
    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/
     
    3939
    4040== Changelog ==
     41
     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.
    4147
    4248= 3.6.0 =
  • afterpay-gateway-for-woocommerce/trunk/vendor/autoload.php

    r2959051 r2972429  
    2323require_once __DIR__ . '/composer/autoload_real.php';
    2424
    25 return ComposerAutoloaderInit4875de1546ac4d9caa9f7de7df5885bc::getLoader();
     25return ComposerAutoloaderInitd1b79db0b8d59aaf8ea8aa86543d756f::getLoader();
  • afterpay-gateway-for-woocommerce/trunk/vendor/composer/autoload_real.php

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

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

    r2959051 r2972429  
    44        'pretty_version' => 'dev-master',
    55        'version' => 'dev-master',
    6         'reference' => '73dda6190e37f65ea01abd032bba594233eee0d4',
     6        'reference' => '0fad5e51d0a6de8476a97c6d54bc409bbdf40fe2',
    77        'type' => 'library',
    88        'install_path' => __DIR__ . '/../../',
     
    1414            'pretty_version' => 'dev-master',
    1515            'version' => 'dev-master',
    16             'reference' => '73dda6190e37f65ea01abd032bba594233eee0d4',
     16            'reference' => '0fad5e51d0a6de8476a97c6d54bc409bbdf40fe2',
    1717            'type' => 'library',
    1818            'install_path' => __DIR__ . '/../../',
Note: See TracChangeset for help on using the changeset viewer.