diff --git a/.plugin-data b/.plugin-data
index 6b972083..315f6c26 100644
--- a/.plugin-data
+++ b/.plugin-data
@@ -1,4 +1,4 @@
{
- "version": "6.2.0",
+ "version": "6.3.0",
"slug": "shopping-feed"
}
\ No newline at end of file
diff --git a/readme.md b/readme.md
index 20ea227c..670dcfac 100644
--- a/readme.md
+++ b/readme.md
@@ -2,8 +2,8 @@
* Contributors: ShoppingFeed, BeAPI
* Tags: shoppingfeed, marketplace, woocommerce, woocommerce shoppingfeed, create woocommerce products shoppingfeed, products feed, generate shoppingfeed, amazon, Jet, Walmart, many marketplace, import orders
-* Stable tag: 6.2.0
-* Version: 6.2.0
+* Stable tag: 6.3.0
+* Version: 6.3.0
* Requires PHP: 7.1
* Requires at least: 5.7
* Tested up to: 6.2
@@ -15,6 +15,9 @@
> Version 6.0.0 is a major version, there are several changes and improvements which affect the architecture of the plugin. You will have to re-configure the plugin, all the previous settings will be lost
## Changelog
+* 6.3.0
+ * Orders : Don't import orders fulfilled by the marketplaces by default, see details in the description.
+ * WPCLI command : don't rerun the generation process when an error occurs.
* 6.2.0
* Rework feed generation process to better handle shop with large amount of products.
* 6.1.20
@@ -151,6 +154,17 @@ Sign up for free on ShoppingFeed : https://shopping-feed.com/
- In Plugins > Installed Plugins > ShoppingFeed > settings, log in with your ShoppingFeed credentials
- In Settings, check that ShoppingFeed is enabled and save changes
+## Orders fulfilled by the marketplaces
+
+The plugin won't import orders fulfilled by marketplaces by default.
+
+Options are available in the plugin settings to include those orders during the import.
+
+They can be found in the "Orders" tab :
+
+* Orders fulfilled by marketplace : import orders even if they are fulfilled by the marketplace.
+* Fulfilled by marketplace order's status : select the status used for orders fulfilled by marketplaces when they are imported.
+
## Shipment tracking support
For now, the only shipment tracking plugins supported are :
diff --git a/readme.txt b/readme.txt
index 3e39c746..9fd1cc6c 100644
--- a/readme.txt
+++ b/readme.txt
@@ -1,8 +1,8 @@
## ShoppingFeed
Contributors: ShoppingFeed, BeAPI
Tags: shoppingfeed, marketplace, woocommerce, woocommerce shoppingfeed, create woocommerce products shoppingfeed, products feed, generate shoppingfeed, amazon, Jet, Walmart, many marketplace, import orders
-Stable tag: 6.2.0
-Version: 6.2.0
+Stable tag: 6.3.0
+Version: 6.3.0
Requires PHP: 7.1
Requires at least: 5.7
Tested up to: 6.2
@@ -13,6 +13,9 @@ WC tested up to: 7.7
Version 6.0.0 is a major version, there are several changes and improvements which affect the architecture of the plugin. You will have to re-configure the plugin, all the previous settings will be lost
== Changelog ==
+* 6.3.0
+ * Orders : Don't import orders fulfilled by the marketplaces by default, see details in the description.
+ * WPCLI command : don't rerun the generation process when an error occurs.
* 6.2.0
* Rework feed generation process to better handle shop with large amount of products.
* 6.1.20
@@ -151,6 +154,17 @@ Sign up for free on ShoppingFeed : https://shopping-feed.com/
- In Plugins > Installed Plugins > ShoppingFeed > settings, log in with your ShoppingFeed credentials
- In Settings, check that ShoppingFeed is enabled and save changes
+## Orders fulfilled by the marketplaces
+
+The plugin won't import orders fulfilled by marketplaces by default.
+
+Options are available in the plugin settings to include those orders during the import.
+
+They can be found in the "Orders" tab :
+
+* Orders fulfilled by marketplace : import orders even if they are fulfilled by the marketplace.
+* Fulfilled by marketplace order's status : select the status used for orders fulfilled by marketplaces when they are imported.
+
## Shipment tracking support
For now, the only shipment tracking plugins supported are :
diff --git a/shoppingfeed.php b/shoppingfeed.php
index 5961aef4..0bfa9144 100644
--- a/shoppingfeed.php
+++ b/shoppingfeed.php
@@ -7,7 +7,7 @@
* Author URI: https://www.shopping-feed.com/
* Text Domain: shopping-feed
* Domain Path: /languages
- * Version: 6.2.0
+ * Version: 6.3.0
* Requires at least: 5.7
* Requires PHP: 7.1
* WC requires at least: 5.1.0
@@ -26,7 +26,7 @@
require_once plugin_dir_path( __FILE__ ) . '/vendor/autoload.php';
}
-define( 'SF_VERSION', '6.2.0' );
+define( 'SF_VERSION', '6.3.0' );
define( 'SF_DB_VERSION_SLUG', 'SF_DB_VERSION' );
define( 'SF_DB_VERSION', '1.0.0' );
define( 'SF_UPGRADE_RUNNING', 'SF_UPGRADE_RUNNING' );
diff --git a/src/Addons/Inventory/Inventory.php b/src/Addons/Inventory/Inventory.php
index fc63ae27..db28bd60 100644
--- a/src/Addons/Inventory/Inventory.php
+++ b/src/Addons/Inventory/Inventory.php
@@ -7,6 +7,7 @@
use ShoppingFeed\ShoppingFeedWC\Addons\Inventory\Marketplaces\Amazon;
use ShoppingFeed\ShoppingFeedWC\Addons\Inventory\Marketplaces\Cdiscount;
+use ShoppingFeed\ShoppingFeedWC\Addons\Inventory\Marketplaces\FulfilledByChannel;
use ShoppingFeed\ShoppingFeedWC\Addons\Inventory\Marketplaces\MonoMono;
class Inventory {
@@ -25,9 +26,15 @@ class Inventory {
*/
private $mono_mono;
+ /**
+ * @var FulfilledByChannel
+ */
+ private $fulfilled_by_channel;
+
public function __construct() {
- $this->amazon = new Amazon();
- $this->cdiscount = new Cdiscount();
- $this->mono_mono = new MonoMono();
+ $this->amazon = new Amazon();
+ $this->cdiscount = new Cdiscount();
+ $this->mono_mono = new MonoMono();
+ $this->fulfilled_by_channel = new FulfilledByChannel();
}
}
diff --git a/src/Addons/Inventory/Marketplaces/Amazon.php b/src/Addons/Inventory/Marketplaces/Amazon.php
index b9c8e808..b3eb4df7 100644
--- a/src/Addons/Inventory/Marketplaces/Amazon.php
+++ b/src/Addons/Inventory/Marketplaces/Amazon.php
@@ -12,23 +12,18 @@ class Amazon {
use Marketplace;
public function __construct() {
- add_action( 'sf_add_metas', array( $this, 'add_metas' ) );
+ add_action( 'sf_add_metas', [ $this, 'add_metas' ] );
}
/**
* @param $metas Metas
*/
public function add_metas( $metas ) {
- if (
- true !== $this->is_amazon( $metas->sf_order ) ||
- 'AFN' !== $metas->sf_order->getPaymentInformation()['method']
- ) {
- return;
+ if ( $this->is_fulfilled_by_amazon( $metas->sf_order ) ) {
+ $metas->add_meta(
+ Metas::$dont_update_inventory,
+ true
+ );
}
-
- $metas->add_meta(
- Metas::$dont_update_inventory,
- true
- );
}
}
diff --git a/src/Addons/Inventory/Marketplaces/Cdiscount.php b/src/Addons/Inventory/Marketplaces/Cdiscount.php
index ae434b82..fe999ce0 100644
--- a/src/Addons/Inventory/Marketplaces/Cdiscount.php
+++ b/src/Addons/Inventory/Marketplaces/Cdiscount.php
@@ -12,23 +12,18 @@ class Cdiscount {
use Marketplace;
public function __construct() {
- add_action( 'sf_add_metas', array( $this, 'add_metas' ) );
+ add_action( 'sf_add_metas', [ $this, 'add_metas' ] );
}
/**
* @param $metas Metas
*/
public function add_metas( $metas ) {
- if (
- true !== $this->is_cdiscount( $metas->sf_order ) ||
- 'CLogistique' !== $metas->sf_order->getPaymentInformation()['method']
- ) {
- return;
+ if ( $this->is_fulfilled_by_cdiscount( $metas->sf_order ) ) {
+ $metas->add_meta(
+ Metas::$dont_update_inventory,
+ true
+ );
}
-
- $metas->add_meta(
- Metas::$dont_update_inventory,
- true
- );
}
}
diff --git a/src/Addons/Inventory/Marketplaces/FulfilledByChannel.php b/src/Addons/Inventory/Marketplaces/FulfilledByChannel.php
new file mode 100644
index 00000000..a22e5a7c
--- /dev/null
+++ b/src/Addons/Inventory/Marketplaces/FulfilledByChannel.php
@@ -0,0 +1,26 @@
+is_fulfilled_by_channel( $metas->sf_order ) ) {
+ $metas->add_meta(
+ Metas::$dont_update_inventory,
+ true
+ );
+ }
+ }
+}
diff --git a/src/Addons/Inventory/Marketplaces/MonoMono.php b/src/Addons/Inventory/Marketplaces/MonoMono.php
index 3bcb3550..a4a53eca 100644
--- a/src/Addons/Inventory/Marketplaces/MonoMono.php
+++ b/src/Addons/Inventory/Marketplaces/MonoMono.php
@@ -12,26 +12,18 @@ class MonoMono {
use Marketplace;
public function __construct() {
- add_action( 'sf_add_metas', array( $this, 'add_metas' ) );
+ add_action( 'sf_add_metas', [ $this, 'add_metas' ] );
}
/**
* @param $metas Metas
*/
public function add_metas( $metas ) {
- if (
- (
- true !== $this->is_mano_mano( $metas->sf_order ) &&
- empty( $metas->sf_order_array['additionalFields']['env'] )
- ) ||
- 'epmm' !== $metas->sf_order_array['additionalFields']['env']
- ) {
- return;
+ if ( $this->is_fulfilled_by_manomano( $metas->sf_order ) ) {
+ $metas->add_meta(
+ Metas::$dont_update_inventory,
+ true
+ );
}
-
- $metas->add_meta(
- Metas::$dont_update_inventory,
- true
- );
}
}
diff --git a/src/Addons/Marketplace.php b/src/Addons/Marketplace.php
index 820e2595..877243a8 100644
--- a/src/Addons/Marketplace.php
+++ b/src/Addons/Marketplace.php
@@ -1,4 +1,5 @@
getChannel()->getName() ) === 'ManoMano' ||
+ strtoupper( $sf_order->getChannel()->getName() ) === 'MANOMANO' ||
$sf_order->getChannel()->getId() === 259
);
}
@@ -62,10 +63,9 @@ private function is_mano_mano( $sf_order ) {
/**
* Check if the current SF order is from the Zalando marketplace
*
- * @param $sf_order OrderResource
+ * @param OrderResource $sf_order
*
* @return bool
- * @author Stéphane Gillot
*/
private function is_zalando( $sf_order ) {
@@ -82,4 +82,75 @@ private function is_zalando( $sf_order ) {
);
}
+ /**
+ * Check if the order is fulfilled by Amazon.
+ *
+ * @param OrderResource $sf_order
+ *
+ * @return bool
+ */
+ private function is_fulfilled_by_amazon( $sf_order ) {
+ return $this->is_amazon( $sf_order ) && 'afn' === strtolower( $sf_order->getPaymentInformation()['method'] );
+ }
+
+ /**
+ * Check if the order is fulfilled by CDiscount.
+ *
+ * @param OrderResource $sf_order
+ *
+ * @return bool
+ */
+ private function is_fulfilled_by_cdiscount( $sf_order ) {
+ return $this->is_cdiscount( $sf_order ) && 'clogistique' === strtolower( $sf_order->getPaymentInformation()['method'] );
+ }
+
+ /**
+ * Check if the order is fulfilled by ManoMano.
+ *
+ * @param OrderResource $sf_order
+ *
+ * @return bool
+ */
+ private function is_fulfilled_by_manomano( $sf_order ) {
+ return $this->is_mano_mano( $sf_order ) && 'epmm' === strtolower( $sf_order->toArray()['additionalFields']['env'] );
+ }
+
+ /**
+ * Check if the order is fulfilled by the channel.
+ *
+ * @param OrderResource $sf_order
+ *
+ * @return bool
+ */
+ private function is_fulfilled_by_channel( $sf_order ) {
+ return ! empty( $sf_order->toArray()['fulfilledBy'] ) && 'channel' === strtolower( $sf_order->toArray()['fulfilledBy'] );
+ }
+
+ /**
+ * Check if the order is fulfilled by a marketplace.
+ *
+ * @param OrderResource $sf_order
+ *
+ * @return bool
+ */
+ private function is_fulfilled_by_marketplace( $sf_order ) {
+
+ if ( $this->is_fulfilled_by_amazon( $sf_order ) ) {
+ return true;
+ }
+
+ if ( $this->is_fulfilled_by_cdiscount( $sf_order ) ) {
+ return true;
+ }
+
+ if ( $this->is_fulfilled_by_manomano( $sf_order ) ) {
+ return true;
+ }
+
+ if ( $this->is_fulfilled_by_channel( $sf_order ) ) {
+ return true;
+ }
+
+ return false;
+ }
}
diff --git a/src/Admin/Options.php b/src/Admin/Options.php
index 0dc6997e..2bcf7ce6 100644
--- a/src/Admin/Options.php
+++ b/src/Admin/Options.php
@@ -985,7 +985,7 @@ private function init_orders_setting_page() {
$this->load_assets();
add_settings_section(
- 'sf_orders_settings_import_frequency',
+ 'sf_orders_settings_import_options',
__( 'Import Options', 'shopping-feed' ),
function () {
//Init orders actions after update
@@ -999,7 +999,11 @@ function () {
$frequencies = [ 5, 10, 15, 30, 45, 60 ];
$frequencies_options = [];
foreach ( $frequencies as $frequency ) {
- $frequencies_options[ $frequency * MINUTE_IN_SECONDS ] = sprintf( '%s %s', $frequency, __( 'min', 'shopping-feed' ) );
+ $frequencies_options[ $frequency * MINUTE_IN_SECONDS ] = sprintf(
+ '%s %s',
+ $frequency,
+ __( 'min', 'shopping-feed' )
+ );
}
add_settings_field(
@@ -1012,56 +1016,104 @@ function () use ( $frequencies_options ) {
foreach ( $frequencies_options as $frequency => $name ) {
?>
+ value=""
+ sf_orders_options['import_frequency'] ) ? $this->sf_orders_options['import_frequency'] : false ); ?>>
+
+
-