Skip to content

Commit 6157252

Browse files
committed
don't automatically disable order synchronisation for new installation and small fixes
1 parent 15dc02e commit 6157252

File tree

4 files changed

+12
-23
lines changed

4 files changed

+12
-23
lines changed

src/Admin/Options.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1520,9 +1520,9 @@ function () {
15201520
<input
15211521
type="checkbox"
15221522
id="disable_order_import"
1523-
name="<?php echo esc_attr( sprintf( '%s[disable_order_import]', self::SF_ORDERS_OPTIONS ) ); ?>"
1524-
value="yes"
1525-
<?php checked( 1, isset( $this->sf_orders_options['disable_order_import'] ) ? $this->sf_orders_options['disable_order_import'] : 0 ); ?>
1523+
name="<?php echo esc_attr( sprintf( '%s[disable_order_import]', self::SF_ORDERS_OPTIONS ) ); ?>"
1524+
value="1"
1525+
<?php checked( '1', isset( $this->sf_orders_options['disable_order_import'] ) ? $this->sf_orders_options['disable_order_import'] : '' ); ?>
15261526
>
15271527
<?php esc_html_e( 'Disable orders synchronisation', 'shopping-feed' ); ?>
15281528
</label>

src/Orders/Orders.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ public function get_orders( $sf_account, $since = '' ) {
6262

6363
// Check if order import is enable
6464
if ( ShoppingFeedHelper::is_order_import_disable() ) {
65+
ShoppingFeedHelper::log(
66+
\WC_Log_Levels::INFO,
67+
'Order import is disabled',
68+
'shopping-feed-orders'
69+
);
70+
6571
return false;
6672
}
6773

src/ShoppingFeed.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,6 @@ public function plugin_action_links( $links = array() ) {
222222
public static function activate() {
223223
if ( defined( 'WC_VERSION' ) ) {
224224
self::add_sf_directory();
225-
ShoppingFeedHelper::set_default_orders_option();
226225
Actions::register_feed_generation();
227226
Actions::register_get_orders();
228227
}

src/ShoppingFeedHelper.php

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ public static function get_zones_with_shipping_methods() {
427427
);
428428
}
429429

430-
$all_shipping_methods = apply_filters('sf_all_shipping_methods', $all_shipping_methods);
430+
$all_shipping_methods = apply_filters( 'sf_all_shipping_methods', $all_shipping_methods );
431431

432432
return $all_shipping_methods;
433433
}
@@ -980,24 +980,8 @@ public static function is_order_import_disable() {
980980
return false;
981981
}
982982

983-
return (bool) ( $orders_options['disable_order_import'] ?? 0 ); // True if the value does not exist. For existing customers
984-
}
985-
986-
/**
987-
* Set default orders options
988-
* @return void
989-
*/
990-
public static function set_default_orders_option() {
991-
// Skip if option has already set
992-
if ( false !== get_option( options::SF_ORDERS_OPTIONS ) ) {
993-
return;
994-
}
983+
$disable_order_import = (int) ( $orders_options['disable_order_import'] ?? 0 );
995984

996-
update_option(
997-
options::SF_ORDERS_OPTIONS,
998-
[
999-
'disable_order_import' => 1,
1000-
]
1001-
);
985+
return 1 === $disable_order_import;
1002986
}
1003987
}

0 commit comments

Comments
 (0)