From 3720baf1f644dbcc4f062a6b873b2b527cd3015f Mon Sep 17 00:00:00 2001 From: Edgaras Date: Wed, 3 Apr 2024 14:23:59 +0300 Subject: [PATCH] Release 3.0.1 --- changelog.txt | 7 --- ...-wc-postfinancecheckout-admin-document.php | 51 +++++++++++------ ...-postfinancecheckout-admin-transaction.php | 56 +++++++++++-------- readme.txt | 12 ++-- woocommerce-postfinancecheckout.php | 17 +++--- 5 files changed, 79 insertions(+), 64 deletions(-) diff --git a/changelog.txt b/changelog.txt index 167ceb1..60fc22b 100644 --- a/changelog.txt +++ b/changelog.txt @@ -727,10 +727,3 @@ Tested against: - [Tested Against] Woocommerce 8.5.2 - [Tested Against] PHP SDK 4.0.2 -= 3.0.1 - April 3 2024 = -- [Feature] Added support to High Performance Order Storage (HPOS). -- [Tested Against] PHP 8.2 -- [Tested Against] Wordpress 6.5 -- [Tested Against] Woocommerce 8.7.0 -- [Tested Against] PHP SDK 4.0.2 - diff --git a/includes/admin/class-wc-postfinancecheckout-admin-document.php b/includes/admin/class-wc-postfinancecheckout-admin-document.php index 4baf6c5..0c5cb61 100644 --- a/includes/admin/class-wc-postfinancecheckout-admin-document.php +++ b/includes/admin/class-wc-postfinancecheckout-admin-document.php @@ -113,35 +113,50 @@ public static function add_buttons_to_overview( WC_Order $order ) { /** * Add WC Meta boxes. - * @see: https://woo.com/document/high-performance-order-storage/#section-8 */ public static function add_meta_box() { - $screen = class_exists( '\Automattic\WooCommerce\Internal\DataStores\Orders\CustomOrdersTableController' ) - && wc_get_container()->get( \Automattic\WooCommerce\Internal\DataStores\Orders\CustomOrdersTableController::class )->custom_orders_table_usage_is_enabled() - ? wc_get_page_screen_id( 'shop-order' ) - : 'shop_order'; - add_meta_box( - 'woocommerce-order-postfinancecheckout-documents', - __( 'PostFinance Checkout Documents', 'woo-postfinancecheckout' ), + global $post; + if ( 'shop_order' !== $post->post_type ) { + return; + } + $order = WC_Order_Factory::get_order( $post->ID ); + $method = wc_get_payment_gateway_by_order( $order ); + if ( ! ( $method instanceof WC_PostFinanceCheckout_Gateway ) ) { + return; + } + $transaction_info = WC_PostFinanceCheckout_Entity_Transaction_Info::load_by_order_id( $order->get_id() ); + if ( $transaction_info->get_id() !== null && in_array( + $transaction_info->get_state(), array( - __CLASS__, - 'output', + \PostFinanceCheckout\Sdk\Model\TransactionState::COMPLETED, + \PostFinanceCheckout\Sdk\Model\TransactionState::FULFILL, + \PostFinanceCheckout\Sdk\Model\TransactionState::DECLINE, ), - $screen, - 'side', - 'default' - ); + true + ) ) { + add_meta_box( + 'woocommerce-order-postfinancecheckout-documents', + __( 'PostFinance Checkout Documents', 'woo-postfinancecheckout' ), + array( + __CLASS__, + 'output', + ), + 'shop_order', + 'side', + 'default' + ); + } } /** * Output the metabox. * - * @param WP_Post|WP_Order $post_or_order_object - * This object is provided by woocommerce when using its screen. + * @param WP_Post $post Post. */ - public static function output( $post_or_order_object ) { - $order = ( $post_or_order_object instanceof WP_Post ) ? wc_get_order( $post_or_order_object->ID ) : $post_or_order_object; + public static function output( $post ) { + global $post; + $order = WC_Order_Factory::get_order( $post->ID ); $method = wc_get_payment_gateway_by_order( $order ); if ( ! ( $method instanceof WC_PostFinanceCheckout_Gateway ) ) { return; diff --git a/includes/admin/class-wc-postfinancecheckout-admin-transaction.php b/includes/admin/class-wc-postfinancecheckout-admin-transaction.php index a9b3366..f65c6fe 100644 --- a/includes/admin/class-wc-postfinancecheckout-admin-transaction.php +++ b/includes/admin/class-wc-postfinancecheckout-admin-transaction.php @@ -41,35 +41,45 @@ public static function init() { /** * Add WC Meta boxes. - * @see: https://woo.com/document/high-performance-order-storage/#section-8 */ public static function add_meta_box() { - $screen = class_exists( '\Automattic\WooCommerce\Internal\DataStores\Orders\CustomOrdersTableController' ) - && wc_get_container()->get( \Automattic\WooCommerce\Internal\DataStores\Orders\CustomOrdersTableController::class )->custom_orders_table_usage_is_enabled() - ? wc_get_page_screen_id( 'shop-order' ) - : 'shop_order'; - add_meta_box( - 'woocommerce-order-postfinancecheckout-transaction', - __( 'PostFinance Checkout Transaction', 'woocommerce-postfinancecheckout' ), - array( - __CLASS__, - 'output', - ), - $screen, - 'normal', - 'default' - ); + global $post; + if ( 'shop_order' != $post->post_type ) { + return; + } + $order = WC_Order_Factory::get_order( $post->ID ); + $method = wc_get_payment_gateway_by_order( $order ); + if ( ! ( $method instanceof WC_PostFinanceCheckout_Gateway ) ) { + return; + } + $transaction_info = WC_PostFinanceCheckout_Entity_Transaction_Info::load_by_order_id( $order->get_id() ); + if ( $transaction_info->get_id() == null ) { + $transaction_info = WC_PostFinanceCheckout_Entity_Transaction_Info::load_newest_by_mapped_order_id( $order->get_id() ); + } + if ( $transaction_info->get_id() != null ) { + add_meta_box( + 'woocommerce-order-postfinancecheckout-transaction', + __( 'PostFinance Checkout Transaction', 'woocommerc-postfinancecheckout' ), + array( + __CLASS__, + 'output', + ), + 'shop_order', + 'normal', + 'default' + ); + } } /** * Output the metabox. * - * @param WP_Post|WP_Order $post_or_order_object - * This object is provided by woocommerce when using its screen. + * @param WP_Post $post post data. */ - public static function output( $post_or_order_object ) { - $order = ( $post_or_order_object instanceof WP_Post ) ? wc_get_order( $post_or_order_object->ID ) : $post_or_order_object; + public static function output( $post ) { + global $post; + $order = WC_Order_Factory::get_order( $post->ID ); $method = wc_get_payment_gateway_by_order( $order ); if ( ! ( $method instanceof WC_PostFinanceCheckout_Gateway ) ) { return; @@ -119,7 +129,7 @@ public static function output( $post_or_order_object ) { get_order_id() ); ?> - + get_failure_reason() != null ) : ?> @@ -145,7 +155,7 @@ public static function output( $post_or_order_object ) { - + @@ -167,7 +177,7 @@ public static function output( $post_or_order_object ) { - + diff --git a/readme.txt b/readme.txt index 3e069b0..ccc1bc6 100644 --- a/readme.txt +++ b/readme.txt @@ -3,7 +3,7 @@ Contributors: postfinancecheckout AG Tags: woocommerce PostFinance Checkout, woocommerce, PostFinance Checkout, payment, e-commerce, webshop, psp, invoice, packing slips, pdf, customer invoice, processing Requires at least: 4.7 Tested up to: 6.2 -Stable tag: 3.0.1 +Stable tag: 3.0.0 License: Apache 2 License URI: http://www.apache.org/licenses/LICENSE-2.0 @@ -56,9 +56,9 @@ Support queries can be issued on the [PostFinance Checkout support site](https:/ == Changelog == -= 3.0.1 - April 3 2024 = -- [Feature] Added support to High Performance Order Storage (HPOS). -- [Tested Against] PHP 8.2 -- [Tested Against] Wordpress 6.5 -- [Tested Against] Woocommerce 8.7.0 += 3.0.0 - February 20 2024 = +- [Feature] Full version release +- [Tested Against] PHP 8.0 +- [Tested Against] Wordpress 6.4.3 +- [Tested Against] Woocommerce 8.5.2 - [Tested Against] PHP SDK 4.0.2 diff --git a/woocommerce-postfinancecheckout.php b/woocommerce-postfinancecheckout.php index 447d7bc..71e6a76 100644 --- a/woocommerce-postfinancecheckout.php +++ b/woocommerce-postfinancecheckout.php @@ -3,10 +3,15 @@ * Plugin Name: PostFinance Checkout * Plugin URI: https://wordpress.org/plugins/woo-postfinancecheckout * Description: Process WooCommerce payments with PostFinance Checkout. + * Version: 3.0.0 * License: Apache2 * License URI: http://www.apache.org/licenses/LICENSE-2.0 * Author: postfinancecheckout AG * Author URI: https://postfinance.ch/en/business/products/e-commerce/postfinance-checkout-all-in-one.html + * Requires at least: 4.7 + * Tested up to: 6.3 + * WC requires at least: 3.0.0 + * WC tested up to: 7.8.2 * * Text Domain: postfinancecheckout * Domain Path: /languages/ @@ -34,14 +39,14 @@ final class WooCommerce_PostFinanceCheckout { const CK_INTEGRATION = 'wc_postfinancecheckout_integration'; const CK_ORDER_REFERENCE = 'wc_postfinancecheckout_order_reference'; const CK_ENFORCE_CONSISTENCY = 'wc_postfinancecheckout_enforce_consistency'; - const WC_MAXIMUM_VERSION = '8.7.0'; + const WC_MAXIMUM_VERSION = '8.5.2'; /** * WooCommerce PostFinanceCheckout version. * * @var string */ - private $version = '3.0.1'; + private $version = '3.0.0'; /** * The single instance of the class. @@ -442,14 +447,6 @@ public function loaded() { 10, 2 ); - - - add_action( 'before_woocommerce_init', function() { - if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) { - \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true ); - } - } ); - } /**