Skip to content

Commit d8f2ad4

Browse files
authored
Add files via upload (#933)
1 parent 615e419 commit d8f2ad4

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
namespace Concrete\Package\CommunityStore\Src\CommunityStore\Tax;
3+
4+
use Concrete\Package\CommunityStore\Src\CommunityStore\Event\Event as StoreEvent;
5+
6+
class TaxEvent extends StoreEvent
7+
{
8+
9+
private $updatedRate = null;
10+
private $updatedLabel = null;
11+
12+
public function getUpdatedRate()
13+
{
14+
return $this->updatedRate;
15+
}
16+
17+
public function setUpdatedRate($rate)
18+
{
19+
$this->updatedRate = $rate;
20+
}
21+
22+
public function setUpdatedLabel($label)
23+
{
24+
$this->updatedLabel = $label;
25+
}
26+
27+
public function getUpdatedLabel()
28+
{
29+
return($this->updatedLabel);
30+
}
31+
32+
}

src/CommunityStore/Tax/TaxRate.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Concrete\Package\CommunityStore\Src\CommunityStore\Customer\Customer;
1111
use Concrete\Package\CommunityStore\Src\CommunityStore\Utilities\Calculator;
1212
use Concrete\Package\CommunityStore\Src\CommunityStore\Utilities\Tax as TaxHelper;
13+
use Concrete\Package\CommunityStore\Src\CommunityStore\Tax\TaxEvent;
1314

1415
/**
1516
* @ORM\Entity
@@ -261,6 +262,13 @@ public function calculate()
261262
$shippingtaxtotal = 0;
262263
$taxCalc = Config::get('community_store.calculation');
263264

265+
$event = new TaxEvent($this);
266+
\Events::dispatch('on_community_store_tax_calculate', $event);
267+
if($event->getUpdatedRate()) {
268+
$this->setTaxRate($event->getUpdatedRate());
269+
$this->setTaxLabel($event->getUpdatedLabel());
270+
}
271+
264272
if ($cart) {
265273
foreach ($cart as $cartItem) {
266274
$pID = $cartItem['product']['pID'];
@@ -315,6 +323,13 @@ public function calculateProduct($productObj, $qty)
315323
{
316324
$taxtotal = 0;
317325

326+
$event = new TaxEvent($this);
327+
\Events::dispatch('on_community_store_tax_calculate', $event);
328+
if($event->getUpdatedRate()) {
329+
$this->setTaxRate($event->getUpdatedRate());
330+
$this->setTaxLabel($event->getUpdatedLabel());
331+
}
332+
318333
if (is_object($productObj)) {
319334
if ($productObj->isTaxable()) {
320335
//if this tax rate is in the tax class associated with this product

0 commit comments

Comments
 (0)