Skip to content

Commit 05a9dc6

Browse files
Release v4.0.2
* Beta support for Checkout Block.
2 parents d315984 + 8a72368 commit 05a9dc6

File tree

14 files changed

+313
-206
lines changed

14 files changed

+313
-206
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
/node_modules/
12
/svn/
23
/vendor/
34
aplazame.latest.zip
45
composer.lock
56
docker-compose.override.yml
7+
package-lock.json

HISTORY.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
## Change Log
22

3+
#### [v4.0.2](https://github.com/aplazame/woocommerce/tree/v4.0.2) (2024-05-30)
4+
5+
* Beta support for Checkout Block.
6+
37
#### [v4.0.1](https://github.com/aplazame/woocommerce/tree/v4.0.1) (2024-03-05)
48

59
* Order confirmation process improved.

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
plugin_path ?= plugin
22
i18n_path ?= i18n/languages
33
i18n_name ?= aplazame-es_ES
4-
version ?= v4.0.1
4+
version ?= v4.0.2
55
errors = $(shell find . -type f -name "*.php" -exec php -l "{}" \;| grep "Errors parsing ";)
66

77
clean:

package.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"devDependencies": {
3+
"@wordpress/scripts": "^27.9.0"
4+
},
5+
"scripts": {
6+
"build": "wp-scripts build --webpack-src-dir=resources --output-path=plugin/resources",
7+
"start": "wp-scripts start --webpack-src-dir=resources --output-path=plugin/resources"
8+
}
9+
}

plugin/README.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
Contributors: aplazame
33
Tags: aplazame,woocommerce,ecommerce,payment,checkout,credit,aplazar,financiar,financiera,financiación,pago aplazado,método de pago
44
Requires at least: 4.0.1
5-
Tested up to: 6.4.3
5+
Tested up to: 6.5.3
66
Requires PHP: 5.3.0
7-
Stable tag: 4.0.1
7+
Stable tag: 4.0.2
88
License: BSD-3-Clause
99
License URI: https://github.com/aplazame/woocommerce/blob/master/LICENSE
1010

plugin/aplazame.php

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/*
33
* Plugin Name: Aplazame
44
* Plugin URI: https://github.com/aplazame/woocommerce
5-
* Version: 4.0.1
5+
* Version: 4.0.2
66
* Description: Aplazame offers a payment method to receive funding for the purchases.
77
* Author: Aplazame
88
* Author URI: https://aplazame.com
@@ -11,7 +11,7 @@
1111
* Domain Path: /i18n/languages/
1212
*
1313
* WC requires at least: 3.0.0
14-
* WC tested up to: 8.6.1
14+
* WC tested up to: 8.9.1
1515
*
1616
* License: GNU General Public License v3.0
1717
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
@@ -25,7 +25,7 @@
2525
require_once 'lib/Aplazame/Aplazame/autoload.php';
2626

2727
class WC_Aplazame {
28-
const VERSION = '4.0.1';
28+
const VERSION = '4.0.2';
2929
const METHOD_ID = 'aplazame';
3030
const METHOD_TITLE = 'Aplazame';
3131

@@ -164,11 +164,22 @@ public function __construct( $apiBaseUri ) {
164164

165165
add_action( 'woocommerce_api_aplazame', array( $this, 'api_router' ) );
166166

167+
// Cart and Checkout Blocks
168+
add_action( 'woocommerce_blocks_loaded', array( $this, 'add_gateway_block' ) );
169+
add_action(
170+
'before_woocommerce_init',
171+
function () {
172+
if ( class_exists( '\Automattic\WooCommerce\Utilities\FeaturesUtil' ) ) {
173+
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'cart_checkout_blocks', __FILE__, true );
174+
}
175+
}
176+
);
177+
167178
// Declare HPOS compatibility
168179
add_action(
169180
'before_woocommerce_init',
170181
function () {
171-
if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
182+
if ( class_exists( '\Automattic\WooCommerce\Utilities\FeaturesUtil' ) ) {
172183
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true );
173184
}
174185
}
@@ -276,6 +287,20 @@ public function add_gateway( $methods ) {
276287
return $methods;
277288
}
278289

290+
public function add_gateway_block() {
291+
if ( ! class_exists( 'Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType' ) ) {
292+
return;
293+
}
294+
295+
include_once 'classes/wc-aplazame-gateway-block.php';
296+
add_action(
297+
'woocommerce_blocks_payment_method_type_registration',
298+
function ( Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry ) {
299+
$payment_method_registry->register( new WC_Aplazame_Gateway_Blocks_Support() );
300+
}
301+
);
302+
}
303+
279304
public function aplazameJs() {
280305

281306
Aplazame_Helpers::render_to_template( 'layout/header.php' );
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
if ( ! defined( 'ABSPATH' ) ) {
4+
exit;
5+
}
6+
7+
use Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType;
8+
9+
final class WC_Aplazame_Gateway_Blocks_Support extends AbstractPaymentMethodType {
10+
private $gateway;
11+
protected $name = WC_Aplazame::METHOD_ID;
12+
13+
public function initialize() {
14+
$this->settings = get_option( "woocommerce_{$this->name}_settings", array() );
15+
$gateways = WC()->payment_gateways->payment_gateways();
16+
$this->gateway = $gateways[ $this->name ];
17+
}
18+
19+
public function is_active() {
20+
return $this->gateway->is_available();
21+
}
22+
23+
public function get_payment_method_script_handles() {
24+
$asset_path = plugin_dir_path( __FILE__ ) . '../resources/payment-block.asset.php';
25+
$version = null;
26+
$dependencies = array();
27+
if ( file_exists( $asset_path ) ) {
28+
$asset = require $asset_path;
29+
$version = isset( $asset['version'] ) ? $asset['version'] : $version;
30+
$dependencies = isset( $asset['dependencies'] ) ? $asset['dependencies'] : $dependencies;
31+
}
32+
wp_register_script(
33+
'wc-aplazame-blocks-integration',
34+
plugin_dir_url( __FILE__ ) . '../resources/payment-block.js',
35+
$dependencies,
36+
$version,
37+
true
38+
);
39+
return array( 'wc-aplazame-blocks-integration' );
40+
}
41+
42+
public function get_payment_method_data() {
43+
return array(
44+
'title' => $this->gateway->title,
45+
'description' => $this->gateway->settings['description'],
46+
);
47+
}
48+
}

0 commit comments

Comments
 (0)