0

I want to specify a zero taxrate for customers in EU not Belgium. (The zero tax rate exists for Belgium) I found a way to add a taxresolver on product type. That works fine.... Should I create another taxresolver with a higher weight? Now not sure how to specify country (code). This is what I have for producttaxresolver:

public function resolve(TaxZone $zone, OrderItemInterface $order_item, ProfileInterface $customer_profile) {
  $rates = $zone->getRates();
  // Get the purchased entity.
  $item = $order_item->getPurchasedEntity();

  // Get the corresponding product.
  $product = $item->getProduct();
  $product_type = $product->bundle();
  // Take a rate depending on the product type.
  switch ($product_type) {
    case 'cursus':
      $rate_id = 'reduced';
      break;

    default:
      // The rate for other product type can be resolved using the default tax rate resolver.
      return NULL;
  }     

  foreach ($rates as $rate) {
    if ($rate->getId() == $rate_id) {
      return $rate;
    }
  }
}

I presume $customer_profile should hold the country code. I cannot find an API documentation for Drupal Commerce 2.0 in Drupal 8. Do you have any suggestion?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.