Changeset 2972430
- Timestamp:
- 09/28/2023 12:43:15 AM (3 years ago)
- Location:
- clearpay-gateway-for-woocommerce
- Files:
-
- 1 deleted
- 14 edited
- 1 copied
-
tags/3.6.0 (deleted)
-
tags/3.6.1 (copied) (copied from clearpay-gateway-for-woocommerce/trunk)
-
tags/3.6.1/class/WC_Gateway_Clearpay.php (modified) (2 diffs)
-
tags/3.6.1/clearpay-gateway-for-woocommerce.php (modified) (2 diffs)
-
tags/3.6.1/readme.txt (modified) (2 diffs)
-
tags/3.6.1/vendor/autoload.php (modified) (1 diff)
-
tags/3.6.1/vendor/composer/autoload_real.php (modified) (2 diffs)
-
tags/3.6.1/vendor/composer/autoload_static.php (modified) (2 diffs)
-
tags/3.6.1/vendor/composer/installed.php (modified) (2 diffs)
-
trunk/class/WC_Gateway_Clearpay.php (modified) (2 diffs)
-
trunk/clearpay-gateway-for-woocommerce.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/vendor/autoload.php (modified) (1 diff)
-
trunk/vendor/composer/autoload_real.php (modified) (2 diffs)
-
trunk/vendor/composer/autoload_static.php (modified) (2 diffs)
-
trunk/vendor/composer/installed.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
clearpay-gateway-for-woocommerce/tags/3.6.1/class/WC_Gateway_Clearpay.php
r2959052 r2972430 2222 2222 // } 2223 2223 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 2224 2244 echo '<square-placement'; 2225 2245 foreach ($attributes as $key => $value) { … … 2228 2248 echo '></square-placement>'; 2229 2249 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); 2230 2321 } 2231 2322 -
clearpay-gateway-for-woocommerce/tags/3.6.1/clearpay-gateway-for-woocommerce.php
r2959052 r2972430 5 5 * Author: Clearpay 6 6 * Author URI: https://www.clearpay.co.uk/ 7 * Version: 3.6. 07 * Version: 3.6.1 8 8 * Text Domain: woo_clearpay 9 9 * Domain Path: /languages/ 10 10 * WC requires at least: 3.2.6 11 * WC tested up to: 8. 0.211 * WC tested up to: 8.1.1 12 12 * 13 13 * Copyright: (c) 2021 Clearpay … … 47 47 * the value in the comments above. 48 48 */ 49 public static $version = '3.6. 0';49 public static $version = '3.6.1'; 50 50 51 51 /** -
clearpay-gateway-for-woocommerce/tags/3.6.1/readme.txt
r2959052 r2972430 3 3 Tags: woocommerce, clearpay 4 4 Requires at least: 4.8.3 5 Tested up to: 6.3. 06 Stable tag: 3.6. 05 Tested up to: 6.3.1 6 Stable tag: 3.6.1 7 7 License: GNU Public License 8 8 License URI: https://www.gnu.org/licenses/ … … 40 40 == Changelog == 41 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. 47 42 48 = 3.6.0 = 43 49 *Release Date: Monday, 28 Aug 2023* -
clearpay-gateway-for-woocommerce/tags/3.6.1/vendor/autoload.php
r2959052 r2972430 23 23 require_once __DIR__ . '/composer/autoload_real.php'; 24 24 25 return ComposerAutoloaderInit 944fdff2186aa515758a109e6ee48d3e::getLoader();25 return ComposerAutoloaderInit28353fa2aaa659c6a5bb5054fe0a7d25::getLoader(); -
clearpay-gateway-for-woocommerce/tags/3.6.1/vendor/composer/autoload_real.php
r2959052 r2972430 3 3 // autoload_real.php @generated by Composer 4 4 5 class ComposerAutoloaderInit 944fdff2186aa515758a109e6ee48d3e5 class ComposerAutoloaderInit28353fa2aaa659c6a5bb5054fe0a7d25 6 6 { 7 7 private static $loader; … … 23 23 } 24 24 25 spl_autoload_register(array('ComposerAutoloaderInit 944fdff2186aa515758a109e6ee48d3e', 'loadClassLoader'), true, true);25 spl_autoload_register(array('ComposerAutoloaderInit28353fa2aaa659c6a5bb5054fe0a7d25', 'loadClassLoader'), true, true); 26 26 self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); 27 spl_autoload_unregister(array('ComposerAutoloaderInit 944fdff2186aa515758a109e6ee48d3e', 'loadClassLoader'));27 spl_autoload_unregister(array('ComposerAutoloaderInit28353fa2aaa659c6a5bb5054fe0a7d25', 'loadClassLoader')); 28 28 29 29 require __DIR__ . '/autoload_static.php'; 30 call_user_func(\Composer\Autoload\ComposerStaticInit 944fdff2186aa515758a109e6ee48d3e::getInitializer($loader));30 call_user_func(\Composer\Autoload\ComposerStaticInit28353fa2aaa659c6a5bb5054fe0a7d25::getInitializer($loader)); 31 31 32 32 $loader->register(true); -
clearpay-gateway-for-woocommerce/tags/3.6.1/vendor/composer/autoload_static.php
r2959052 r2972430 5 5 namespace Composer\Autoload; 6 6 7 class ComposerStaticInit 944fdff2186aa515758a109e6ee48d3e7 class ComposerStaticInit28353fa2aaa659c6a5bb5054fe0a7d25 8 8 { 9 9 public static $prefixLengthsPsr4 = array ( … … 28 28 { 29 29 return \Closure::bind(function () use ($loader) { 30 $loader->prefixLengthsPsr4 = ComposerStaticInit 944fdff2186aa515758a109e6ee48d3e::$prefixLengthsPsr4;31 $loader->prefixDirsPsr4 = ComposerStaticInit 944fdff2186aa515758a109e6ee48d3e::$prefixDirsPsr4;32 $loader->classMap = ComposerStaticInit 944fdff2186aa515758a109e6ee48d3e::$classMap;30 $loader->prefixLengthsPsr4 = ComposerStaticInit28353fa2aaa659c6a5bb5054fe0a7d25::$prefixLengthsPsr4; 31 $loader->prefixDirsPsr4 = ComposerStaticInit28353fa2aaa659c6a5bb5054fe0a7d25::$prefixDirsPsr4; 32 $loader->classMap = ComposerStaticInit28353fa2aaa659c6a5bb5054fe0a7d25::$classMap; 33 33 34 34 }, null, ClassLoader::class); -
clearpay-gateway-for-woocommerce/tags/3.6.1/vendor/composer/installed.php
r2959052 r2972430 4 4 'pretty_version' => 'dev-master', 5 5 'version' => 'dev-master', 6 'reference' => ' 3a7381e7096bf14d40a992c5a7e99aaadfae528d',6 'reference' => '6fb292f5312bd300225d794929165e2bf0fe4c72', 7 7 'type' => 'library', 8 8 'install_path' => __DIR__ . '/../../', … … 14 14 'pretty_version' => 'dev-master', 15 15 'version' => 'dev-master', 16 'reference' => ' 3a7381e7096bf14d40a992c5a7e99aaadfae528d',16 'reference' => '6fb292f5312bd300225d794929165e2bf0fe4c72', 17 17 'type' => 'library', 18 18 'install_path' => __DIR__ . '/../../', -
clearpay-gateway-for-woocommerce/trunk/class/WC_Gateway_Clearpay.php
r2959052 r2972430 2222 2222 // } 2223 2223 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 2224 2244 echo '<square-placement'; 2225 2245 foreach ($attributes as $key => $value) { … … 2228 2248 echo '></square-placement>'; 2229 2249 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); 2230 2321 } 2231 2322 -
clearpay-gateway-for-woocommerce/trunk/clearpay-gateway-for-woocommerce.php
r2959052 r2972430 5 5 * Author: Clearpay 6 6 * Author URI: https://www.clearpay.co.uk/ 7 * Version: 3.6. 07 * Version: 3.6.1 8 8 * Text Domain: woo_clearpay 9 9 * Domain Path: /languages/ 10 10 * WC requires at least: 3.2.6 11 * WC tested up to: 8. 0.211 * WC tested up to: 8.1.1 12 12 * 13 13 * Copyright: (c) 2021 Clearpay … … 47 47 * the value in the comments above. 48 48 */ 49 public static $version = '3.6. 0';49 public static $version = '3.6.1'; 50 50 51 51 /** -
clearpay-gateway-for-woocommerce/trunk/readme.txt
r2959052 r2972430 3 3 Tags: woocommerce, clearpay 4 4 Requires at least: 4.8.3 5 Tested up to: 6.3. 06 Stable tag: 3.6. 05 Tested up to: 6.3.1 6 Stable tag: 3.6.1 7 7 License: GNU Public License 8 8 License URI: https://www.gnu.org/licenses/ … … 40 40 == Changelog == 41 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. 47 42 48 = 3.6.0 = 43 49 *Release Date: Monday, 28 Aug 2023* -
clearpay-gateway-for-woocommerce/trunk/vendor/autoload.php
r2959052 r2972430 23 23 require_once __DIR__ . '/composer/autoload_real.php'; 24 24 25 return ComposerAutoloaderInit 944fdff2186aa515758a109e6ee48d3e::getLoader();25 return ComposerAutoloaderInit28353fa2aaa659c6a5bb5054fe0a7d25::getLoader(); -
clearpay-gateway-for-woocommerce/trunk/vendor/composer/autoload_real.php
r2959052 r2972430 3 3 // autoload_real.php @generated by Composer 4 4 5 class ComposerAutoloaderInit 944fdff2186aa515758a109e6ee48d3e5 class ComposerAutoloaderInit28353fa2aaa659c6a5bb5054fe0a7d25 6 6 { 7 7 private static $loader; … … 23 23 } 24 24 25 spl_autoload_register(array('ComposerAutoloaderInit 944fdff2186aa515758a109e6ee48d3e', 'loadClassLoader'), true, true);25 spl_autoload_register(array('ComposerAutoloaderInit28353fa2aaa659c6a5bb5054fe0a7d25', 'loadClassLoader'), true, true); 26 26 self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); 27 spl_autoload_unregister(array('ComposerAutoloaderInit 944fdff2186aa515758a109e6ee48d3e', 'loadClassLoader'));27 spl_autoload_unregister(array('ComposerAutoloaderInit28353fa2aaa659c6a5bb5054fe0a7d25', 'loadClassLoader')); 28 28 29 29 require __DIR__ . '/autoload_static.php'; 30 call_user_func(\Composer\Autoload\ComposerStaticInit 944fdff2186aa515758a109e6ee48d3e::getInitializer($loader));30 call_user_func(\Composer\Autoload\ComposerStaticInit28353fa2aaa659c6a5bb5054fe0a7d25::getInitializer($loader)); 31 31 32 32 $loader->register(true); -
clearpay-gateway-for-woocommerce/trunk/vendor/composer/autoload_static.php
r2959052 r2972430 5 5 namespace Composer\Autoload; 6 6 7 class ComposerStaticInit 944fdff2186aa515758a109e6ee48d3e7 class ComposerStaticInit28353fa2aaa659c6a5bb5054fe0a7d25 8 8 { 9 9 public static $prefixLengthsPsr4 = array ( … … 28 28 { 29 29 return \Closure::bind(function () use ($loader) { 30 $loader->prefixLengthsPsr4 = ComposerStaticInit 944fdff2186aa515758a109e6ee48d3e::$prefixLengthsPsr4;31 $loader->prefixDirsPsr4 = ComposerStaticInit 944fdff2186aa515758a109e6ee48d3e::$prefixDirsPsr4;32 $loader->classMap = ComposerStaticInit 944fdff2186aa515758a109e6ee48d3e::$classMap;30 $loader->prefixLengthsPsr4 = ComposerStaticInit28353fa2aaa659c6a5bb5054fe0a7d25::$prefixLengthsPsr4; 31 $loader->prefixDirsPsr4 = ComposerStaticInit28353fa2aaa659c6a5bb5054fe0a7d25::$prefixDirsPsr4; 32 $loader->classMap = ComposerStaticInit28353fa2aaa659c6a5bb5054fe0a7d25::$classMap; 33 33 34 34 }, null, ClassLoader::class); -
clearpay-gateway-for-woocommerce/trunk/vendor/composer/installed.php
r2959052 r2972430 4 4 'pretty_version' => 'dev-master', 5 5 'version' => 'dev-master', 6 'reference' => ' 3a7381e7096bf14d40a992c5a7e99aaadfae528d',6 'reference' => '6fb292f5312bd300225d794929165e2bf0fe4c72', 7 7 'type' => 'library', 8 8 'install_path' => __DIR__ . '/../../', … … 14 14 'pretty_version' => 'dev-master', 15 15 'version' => 'dev-master', 16 'reference' => ' 3a7381e7096bf14d40a992c5a7e99aaadfae528d',16 'reference' => '6fb292f5312bd300225d794929165e2bf0fe4c72', 17 17 'type' => 'library', 18 18 'install_path' => __DIR__ . '/../../',
Note: See TracChangeset
for help on using the changeset viewer.