Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release v5.11.0 #327

Merged
merged 11 commits into from
Feb 18, 2025
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Changelog

## v5.11.0 - 2025-02-18

### Changes

### 🚀 New Features

- Add payment method position to the gather cms data and fix typeError for display in page (#326)

#### Contributors

@joyet-simon and [alma-create-pr-with-team-review[bot]](https://github.com/apps/alma-create-pr-with-team-review)

## v5.10.0 - 2025-02-11

### Changes
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
- Tested up to Wordpress: 6.6.1
- Tested up to Woocommerce: 9.2.3
- Requires PHP: 5.6
- Stable tag: 5.10.0
- Stable tag: 5.11.0
- License: GPLv3
- License URI: https://www.gnu.org/licenses/gpl-3.0.html
- Support: [email protected]
Expand Down
4 changes: 2 additions & 2 deletions alma-gateway-for-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Alma - Pay in installments or later for WooCommerce
* Plugin URI: https://docs.almapay.com/docs/woocommerce
* Description: Install Alma and boost your sales! It's simple and guaranteed, your cash flow is secured. 0 commitment, 0 subscription, 0 risk.
* Version: 5.10.0
* Version: 5.11.0
* Author: Alma
* Author URI: https://almapay.com
* License: GNU General Public License v3.0
Expand Down Expand Up @@ -40,7 +40,7 @@
}

if ( ! defined( 'ALMA_VERSION' ) ) {
define( 'ALMA_VERSION', '5.10.0' );
define( 'ALMA_VERSION', '5.11.0' );
}
if ( ! defined( 'ALMA_PLUGIN_FILE' ) ) {
define( 'ALMA_PLUGIN_FILE', __FILE__ );
Expand Down
4 changes: 2 additions & 2 deletions includes/AlmaSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ class AlmaSettings {
public $display_cart_eligibility;

/**
* Bool if In Page is activated.
* In Page is activated ("yes" or "no").
*
* @var bool
* @var string
*/
public $display_in_page;

Expand Down
33 changes: 32 additions & 1 deletion includes/Services/CollectCmsDataService.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use Alma\Woocommerce\Helpers\ToolsHelper;
use Alma\Woocommerce\WcProxy\FunctionsProxy;
use Alma\Woocommerce\WcProxy\OptionProxy;
use Alma\Woocommerce\WcProxy\PaymentGatewaysProxy;
use Alma\Woocommerce\WcProxy\ThemeProxy;

/**
Expand Down Expand Up @@ -180,13 +181,14 @@ private function get_cms_features() {
'widget_cart_activated' => 'yes' === $this->alma_settings->display_cart_eligibility,
'widget_product_activated' => 'yes' === $this->alma_settings->display_product_eligibility,
'used_fee_plans' => $this->format_fee_plans(),
'in_page_activated' => $this->alma_settings->display_in_page,
'in_page_activated' => 'yes' === $this->alma_settings->display_in_page,
'log_activated' => 'yes' === $this->alma_settings->debug,
'excluded_categories' => $this->alma_settings->excluded_products_list,
'is_multisite' => is_multisite(),
'specific_features' => array(
( in_array( 'alma-woocommerce-gateway/alma-gateway-for-woocommerce.php', $auto_update_plugins, true ) ) ? 'auto_update' : null,
),
'payment_method_position' => $this->get_alma_gateway_position(),
)
);
}
Expand Down Expand Up @@ -255,4 +257,33 @@ private function format_fee_plans() {
return $plans;
}

/**
* Get Alma gateway position.
* Remove alma_* gateways from the list of gateways.
* Sort gateways to re-index all.
*
* @return int
*/
private function get_alma_gateway_position() {
$gateways = PaymentGatewaysProxy::get_instance()->get_payment_gateways();
$gateway_position = 0;

$gateways = array_filter(
$gateways,
function( $gateway) {
return ! preg_match( '/alma_.+/', $gateway->id );
}
);

$gateways = array_values( $gateways );

foreach ( $gateways as $position => $gateway ) {
if ( 'alma' === $gateway->id ) {
$gateway_position = $position + 1;
}
}

return $gateway_position;
}

}
64 changes: 64 additions & 0 deletions includes/WcProxy/PaymentGatewaysProxy.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php
/**
* Payment gateways proxy.
*
* @package Alma\Woocommerce\WcProxy
*/
namespace Alma\Woocommerce\WcProxy;

use WC_Payment_Gateways;

class PaymentGatewaysProxy {

/**
* @var PaymentGatewaysProxy|null
*/
private static $instance = null;

/**
* @var WC_Payment_Gateways
*/
private $wc_payment_gateway;

/**
* PaymentGatewaysProxy constructor.
*
* @param WC_Payment_Gateways|null $wc_payment_gateway
*/
private function __construct( $wc_payment_gateway = null) {
$this->wc_payment_gateway = $wc_payment_gateway ? $wc_payment_gateway : WC_Payment_Gateways::instance();
}

/**
* Get the singleton instance of PaymentGatewaysProxy.
*
* @param WC_Payment_Gateways|null $wc_payment_gateway
* @return PaymentGatewaysProxy
*/
public static function get_instance( $wc_payment_gateway = null) {
if (null === self::$instance) {
self::$instance = new self( $wc_payment_gateway );
}

return self::$instance;
}

/**
* Get payment gateways.
*
* @return array
*/
public function get_payment_gateways() {
return $this->wc_payment_gateway->payment_gateways();
}

/**
* Used for unit tests.
*
* @return void
*/
public static function reset_instance() {
self::$instance = null;
}

}
14 changes: 13 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Tags: payments, BNPL, woocommerce, ecommerce, e-commerce, payment gateway, sell,
Requires at least: 4.4
Tested up to: 6.3
Requires PHP: 5.6
Stable tag: 5.10.0
Stable tag: 5.11.0
License: GPLv3
License URI: https://www.gnu.org/licenses/gpl-3.0.html

Expand Down Expand Up @@ -51,6 +51,18 @@ You can find more documentation on our [website](https://docs.almapay.com/docs/w

== Changelog ==

## v5.11.0 - 2025-02-18

### Changes

### 🚀 New Features

- Add payment method position to the gather cms data and fix typeError for display in page (#326)

#### Contributors

@joyet-simon and [alma-create-pr-with-team-review[bot]](https://github.com/apps/alma-create-pr-with-team-review)

## v5.10.0 - 2025-02-11

### Changes
Expand Down
Loading
Loading