Created
June 13, 2012 21:19
-
-
Save inspiran/2926562 to your computer and use it in GitHub Desktop.
Vespolina - injectable taxation hints
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected function preparePricingContextForTaxation($pricingContext) | |
{ | |
//Find out if the tax zone was supplied | |
$taxZone = $pricingContext->get('taxZone'); | |
if (null == $taxZone) { | |
//Check if a fulfillment address was explicitly set | |
$address = $pricingContext->get('fulfillmentAddress'); | |
if (null == $address) { | |
//We we don't have a fulfillment address, we use now the customer's info | |
$customer = $pricingContext->get('customer'); | |
if (null != $customer) { | |
$address = $customer->getAddresses()->first(); //Todo: should use delivery address | |
} | |
} | |
if (null != $address) { | |
//So we have an address, lookup the tax zone | |
$taxZone = $this->taxationManager->findTaxZoneByAddress($address); | |
$pricingContext->set('taxZone', $taxZone); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment