Skip to content

Commit 15dc02e

Browse files
committed
Update option wording and improve checks
1 parent 4000ce4 commit 15dc02e

File tree

6 files changed

+27
-13
lines changed

6 files changed

+27
-13
lines changed

src/Actions/Actions.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,10 @@ public static function register_feed_generation() {
4141
* Register new action to get orders
4242
*/
4343
public static function register_get_orders() {
44-
if ( ShoppingFeedHelper::is_disable_order_import() ) {
44+
if ( ShoppingFeedHelper::is_order_import_disable() ) {
4545
return;
4646
}
47+
4748
$sf_accounts = ShoppingFeedHelper::get_sf_account_options();
4849
if ( empty( $sf_accounts ) ) {
4950
ShoppingFeedHelper::get_logger()->error(

src/Admin/Options.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1513,7 +1513,7 @@ function () {
15131513

15141514
add_settings_field(
15151515
'disable_orders_import_option',
1516-
__( 'Disable order import', 'shopping-feed' ),
1516+
__( 'Order import', 'shopping-feed' ),
15171517
function () {
15181518
?>
15191519
<label for="disable_order_import">
@@ -1524,10 +1524,10 @@ function () {
15241524
value="yes"
15251525
<?php checked( 1, isset( $this->sf_orders_options['disable_order_import'] ) ? $this->sf_orders_options['disable_order_import'] : 0 ); ?>
15261526
>
1527-
<?php esc_html_e( 'Would you like to deactivate order import ?', 'shopping-feed' ); ?>
1527+
<?php esc_html_e( 'Disable orders synchronisation', 'shopping-feed' ); ?>
15281528
</label>
15291529
<p class="description" id="tagline-description">
1530-
<?php esc_html_e( 'If the box is checked, item import will be disabled.', 'shopping-feed' ); ?>
1530+
<?php esc_html_e( 'Disable the import of new orders to WooCommerce and stops the synchronization of existing ones with ShoppingFeed.', 'shopping-feed' ); ?>
15311531
</p>
15321532
<?php
15331533
},

src/Admin/WoocommerceActions.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,16 @@ function ( $order_id, $message ) {
151151
add_action(
152152
$action,
153153
function ( $order_id ) use ( $sf_action ) {
154-
//if its not a sf order
154+
//if it's not a sf order
155155
if ( ! Order::is_sf_order( $order_id ) ) {
156156
return;
157157
}
158+
159+
// Don't update order is synchronisation is disabled.
160+
if ( ShoppingFeedHelper::is_order_import_disable() ) {
161+
return;
162+
}
163+
158164
try {
159165
$operations = new Operations( $order_id );
160166
if ( ! method_exists( $operations, $sf_action ) ) {

src/Orders/Operations.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,6 @@ class Operations {
5353
* @throws Exception
5454
*/
5555
public function __construct( $order_id ) {
56-
// Check if import is enable
57-
if ( ShoppingFeedHelper::is_disable_order_import() ) {
58-
return;
59-
}
6056
//Check if the order from SF and return it with metas data
6157
$order_sf_metas = Order::get_order_sf_metas( $order_id );
6258
if (
@@ -196,6 +192,11 @@ private function acknowledge( $message = '' ) {
196192
* @param string $message
197193
*/
198194
public static function acknowledge_order( $order_id, $message = '' ) {
195+
// Don't acknowledge order is synchronisation is disabled.
196+
if ( ShoppingFeedHelper::is_order_import_disable() ) {
197+
return;
198+
}
199+
199200
$ok = true;
200201
try {
201202
$operations = new self( $order_id );
@@ -251,6 +252,11 @@ public static function get_available_operations() {
251252
* @author Stéphane Gillot
252253
*/
253254
public static function acknowledge_error( OrderResource $sf_order, $error ) {
255+
// Don't acknowledge order is synchronisation is disabled.
256+
if ( ShoppingFeedHelper::is_order_import_disable() ) {
257+
return;
258+
}
259+
254260
$shop = Sdk::get_sf_account_shop( $sf_order->toArray()['storeId'] );
255261
if ( ! $shop ) {
256262
ShoppingFeedHelper::get_logger()->notice(

src/Orders/Orders.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ public function get_orders( $sf_account, $since = '' ) {
6060
'shopping-feed-orders'
6161
);
6262

63-
// Check if import is enable
64-
if ( ShoppingFeedHelper::is_disable_order_import() ) {
63+
// Check if order import is enable
64+
if ( ShoppingFeedHelper::is_order_import_disable() ) {
6565
return false;
6666
}
6767

src/ShoppingFeedHelper.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -969,10 +969,11 @@ public static function current_language() {
969969
}
970970

971971
/**
972-
* Return SF disable order import
972+
* Check if order import is disable.
973+
*
973974
* @return bool
974975
*/
975-
public static function is_disable_order_import() {
976+
public static function is_order_import_disable() {
976977
$orders_options = self::get_sf_orders_options();
977978

978979
if ( false === $orders_options ) {

0 commit comments

Comments
 (0)