/** * Set the `basePrice` value for the item(s). * * Base price is the same as the actual price unless the strategy is * `inclusive` and the order is not taxable (i.e. a tax discount must be * applied). * * @param Event\Event $event */ public function setBasePrice(Event\Event $event) { if ($event instanceof Event\EntityEvent && $event->getEntity() instanceof Item) { $items = [$event->getEntity()]; } else { $items = $event->getOrder()->items->all(); } foreach ($items as $item) { $item->basePrice = $item->actualPrice; // Skip if tax strategy is exclusive or the order is taxable if ('exclusive' === $item->taxStrategy || true === $item->order->taxable) { continue; } $includedTax = $item->getProduct()->getTaxStrategy()->getIncludedTaxRate(); // Remove the tax discount $item->basePrice -= $this->_calculateInclusiveTax($item->actualPrice, $includedTax); $item->net -= $this->_calculateInclusiveTax($item->net, $includedTax); } }