Skip to content

Commit

Permalink
Merge pull request #88 from BeAPI/ver/6.3.0
Browse files Browse the repository at this point in the history
Release 6.3.0
  • Loading branch information
petitphp authored Sep 12, 2023
2 parents 13d6fc5 + 6bb7518 commit 44f93b4
Show file tree
Hide file tree
Showing 19 changed files with 648 additions and 107 deletions.
2 changes: 1 addition & 1 deletion .plugin-data
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"version": "6.2.0",
"version": "6.3.0",
"slug": "shopping-feed"
}
18 changes: 16 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 :

Expand Down
18 changes: 16 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 :
Expand Down
4 changes: 2 additions & 2 deletions shoppingfeed.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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' );
Expand Down
13 changes: 10 additions & 3 deletions src/Addons/Inventory/Inventory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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();
}
}
17 changes: 6 additions & 11 deletions src/Addons/Inventory/Marketplaces/Amazon.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
}
17 changes: 6 additions & 11 deletions src/Addons/Inventory/Marketplaces/Cdiscount.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
}
26 changes: 26 additions & 0 deletions src/Addons/Inventory/Marketplaces/FulfilledByChannel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace ShoppingFeed\ShoppingFeedWC\Addons\Inventory\Marketplaces;

use ShoppingFeed\ShoppingFeedWC\Addons\Marketplace;
use ShoppingFeed\ShoppingFeedWC\Orders\Order\Metas;

class FulfilledByChannel {
use Marketplace;

public function __construct() {
add_action( 'sf_add_metas', array( $this, 'add_metas' ) );
}

/**
* @param $metas Metas
*/
public function add_metas( $metas ) {
if ( $this->is_fulfilled_by_channel( $metas->sf_order ) ) {
$metas->add_meta(
Metas::$dont_update_inventory,
true
);
}
}
}
20 changes: 6 additions & 14 deletions src/Addons/Inventory/Marketplaces/MonoMono.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
}
85 changes: 78 additions & 7 deletions src/Addons/Marketplace.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace ShoppingFeed\ShoppingFeedWC\Addons;

use ShoppingFeed\Sdk\Api\Order\OrderResource;
Expand All @@ -12,7 +13,7 @@
*/
trait Marketplace {
/**
* @param $sf_order OrderResource
* @param OrderResource $sf_order
*
* @return bool
*/
Expand All @@ -24,7 +25,7 @@ private function is_cdiscount( $sf_order ) {
}

/**
* @param $sf_order OrderResource
* @param OrderResource $sf_order
*
* @return bool
*/
Expand All @@ -36,7 +37,7 @@ private function is_rdc( $sf_order ) {
}

/**
* @param $sf_order OrderResource
* @param OrderResource $sf_order
*
* @return bool
*/
Expand All @@ -48,24 +49,23 @@ private function is_amazon( $sf_order ) {
}

/**
* @param $sf_order OrderResource
* @param OrderResource $sf_order
*
* @return bool
*/
private function is_mano_mano( $sf_order ) {
return (
strtoupper( $sf_order->getChannel()->getName() ) === 'ManoMano' ||
strtoupper( $sf_order->getChannel()->getName() ) === 'MANOMANO' ||
$sf_order->getChannel()->getId() === 259
);
}

/**
* 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 ) {

Expand All @@ -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;
}
}
Loading

0 comments on commit 44f93b4

Please sign in to comment.