Skip to content

Commit

Permalink
🔀 Merge branch 'trunk'
Browse files Browse the repository at this point in the history
# Conflicts:
#	modules/ppcp-settings/resources/js/Components/ReusableComponents/SelectBox.js
  • Loading branch information
stracker-phil committed Jan 23, 2025
2 parents 4015a8f + 449a4a3 commit 09ca3d0
Show file tree
Hide file tree
Showing 24 changed files with 342 additions and 173 deletions.
2 changes: 2 additions & 0 deletions bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* @package WooCommerce\PayPalCommerce
*/

namespace WooCommerce\PayPalCommerce;

use WooCommerce\PayPalCommerce\Vendor\Inpsyde\Modularity\Package;
use WooCommerce\PayPalCommerce\Vendor\Inpsyde\Modularity\Properties\PluginProperties;
use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface;
Expand Down
3 changes: 2 additions & 1 deletion modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
* @package WooCommerce\PayPalCommerce
*/

namespace WooCommerce\PayPalCommerce;

use WooCommerce\PayPalCommerce\PayLaterBlock\PayLaterBlockModule;
use WooCommerce\PayPalCommerce\PayLaterWCBlocks\PayLaterWCBlocksModule;
use WooCommerce\PayPalCommerce\PayLaterConfigurator\PayLaterConfiguratorModule;
use WooCommerce\PayPalCommerce\PluginModule;

return function ( string $root_dir ): iterable {
$modules_dir = "$root_dir/modules";
Expand Down
2 changes: 2 additions & 0 deletions modules/ppcp-compat/src/CompatModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ function() use ( $c ) {
$this->initialize_wc_bookings_compat_layer( $c );
}

add_action( 'woocommerce_paypal_payments_gateway_migrate', static fn() => delete_transient( 'ppcp_has_ppec_subscriptions' ) );

return true;
}

Expand Down
4 changes: 2 additions & 2 deletions modules/ppcp-compat/src/PPEC/PPECHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ public static function site_has_ppec_subscriptions() {
}

