Skip to content

Commit e4bb044

Browse files
palak-anaPalak Anand
andauthored
Overriding the getProvider method of taxjar (#525)
* Overriding the getProvider method of taxjar in facebook plugin * Updating the License information * added check for fb orders --------- Co-authored-by: Palak Anand <[email protected]>
1 parent d4311cd commit e4bb044

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
/**
5+
* Copyright (c) Meta Platforms, Inc. and affiliates.
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
20+
namespace Meta\Sales\Plugin;
21+
22+
use Taxjar\SalesTax\Model\Transaction;
23+
use Meta\Sales\Api\Data\FacebookOrderInterfaceFactory;
24+
25+
class TransactionUpdatePlugin {
26+
27+
/**
28+
* @var FacebookOrderInterfaceFactory
29+
*/
30+
private FacebookOrderInterfaceFactory $facebookOrderFactory;
31+
32+
/**
33+
* @param FacebookOrderInterfaceFactory $facebookOrderFactory
34+
*/
35+
public function __construct(
36+
FacebookOrderInterfaceFactory $facebookOrderFactory
37+
) {
38+
$this->facebookOrderFactory = $facebookOrderFactory;
39+
}
40+
41+
/**
42+
* Overriding the GetProvider method of Taxjar to return Facebook to exempt the order in
43+
* Taxjar plugin with marketplace exemption
44+
*/
45+
public function afterGetProvider(Transaction $subject, $result, $order): string
46+
{
47+
$facebookOrder = $this->facebookOrderFactory->create();
48+
$facebookOrder->load($order->getId(), 'magento_order_id');
49+
if ($facebookOrder->getFacebookOrderId()) {
50+
return 'facebook';
51+
}
52+
return $result;
53+
}
54+
}

app/code/Meta/Sales/etc/di.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,4 +553,7 @@
553553
<plugin name="facebookSalesOrderGrid"
554554
type="Meta\Sales\Plugin\FacebookSalesOrderGridPlugin"/>
555555
</type>
556+
<type name="Taxjar\SalesTax\Model\Transaction">
557+
<plugin name="meta_taxjar" type="Meta\Sales\Plugin\TransactionUpdatePlugin"/>
558+
</type>
556559
</config>

app/code/Meta/Sales/etc/module.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<module name="Meta_BusinessExtension"/>
1919
<module name="Meta_Catalog"/>
2020
<module name="Magento_OfflineShipping"/>
21+
<module name="Taxjar_SalesTax"/>
2122
</sequence>
2223
</module>
2324
</config>

0 commit comments

Comments
 (0)