Skip to content

Instantly share code, notes, and snippets.

@inspiran
Created June 13, 2012 21:19
Show Gist options
  • Save inspiran/2926562 to your computer and use it in GitHub Desktop.
Save inspiran/2926562 to your computer and use it in GitHub Desktop.
Vespolina - injectable taxation hints
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