Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update SalesTaxService.php #4

Merged
merged 1 commit into from
Sep 6, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/services/SalesTaxService.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

use craft\commerce\Plugin as Commerce;
use craft\commerce\models\Address;
use craft\commerce\models\OrderAdjustment;
use craft\commerce\models\Transaction;
use craft\commerce\elements\Order;
use craft\commerce\helpers\Currency;
Expand Down Expand Up @@ -546,7 +547,24 @@ private function getTotalTax($order, $transaction)

foreach ($order->adjustments as $adjustment) {

/** @var OrderAdjustment $adjustment */

if($adjustment->type === 'discount') {

// if the discount is for a specific lineItem
if ($adjustmentLineItem = $adjustment->getLineItem()) {

// check to see if there is an Avatax Tax Code override specified
if(isset($adjustmentLineItem->purchasable->product->avataxTaxCode)) {

// if so, use this as the discountCode to make sure the adjustment is applied
// only to lineItems with that same tax code
$discountCode = $adjustmentLineItem->purchasable->product->avataxTaxCode;

}

}

$t = $t->withLine(
$adjustment->amount, // Total amount for the line item
1, // quantity
Expand Down