Skip to content

Commit bec9e2c

Browse files
Release 3.3.14
1 parent 73da81f commit bec9e2c

24 files changed

+351
-105
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ This repository contains the PostFinance Checkout plugin that enables WooCommerc
1414

1515
## Documentation
1616

17-
* [Documentation](https://plugin-documentation.postfinance-checkout.ch/pfpayments/woocommerce/3.3.13/docs/en/documentation.html)
17+
* [Documentation](https://plugin-documentation.postfinance-checkout.ch/pfpayments/woocommerce/3.3.14/docs/en/documentation.html)
1818

1919
## Support
2020

@@ -25,13 +25,13 @@ Support queries can be issued on the [PostFinance Checkout support site](https:/
2525
____________________________________________________________________________
2626
| WooCommerce version | Plugin major version | Supported until |
2727
|------------------------|------------------------|------------------------|
28-
| 8.x, 9.x | 3.x | Further notice |
28+
| 8.x, 9.x, 10.x | 3.x | Further notice |
2929
| 7.x | 2.x | Feb 2024 |
3030
----------------------------------------------------------------------------
3131

3232
## License
3333

34-
Please see the [license file](https://github.com/pfpayments/woocommerce/blob/3.3.13/LICENSE) for more information.
34+
Please see the [license file](https://github.com/pfpayments/woocommerce/blob/3.3.14/LICENSE) for more information.
3535

3636
## Privacy Policy
3737

changelog.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -962,3 +962,16 @@ Please ensure that in woocommerce->settings->tax, the "Round tax at subtotal lev
962962
- [Tested Against] Woocommerce 9.9.5
963963
- [Tested Against] PHP SDK 4.8.0
964964

965+
= 3.3.14 - July 22nd 2025 =
966+
- [Bugfix] Fix class loading order issues
967+
- [Bugfix] Fix problem with multisite not installing tables when plugin is network activated
968+
- [Bugfix] Fix missing payment methods if subscription price is 0
969+
- [Bugfix] Fix for failed subscriptions renewals if subscription contains a discount
970+
- [Bugfix] Fix for iframe payment fields not loading on delivery method change
971+
- [Feature] Added plugin version metric
972+
- [Feature] Send order notes to portal
973+
- [Tested Against] PHP 8.2
974+
- [Tested Against] Wordpress 6.7
975+
- [Tested Against] Woocommerce 10.0.0
976+
- [Tested Against] PHP SDK 4.8.0
977+

docs/en/documentation.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ <h2>Documentation</h2> </div>
2323
</a>
2424
</li>
2525
<li>
26-
<a href="https://github.com/pfpayments/woocommerce/releases/tag/3.3.13/">
26+
<a href="https://github.com/pfpayments/woocommerce/releases/tag/3.3.14/">
2727
Source
2828
</a>
2929
</li>

includes/admin/class-wc-postfinancecheckout-admin-settings-page.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ public function get_default_settings() {
205205
$settings = array(
206206
array(
207207
'links' => array(
208-
'https://plugin-documentation.postfinance-checkout.ch/pfpayments/woocommerce/3.3.13/docs/en/documentation.html' => esc_html__( 'Documentation', 'woo-postfinancecheckout' ),
208+
'https://plugin-documentation.postfinance-checkout.ch/pfpayments/woocommerce/3.3.14/docs/en/documentation.html' => esc_html__( 'Documentation', 'woo-postfinancecheckout' ),
209209
'https://checkout.postfinance.ch/en-ch/user/signup' => esc_html__( 'Sign Up', 'woo-postfinancecheckout' ),
210210
),
211211
'type' => 'postfinancecheckout_links',
@@ -408,6 +408,25 @@ public function get_default_settings() {
408408
'id' => 'reference_options',
409409
),
410410

411+
array(
412+
'title' => esc_html__( 'Virtual Order Status Options', 'woo-postfinancecheckout' ),
413+
'type' => 'title',
414+
'id' => 'order_status_options',
415+
),
416+
417+
array(
418+
'title' => esc_html__( 'Change Virtual Order Status On Completion', 'woo-postfinancecheckout' ),
419+
'desc' => esc_html__( 'Enable this setting to automatically set order\'s status to "Completed" when they consist entirely out of virtual products and order\'s total is 0.', 'woo-postfinancecheckout' ),
420+
'id' => WooCommerce_PostFinanceCheckout::POSTFINANCECHECKOUT_CK_CHANGE_ORDER_STATUS,
421+
'type' => 'checkbox',
422+
'default' => 'yes',
423+
'css' => 'min-width:300px;',
424+
),
425+
426+
array(
427+
'type' => 'sectionend',
428+
'id' => 'order_status_options',
429+
),
411430
);
412431

413432
return apply_filters( 'postfinancecheckout_settings', $settings );

includes/class-wc-postfinancecheckout-blocks-support.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function is_active() {
5757
*/
5858
public function get_payment_method_script_handles() {
5959
$dependencies = array();
60-
$version = '3.3.13';
60+
$version = '3.3.14';
6161

6262
wp_register_script(
6363
'WooCommerce_PostFinanceCheckout_blocks_support',

includes/class-wc-postfinancecheckout-gateway.php

Lines changed: 67 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ public function __construct( WC_PostFinanceCheckout_Entity_Method_Configuration
140140
)
141141
);
142142

143+
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_checkout_scripts' ) );
144+
143145
$this->supports = array(
144146
'products',
145147
'refunds',
@@ -433,7 +435,7 @@ protected function get_safe_possible_payment_methods_for_cart() {
433435
WooCommerce_PostFinanceCheckout::instance()->log( $e->getMessage(), WC_Log_Levels::DEBUG );
434436
}
435437

436-
return false;
438+
return array();
437439
}
438440

439441
/**
@@ -473,7 +475,6 @@ public function payment_fields() {
473475

474476
parent::payment_fields();
475477
$transaction_service = WC_PostFinanceCheckout_Service_Transaction::instance();
476-
$woocommerce_data = get_plugin_data( WP_PLUGIN_DIR . '/woocommerce/woocommerce.php', false, false );
477478
try {
478479
if ( apply_filters( 'wc_postfinancecheckout_is_order_pay_endpoint', is_checkout_pay_page() ) ) { //phpcs:ignore
479480
global $wp;
@@ -485,49 +486,6 @@ public function payment_fields() {
485486
} else {
486487
$transaction = $transaction_service->get_transaction_from_session();
487488
}
488-
if ( ! wp_script_is( 'postfinancecheckout-remote-checkout-js', 'enqueued' ) ) {
489-
$ajax_url = $transaction_service->get_javascript_url_for_transaction( $transaction );
490-
// !isset($wp->query_vars['order-pay'])->If you're not in the "re-pay" checkout.
491-
if (
492-
( get_option( WooCommerce_PostFinanceCheckout::POSTFINANCECHECKOUT_CK_INTEGRATION ) == WC_PostFinanceCheckout_Integration::POSTFINANCECHECKOUT_LIGHTBOX )
493-
&& ( is_checkout()
494-
&& ! isset( $wp->query_vars['order-pay'] ) )
495-
) {
496-
$ajax_url = $transaction_service->get_lightbox_url_for_transaction( $transaction );
497-
}
498-
wp_enqueue_script(
499-
'postfinancecheckout-remote-checkout-js',
500-
$ajax_url,
501-
array(
502-
'jquery',
503-
),
504-
1,
505-
true
506-
);
507-
wp_enqueue_script(
508-
'postfinancecheckout-checkout-js',
509-
WooCommerce_PostFinanceCheckout::instance()->plugin_url() . '/assets/js/frontend/checkout.js',
510-
array(
511-
'jquery',
512-
'jquery-blockui',
513-
'postfinancecheckout-remote-checkout-js',
514-
),
515-
1,
516-
true
517-
);
518-
global $wp_version;
519-
$localize = array(
520-
'i18n_not_complete' => esc_html__( 'Please fill out all required fields.', 'woo-postfinancecheckout' ),
521-
'integration' => get_option( WooCommerce_PostFinanceCheckout::POSTFINANCECHECKOUT_CK_INTEGRATION ),
522-
'versions' => array(
523-
'wordpress' => $wp_version,
524-
'woocommerce' => $woocommerce_data['Version'],
525-
'postfinancecheckout' => WC_POSTFINANCECHECKOUT_VERSION,
526-
),
527-
);
528-
wp_localize_script( 'postfinancecheckout-checkout-js', 'postfinancecheckout_js_params', $localize );
529-
530-
}
531489
$transaction_nonce = hash_hmac( 'sha256', $transaction->getLinkedSpaceId() . '-' . $transaction->getId(), NONCE_KEY );
532490

533491
?>
@@ -550,6 +508,70 @@ class="postfinancecheckout-method-configuration" style="display: none;"
550508
}
551509
}
552510

511+
public function enqueue_checkout_scripts() {
512+
513+
$transaction_service = WC_PostFinanceCheckout_Service_Transaction::instance();
514+
$woocommerce_data = get_plugin_data( WP_PLUGIN_DIR . '/woocommerce/woocommerce.php', false, false );
515+
if ( apply_filters( 'wc_postfinancecheckout_is_order_pay_endpoint', is_checkout_pay_page() ) ) { //phpcs:ignore
516+
global $wp;
517+
$order = WC_Order_Factory::get_order( $wp->query_vars['order-pay'] );
518+
if ( ! $order ) {
519+
return false;
520+
}
521+
$transaction = $transaction_service->get_transaction_from_order( $order );
522+
} else {
523+
$transaction = $transaction_service->get_transaction_from_session();
524+
}
525+
if ( ! wp_script_is( 'postfinancecheckout-remote-checkout-js', 'enqueued' ) ) {
526+
$ajax_url = $transaction_service->get_javascript_url_for_transaction( $transaction );
527+
// !isset($wp->query_vars['order-pay'])->If you're not in the "re-pay" checkout.
528+
if (
529+
( get_option( WooCommerce_PostFinanceCheckout::POSTFINANCECHECKOUT_CK_INTEGRATION ) == WC_PostFinanceCheckout_Integration::POSTFINANCECHECKOUT_LIGHTBOX )
530+
&& ( is_checkout()
531+
&& ! isset( $wp->query_vars['order-pay'] ) )
532+
) {
533+
$ajax_url = $transaction_service->get_lightbox_url_for_transaction( $transaction );
534+
}
535+
536+
if (get_option( WooCommerce_PostFinanceCheckout::POSTFINANCECHECKOUT_CK_INTEGRATION ) == WC_PostFinanceCheckout_Integration::POSTFINANCECHECKOUT_PAYMENTPAGE) {
537+
return false;
538+
}
539+
540+
wp_enqueue_script(
541+
'postfinancecheckout-remote-checkout-js',
542+
$ajax_url,
543+
array(
544+
'jquery',
545+
),
546+
1,
547+
true
548+
);
549+
wp_enqueue_script(
550+
'postfinancecheckout-checkout-js',
551+
WooCommerce_PostFinanceCheckout::instance()->plugin_url() . '/assets/js/frontend/checkout.js',
552+
array(
553+
'jquery',
554+
'jquery-blockui',
555+
'postfinancecheckout-remote-checkout-js',
556+
),
557+
1,
558+
true
559+
);
560+
global $wp_version;
561+
$localize = array(
562+
'i18n_not_complete' => esc_html__( 'Please fill out all required fields.', 'woo-postfinancecheckout' ),
563+
'integration' => get_option( WooCommerce_PostFinanceCheckout::POSTFINANCECHECKOUT_CK_INTEGRATION ),
564+
'versions' => array(
565+
'wordpress' => $wp_version,
566+
'woocommerce' => $woocommerce_data['Version'],
567+
'postfinancecheckout' => WC_POSTFINANCECHECKOUT_VERSION,
568+
),
569+
);
570+
wp_localize_script( 'postfinancecheckout-checkout-js', 'postfinancecheckout_js_params', $localize );
571+
572+
}
573+
}
574+
553575
/**
554576
* Validate frontend fields.
555577
*

includes/class-wc-postfinancecheckout-helper.php

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class WC_PostFinanceCheckout_Helper {
2727
const POSTFINANCECHECKOUT_CHECKOUT_VERSION = 'x-checkout-type';
2828
const POSTFINANCECHECKOUT_CHECKOUT_TYPE_BLOCKS = 'blocks';
2929
const POSTFINANCECHECKOUT_CHECKOUT_TYPE_LEGACY = 'legacy';
30+
const POSTFINANCECHECKOUT_PLUGIN_VERSION = 'x-meta-plugin-version';
3031

3132
/**
3233
* Instance.
@@ -236,9 +237,14 @@ public function get_total_amount_including_tax( array $line_items, bool $exclude
236237
* @return \PostFinanceCheckout\Sdk\Model\LineItemCreate[]
237238
* @throws WC_PostFinanceCheckout_Exception_Invalid_Transaction_Amount WC_PostFinanceCheckout_Exception_Invalid_Transaction_Amount.
238239
*/
239-
public function cleanup_line_items( array $line_items, $expected_sum, $currency ) {
240+
public function cleanup_line_items( array $line_items, $expected_sum, $currency, bool $is_recurrent = false ) {
241+
// Check if coupon is applied to order depending whether new order is created from session, or existing order.
242+
if ( $is_recurrent ) {
243+
$has_coupons = apply_filters( 'wc_postfinancecheckout_packages_coupon_line_items_have_coupon_discounts', $line_items, $currency );
244+
} else {
245+
$has_coupons = apply_filters( 'wc_postfinancecheckout_packages_coupon_cart_has_coupon_discounts_applied', $currency ); //phpcs:ignore
246+
}
240247
// ensure that the effective sum coincides with the total discounted by the coupons.
241-
$has_coupons = apply_filters( 'wc_postfinancecheckout_packages_coupon_has_coupon_discounts_applied', $currency ); //phpcs:ignore
242248
$effective_sum = $this->round_amount( $this->get_total_amount_including_tax( $line_items, $has_coupons ), $currency );
243249
$rounded_expected_sum = $this->round_amount( $expected_sum, $currency );
244250

@@ -571,11 +577,13 @@ protected static function get_default_header_data() {
571577
$version = WC_VERSION;
572578

573579
$shop_version = str_replace( 'v', '', $version );
580+
$plugin_version = '3.3.14';
574581
list ($major_version, $minor_version) = explode( '.', $shop_version, 3 );
575582
return array(
576583
self::POSTFINANCECHECKOUT_SHOP_SYSTEM => 'woocommerce',
577584
self::POSTFINANCECHECKOUT_SHOP_SYSTEM_VERSION => $shop_version,
578585
self::POSTFINANCECHECKOUT_SHOP_SYSTEM_AND_VERSION => 'woocommerce-' . $major_version . '.' . $minor_version,
586+
self::POSTFINANCECHECKOUT_PLUGIN_VERSION => $plugin_version,
579587
);
580588
}
581589

@@ -624,20 +632,33 @@ public function get_woocommerce_order_statuses_json() {
624632
* @param $order
625633
* @return void
626634
*/
627-
public static function set_virtual_orders_to_complete( $order ) {
635+
public static function set_virtual_zero_total_orders_to_complete( $order ) {
636+
if ( 'yes' === get_option( WooCommerce_PostFinanceCheckout::POSTFINANCECHECKOUT_CK_CHANGE_ORDER_STATUS )
637+
&& $order->get_total() <= 0 && self::is_order_virtual( $order ) ) {
638+
$order->update_status( 'completed' );
639+
}
640+
}
641+
642+
/**
643+
* @param $order
644+
* @return bool
645+
*/
646+
public static function is_order_virtual( $order ) {
647+
if ( ! $order instanceof WC_Order ) {
648+
$order = wc_get_order( $order );
649+
}
650+
651+
if ( ! $order ) {
652+
return false;
653+
}
628654

629-
$only_virtual = true;
630655
foreach ( $order->get_items() as $item ) {
631656
$product = $item->get_product();
632657
if ( ! $product || ! $product->is_virtual() ) {
633-
$only_virtual = false;
634-
break;
658+
return false;
635659
}
636660
}
637-
638-
if ( $only_virtual ) {
639-
$order->update_status( 'completed' );
640-
}
661+
return true;
641662
}
642663

643664
/**

includes/class-wc-postfinancecheckout-migration.php

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,13 @@ public static function init() {
6969
5
7070
);
7171
add_action(
72-
'wpmu_new_blog',
72+
'wp_initialize_site',
7373
array(
7474
__CLASS__,
75-
'wpmu_new_blog',
76-
)
75+
'wp_initialize_site'
76+
),
77+
10,
78+
2
7779
);
7880
add_filter(
7981
'wpmu_drop_tables',
@@ -176,16 +178,23 @@ private static function check_requirements() {
176178
/**
177179
* Create tables if new MU blog is created
178180
*
179-
* @param mixed $blog_id blog id.
180-
* @param mixed $user_id user id.
181-
* @param mixed $domain domain.
182-
* @param mixed $path path.
183-
* @param mixed $site_id site id.
184-
* @param mixed $meta meta.
181+
* wp_initialize_site hook introduced since 5.1.0
182+
* @link https://developer.wordpress.org/reference/hooks/wp_initialize_site/
183+
*
184+
* @param WP_Site $site
185+
* @param array $args
186+
* @return void
185187
*/
186-
public static function wpmu_new_blog( $blog_id, $user_id, $domain, $path, $site_id, $meta ) { //phpcs:ignore
187-
188+
public static function wp_initialize_site( WP_Site $site, array $args ) { //phpcs:ignore
188189
if ( is_plugin_active_for_network( 'woo-postfinancecheckout/woocommerce-postfinancecheckout.php' ) ) {
190+
$blog_id = $site->blog_id;
191+
// Defensive check: blog_id should always be set, otherwise will be shown as postfinancecheckout error
192+
if ( ! $blog_id ) {
193+
$logger = wc_get_logger();
194+
$logger->error( 'Could not detect blog_id during wp_initialize_site.', [ 'source' => 'postfinancecheckout' ] );
195+
return;
196+
}
197+
189198
switch_to_blog( $blog_id );
190199
self::migrate_db();
191200
restore_current_blog();
@@ -268,7 +277,7 @@ public static function check_version() {
268277
public static function plugin_row_meta( $links, $file ) {
269278
if ( WC_POSTFINANCECHECKOUT_PLUGIN_BASENAME === $file ) {
270279
$row_meta = array(
271-
'docs' => '<a href="https://plugin-documentation.postfinance-checkout.ch/pfpayments/woocommerce/3.3.13/docs/en/documentation.html" aria-label="' . esc_html__( 'View Documentation', 'woo-postfinancecheckout' ) . '">' . esc_html__( 'Documentation', 'woo-postfinancecheckout' ) . '</a>',
280+
'docs' => '<a href="https://plugin-documentation.postfinance-checkout.ch/pfpayments/woocommerce/3.3.14/docs/en/documentation.html" aria-label="' . esc_html__( 'View Documentation', 'woo-postfinancecheckout' ) . '">' . esc_html__( 'Documentation', 'woo-postfinancecheckout' ) . '</a>',
272281
);
273282

274283
return array_merge( $links, $row_meta );

includes/class-wc-postfinancecheckout-order-status-adapter.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,12 @@ public function update_order_status( WC_Order $order, ?string $status, ?string $
374374
*/
375375
public function get_order_status_on_payment_complete( string $status, int $order_id, WC_Order $order ): string
376376
{
377+
// If order consists entirely out of virtual products and their total is 0, change their status to completed
378+
if ( 'yes' === get_option( WooCommerce_PostFinanceCheckout::POSTFINANCECHECKOUT_CK_CHANGE_ORDER_STATUS )
379+
&& $order->get_total() <= 0 && WC_PostFinanceCheckout_Helper::is_order_virtual( $order ) ) {
380+
return self::POSTFINANCECHECKOUT_STATUS_COMPLETED;
381+
}
382+
377383
// Check if the transaction status is mapped in WooCommerce
378384
$mapped_status = $this->map_postfinancecheckout_status_to_woocommerce( \PostFinanceCheckout\Sdk\Model\TransactionState::FULFILL );
379385

0 commit comments

Comments
 (0)