global $wpdb;
if ( class_exists( OrderUtil::class ) && OrderUtil::custom_orders_table_usage_is_enabled() && isset( $wpdb->wc_orders ) ) {
if ( class_exists( OrderUtil::class ) && OrderUtil::custom_orders_table_usage_is_enabled() ) {
$result = $wpdb->get_var(
$wpdb->prepare(
"SELECT 1 FROM {$wpdb->wc_orders} WHERE payment_method = %s",
"SELECT 1 FROM {$wpdb->prefix}wc_orders WHERE payment_method = %s",
self::PPEC_GATEWAY_ID
)
);
Expand Down
2 changes: 2 additions & 0 deletions modules/ppcp-paypal-subscriptions/src/RenewalHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public function __construct( LoggerInterface $logger ) {
public function process( array $subscriptions, string $transaction_id ): void {
foreach ( $subscriptions as $subscription ) {
if ( $this->is_for_renewal_order( $subscription ) ) {
$subscription->update_status( 'on-hold' );

$renewal_order = wcs_create_renewal_order( $subscription );
if ( is_a( $renewal_order, WC_Order::class ) ) {
$this->logger->info(
Expand Down
101 changes: 41 additions & 60 deletions modules/ppcp-save-payment-methods/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,75 +20,56 @@
$save_payment_methods_applies = $container->get( 'save-payment-methods.helpers.save-payment-methods-applies' );
assert( $save_payment_methods_applies instanceof SavePaymentMethodsApplies );

return $save_payment_methods_applies->for_country_currency();
return $save_payment_methods_applies->for_country();
},
'save-payment-methods.helpers.save-payment-methods-applies' => static function ( ContainerInterface $container ) : SavePaymentMethodsApplies {
return new SavePaymentMethodsApplies(
$container->get( 'save-payment-methods.supported-country-currency-matrix' ),
$container->get( 'api.shop.currency.getter' ),
$container->get( 'save-payment-methods.supported-countries' ),
$container->get( 'api.shop.country' )
);
},
'save-payment-methods.supported-country-currency-matrix' => static function ( ContainerInterface $container ) : array {
$default_currencies = array(
'AUD',
'BRL',
'CAD',
'CHF',
'CZK',
'DKK',
'EUR',
'GBP',
'HUF',
'ILS',
'JPY',
'MXN',
'NOK',
'NZD',
'PHP',
'PLN',
'SEK',
'THB',
'TWD',
'USD',
);
'save-payment-methods.supported-countries' => static function ( ContainerInterface $container ) : array {
if ( has_filter( 'woocommerce_paypal_payments_save_payment_methods_supported_country_currency_matrix' ) ) {
_deprecated_hook( 'woocommerce_paypal_payments_save_payment_methods_supported_country_currency_matrix', '3.0.0', 'woocommerce_paypal_payments_save_payment_methods_supported_countries', esc_attr__( 'Please use the new Hook to filter countries for saved payments in PayPal Payments.', 'woocommerce-paypal-payments' ) );
}

return apply_filters(
'woocommerce_paypal_payments_save_payment_methods_supported_country_currency_matrix',
'woocommerce_paypal_payments_save_payment_methods_supported_countries',
array(
'AU' => $default_currencies,
'AT' => $default_currencies,
'BE' => $default_currencies,
'BG' => $default_currencies,
'CA' => $default_currencies,
'CN' => $default_currencies,
'CY' => $default_currencies,
'CZ' => $default_currencies,
'DK' => $default_currencies,
'EE' => $default_currencies,
'FI' => $default_currencies,
'FR' => $default_currencies,
'DE' => $default_currencies,
'GR' => $default_currencies,
'HU' => $default_currencies,
'IE' => $default_currencies,
'IT' => $default_currencies,
'LV' => $default_currencies,
'LI' => $default_currencies,
'LT' => $default_currencies,
'LU' => $default_currencies,
'MT' => $default_currencies,
'NO' => $default_currencies,
'NL' => $default_currencies,
'PL' => $default_currencies,
'PT' => $default_currencies,
'RO' => $default_currencies,
'SK' => $default_currencies,
'SI' => $default_currencies,
'ES' => $default_currencies,
'SE' => $default_currencies,
'GB' => $default_currencies,
'US' => $default_currencies,
'AU',
'AT',
'BE',
'BG',
'CA',
'CN',
'CY',
'CZ',
'DK',
'EE',
'FI',
'FR',
'DE',
'HK',
'HU',
'IE',
'IT',
'LV',
'LI',
'LT',
'LU',
'MT',
'NO',
'NL',
'PL',
'PT',
'RO',
'SG',
'SK',
'SI',
'ES',
'SE',
'GB',
'US',
)
);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,60 +9,46 @@

namespace WooCommerce\PayPalCommerce\SavePaymentMethods\Helper;

use WooCommerce\PayPalCommerce\ApiClient\Helper\CurrencyGetter;

/**
* Class SavePaymentMethodsApplies
*/
class SavePaymentMethodsApplies {

/**
* The matrix which countries and currency combinations can be used for Save Payment Methods.
* The countries can be used for Save Payment Methods.
*
* @var array
*/
private $allowed_country_currency_matrix;

/**
* The getter of the 3-letter currency code of the shop.
*
* @var CurrencyGetter
*/
private CurrencyGetter $currency;
private array $allowed_countries;

/**
* 2-letter country code of the shop.
*
* @var string
*/
private $country;
private string $country;

/**
* SavePaymentMethodsApplies constructor.
*
* @param array $allowed_country_currency_matrix The matrix which countries and currency combinations can be used for Save Payment Methods.
* @param CurrencyGetter $currency The getter of the 3-letter currency code of the shop.
* @param string $country 2-letter country code of the shop.
* @param array $allowed_countries The matrix which countries and currency combinations can be used for Save Payment Methods.
* @param string $country 2-letter country code of the shop.
*/
public function __construct(
array $allowed_country_currency_matrix,
CurrencyGetter $currency,
array $allowed_countries,
string $country
) {
$this->allowed_country_currency_matrix = $allowed_country_currency_matrix;
$this->currency = $currency;
$this->country = $country;
$this->allowed_countries = $allowed_countries;
$this->country = $country;
}

/**
* Returns whether Save Payment Methods can be used in the current country and the current currency used.
*
* @return bool
*/
public function for_country_currency(): bool {
if ( ! in_array( $this->country, array_keys( $this->allowed_country_currency_matrix ), true ) ) {
return false;
}
return in_array( $this->currency->get(), $this->allowed_country_currency_matrix[ $this->country ], true );
public function for_country(): bool {

return in_array( $this->country, $this->allowed_countries, true );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
border: 1px solid var(--color-separators);
border-radius: 8px;
overflow: hidden;
font-family: "PayPalPro", sans-serif;
-webkit-font-smoothing: antialiased;

.css-1snxoyf.eolpigi0 {
margin: 0;
Expand Down Expand Up @@ -46,44 +48,66 @@
}

&__subheader, #configurator-controlPanelSubHeader {
@include font(13, 20, 400);
color: $color-gray-800;
color: var(--color-text-description);
margin: 0 0 18px 0;
}

.css-1caaugt-links_base-text_body_strong, .css-dpyjrq-text_body {
@include font(13, 20, 400);
}

&__header, #configurator-controlPanelHeader, #configurator-previewSectionSubHeaderText.css-14ujlqd-text_body, .css-16jt5za-text_body {
@include font(14, 20, 600);
color: $color-gray-800;
margin: 0 0 8px 0;
display: block;
@include font(16, 20, 600);
color: var(--color-text-title);
margin-bottom: 6px;
font-family: "PayPalPro", sans-serif;
-webkit-font-smoothing: antialiased;
}

.css-1yo2lxy-text_body_strong {
@include font(13, 16, 600);
color: $color-black;
color: var(--color-text-description);
margin: 0;
text-transform: none;
}

.css-rok10q {
.css-rok10q, .css-dfgbdq-text_body_strong {
margin-top: 0;
}

&__publish-button {
display: none;
}

.css-1oxdnb3-dropdown_menu_button-text_field_value_sm-active, .css-1wvwydd-dropdown_menu_button-text_field_value_sm-active-active, .css-16jt5za-text_body {
font-size: 13px;
line-height: 1.5384615385;
font-weight: 400;
}

.css-udzaps {
padding: 0px;
}

.css-104jwuk,
.css-dpyjrq-text_body,
.css-1oxdnb3-dropdown_menu_button-text_field_value_sm-active,
.css-1wvwydd-dropdown_menu_button-text_field_value_sm-active-active,
.css-16jt5za-text_body,
.css-1caaugt-links_base-text_body_strong,
.css-dpyjrq-text_body,
&__subheader,
#configurator-controlPanelSubHeader,
.css-1yo2lxy-text_body_strong{
@include font(13, 20, 400);
font-family: "PayPalPro", sans-serif;
-webkit-font-smoothing: antialiased;
}

.css-1k9r7mv-text_body, .css-ra9ecy-text_body_strong {
font-family: "PayPalPro", sans-serif;
-webkit-font-smoothing: antialiased;
}

.css-1hs85tj {
display: none;
}

.css-4nclxm.e1vy3g880, {
width: 100%;
padding: 48px 8px;

.css-11hsg2u.e1vy3g880 {
width: 100%;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,31 @@ const SelectableContent = ( {
);
};

const handleClick = () => {
if ( type === 'checkbox' ) {
let newValue;

if ( Array.isArray( currentValue ) ) {
if ( currentValue.includes( value ) ) {
newValue = currentValue.filter(
( optionValue ) => optionValue !== value
);
} else {
newValue = [ ...currentValue, value ];
}
} else {
newValue = ! currentValue;
}

changeCallback( newValue );
}
};

return (
<div className={ boxClassName }>
<div
className={ boxClassName }
onClick={ type === 'checkbox' ? handleClick : undefined }
>
<InputField isRadio={ type === 'radio' } />

<div className="ppcp-r-select-box__content">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ const ALL_STEPS = [
id: 'methods',
title: __( 'Choose checkout options', 'woocommerce-paypal-payments' ),
StepComponent: StepPaymentMethods,
canProceed: () => true,
canProceed: ( { methods } ) =>
methods.areOptionalPaymentMethodsEnabled !== null,
},
{
id: 'complete',
Expand Down
2 changes: 2 additions & 0 deletions modules/ppcp-settings/resources/js/data/onboarding/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,12 @@ export const useSteps = () => {
export const useNavigationState = () => {
const products = useProducts();
const business = useBusiness();
const methods = useOptionalPaymentMethods();

return {
products,
business,
methods,
};
};

Expand Down
Loading

0 comments on commit 09ca3d0

Please sign in to comment.