Skip to content

Commit

Permalink
Merge branch 'feature/setup' into feature/testing
Browse files Browse the repository at this point in the history
  • Loading branch information
larasmorningtrain committed Jan 29, 2024
2 parents b6e3dc2 + 24bb1a0 commit 5bda599
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@

class ProductService
{
public static function addEconomicProductFieldWithWrapper(): void
{
echo '<div class="options_group pricing show_if_simple hidden">';
self::addEconomicProductField();
echo '</div>';
}

public static function addEconomicProductField(): void
{
woocommerce_wp_text_input([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,14 +279,12 @@ public function addEanFieldFisplayAdminOrderMeta($order): void

public function isSettingsPage()
{
if (! is_admin() || ! function_exists('get_current_screen')) {
if (! is_admin()) {
return false;
}

$currentScreen = get_current_screen();

return $currentScreen->base === 'woocommerce_page_wc-settings' &&
isset($_GET['tab']) && $_GET['tab'] === 'checkout' &&
isset($_GET['section']) && $_GET['section'] === 'economic_invoice';
return ! empty($_GET['page']) && $_GET['page'] === 'wc-settings' &&
! empty($_GET['tab']) && $_GET['tab'] === 'checkout' &&
! empty($_GET['section']) && $_GET['section'] === 'economic_invoice';
}
}
4 changes: 2 additions & 2 deletions src/WoocommerceEconomic.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public static function init(): void
{
add_filter('woocommerce_payment_gateways', [self::class, 'registerGateway'], 10, 1);
add_action('init', [self::class, 'requireGateway'], 1);
add_action('woocommerce_product_options_general_product_data', [ProductService::class, 'addEconomicProductField']);
add_action('woocommerce_product_options_general_product_data', [ProductService::class, 'addEconomicProductFieldWithWrapper']);
add_action('woocommerce_variation_options', [ProductService::class, 'addEconomicProductField']);
add_action('woocommerce_save_product_variation', [ProductService::class, 'saveEconomicProductField'], 10, 2);
add_action('woocommerce_process_product_meta', [ProductService::class, 'saveEconomicProductField'], 10, 2);
Expand All @@ -27,6 +27,6 @@ public static function registerGateway($gateways): array

public static function requireGateway(): void
{
require_once __DIR__.'/woocommerce/WC_Gateway_Economic_Invoice.php';
require_once __DIR__.'/Woocommerce/WC_Gateway_Economic_Invoice.php';
}
}

0 comments on commit 5bda599

Please sign in to comment.