diff --git a/changelog.txt b/changelog.txt index 7654600..180f320 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-wallee-admin-document.php b/includes/admin/class-wc-wallee-admin-document.php index 229484a..7aeb93d 100644 --- a/includes/admin/class-wc-wallee-admin-document.php +++ b/includes/admin/class-wc-wallee-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-wallee-documents', - __( 'wallee Documents', 'woo-wallee' ), + 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_Wallee_Gateway ) ) { + return; + } + $transaction_info = WC_Wallee_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', + \Wallee\Sdk\Model\TransactionState::COMPLETED, + \Wallee\Sdk\Model\TransactionState::FULFILL, + \Wallee\Sdk\Model\TransactionState::DECLINE, ), - $screen, - 'side', - 'default' - ); + true + ) ) { + add_meta_box( + 'woocommerce-order-wallee-documents', + __( 'wallee Documents', 'woo-wallee' ), + 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_Wallee_Gateway ) ) { return; diff --git a/includes/admin/class-wc-wallee-admin-transaction.php b/includes/admin/class-wc-wallee-admin-transaction.php index 8c62747..08a58f8 100644 --- a/includes/admin/class-wc-wallee-admin-transaction.php +++ b/includes/admin/class-wc-wallee-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-wallee-transaction', - __( 'wallee Transaction', 'woocommerce-wallee' ), - 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_Wallee_Gateway ) ) { + return; + } + $transaction_info = WC_Wallee_Entity_Transaction_Info::load_by_order_id( $order->get_id() ); + if ( $transaction_info->get_id() == null ) { + $transaction_info = WC_Wallee_Entity_Transaction_Info::load_newest_by_mapped_order_id( $order->get_id() ); + } + if ( $transaction_info->get_id() != null ) { + add_meta_box( + 'woocommerce-order-wallee-transaction', + __( 'wallee Transaction', 'woocommerc-wallee' ), + 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_Wallee_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 5cfefce..2e6c7a9 100644 --- a/readme.txt +++ b/readme.txt @@ -3,7 +3,7 @@ Contributors: wallee AG Tags: woocommerce wallee, woocommerce, wallee, 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 [wallee support site](https://app-wallee.co == 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-wallee.php b/woocommerce-wallee.php index bfc88b6..16325b2 100644 --- a/woocommerce-wallee.php +++ b/woocommerce-wallee.php @@ -3,10 +3,15 @@ * Plugin Name: wallee * Plugin URI: https://wordpress.org/plugins/woo-wallee * Description: Process WooCommerce payments with wallee. + * Version: 3.0.0 * License: Apache2 * License URI: http://www.apache.org/licenses/LICENSE-2.0 * Author: wallee AG * Author URI: https://www.wallee.com + * 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: wallee * Domain Path: /languages/ @@ -34,14 +39,14 @@ final class WooCommerce_Wallee { const CK_INTEGRATION = 'wc_wallee_integration'; const CK_ORDER_REFERENCE = 'wc_wallee_order_reference'; const CK_ENFORCE_CONSISTENCY = 'wc_wallee_enforce_consistency'; - const WC_MAXIMUM_VERSION = '8.7.0'; + const WC_MAXIMUM_VERSION = '8.5.2'; /** * WooCommerce Wallee 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 ); - } - } ); - } /**