diff --git a/includes/admin/class-wc-gzd-admin.php b/includes/admin/class-wc-gzd-admin.php index 59ede79c..996b1393 100644 --- a/includes/admin/class-wc-gzd-admin.php +++ b/includes/admin/class-wc-gzd-admin.php @@ -114,6 +114,7 @@ public function tool_actions() { 'disable_food_options', 'install_oss', 'install_ts', + 'update_database', ); if ( current_user_can( 'manage_woocommerce' ) ) { @@ -1136,6 +1137,10 @@ protected function check_disable_notices() { } } + protected function check_update_database() { + WC_GZD_Install::update(); + } + public function disable_small_business_options() { // Update woocommerce options to show tax update_option( 'woocommerce_calc_taxes', 'yes' ); diff --git a/includes/admin/views/html-page-status-germanized.php b/includes/admin/views/html-page-status-germanized.php index 74c1e556..4d2423ab 100644 --- a/includes/admin/views/html-page-status-germanized.php +++ b/includes/admin/views/html-page-status-germanized.php @@ -217,6 +217,13 @@ + + + + + + + Status > Logs.', 'woocommerce-germanized' ) ) ); ?> diff --git a/includes/class-wc-gzd-install.php b/includes/class-wc-gzd-install.php index 46eb89f9..45701703 100644 --- a/includes/class-wc-gzd-install.php +++ b/includes/class-wc-gzd-install.php @@ -397,7 +397,7 @@ private static function needs_db_update() { /** * Handle updates */ - private static function update() { + public static function update() { $current_db_version = get_option( 'woocommerce_gzd_db_version', null ); if ( ! is_null( $current_db_version ) && ! empty( $current_db_version ) ) { diff --git a/includes/class-wc-gzd-payment-gateways.php b/includes/class-wc-gzd-payment-gateways.php index 546743ef..8a03479b 100644 --- a/includes/class-wc-gzd-payment-gateways.php +++ b/includes/class-wc-gzd-payment-gateways.php @@ -242,7 +242,7 @@ public function set_fields( $fields ) { public function get_current_gateway() { $current_gateway = WC()->session ? WC()->session->get( 'chosen_payment_method' ) : ''; - $has_block_checkout = has_block( 'woocommerce/checkout' ) || has_block( 'woocommerce/cart' ) || WC()->is_rest_api_request(); + $has_block_checkout = \Vendidero\Germanized\Utilities\CartCheckout::uses_checkout_block() || WC()->is_rest_api_request(); if ( $has_block_checkout ) { $current_gateway = WC()->session ? WC()->session->get( 'wc_gzd_blocks_chosen_payment_method', '' ) : ''; diff --git a/src/Blocks/Checkout.php b/src/Blocks/Checkout.php index 275824d6..548359f7 100644 --- a/src/Blocks/Checkout.php +++ b/src/Blocks/Checkout.php @@ -8,6 +8,7 @@ use Vendidero\Germanized\Blocks\PaymentGateways\DirectDebit; use Vendidero\Germanized\Blocks\PaymentGateways\Invoice; use Vendidero\Germanized\Package; +use Vendidero\Germanized\Utilities\CartCheckout; final class Checkout { @@ -57,7 +58,7 @@ function ( $is_visible, $checkbox_id ) { add_filter( 'woocommerce_get_item_data', function ( $item_data, $item ) { - $needs_price_labels = has_block( 'woocommerce/checkout' ) || has_block( 'woocommerce/cart' ) || WC()->is_rest_api_request(); + $needs_price_labels = CartCheckout::uses_checkout_block() || CartCheckout::uses_cart_block() || WC()->is_rest_api_request(); if ( apply_filters( 'woocommerce_gzd_cart_checkout_needs_block_price_labels', $needs_price_labels ) ) { $labels = wc_gzd_get_checkout_shopmarks(); diff --git a/src/Utilities/CartCheckout.php b/src/Utilities/CartCheckout.php new file mode 100644 index 00000000..3688bdf8 --- /dev/null +++ b/src/Utilities/CartCheckout.php @@ -0,0 +1,43 @@ +content ) ) { + return true; + } + } + } + $cart_page_id = wc_get_page_id( 'cart' ); + + return $cart_page_id && has_block( 'woocommerce/cart', $cart_page_id ); + } + + /** + * Checks if the default checkout page is using the Checkout block. + * + * @return bool true if the WC checkout page is using the Checkout block. + */ + public static function uses_checkout_block() { + if ( function_exists( 'wc_current_theme_is_fse_theme' ) && wc_current_theme_is_fse_theme() && is_callable( array( '\Automattic\WooCommerce\Blocks\Utils\BlockTemplateUtils', 'get_block_templates_from_db' ) ) ) { + $templates_from_db = \Automattic\WooCommerce\Blocks\Utils\BlockTemplateUtils::get_block_templates_from_db( array( 'checkout', 'page-checkout' ), 'wp_template' ); + foreach ( $templates_from_db as $template ) { + if ( has_block( 'woocommerce/checkout', $template->content ) ) { + return true; + } + } + } + $checkout_page_id = wc_get_page_id( 'checkout' ); + + return $checkout_page_id && has_block( 'woocommerce/checkout', $checkout_page_id ); + } +}