You are here

interface PriceSplitterInterface in Commerce Core 8.2

Splits price amounts across order items.

Useful for dividing a single order-level promotion or fee into multiple order-item-level ones, for easier VAT calculation or refunds.

Hierarchy

Expanded class hierarchy of PriceSplitterInterface

All classes that implement PriceSplitterInterface

2 files declare their use of PriceSplitterInterface
BuyXGetY.php in modules/promotion/src/Plugin/Commerce/PromotionOffer/BuyXGetY.php
OrderPromotionOfferBase.php in modules/promotion/src/Plugin/Commerce/PromotionOffer/OrderPromotionOfferBase.php

File

modules/order/src/PriceSplitterInterface.php, line 14

Namespace

Drupal\commerce_order
View source
interface PriceSplitterInterface {

  /**
   * Splits the given amount across order items.
   *
   * @param \Drupal\commerce_order\Entity\OrderInterface $order
   *   The order.
   * @param \Drupal\commerce_price\Price $amount
   *   The amount.
   * @param string $percentage
   *   The percentage used to calculate the amount, as a decimal.
   *   For example, '0.2' for 20%. When missing, calculated by comparing
   *   the amount to the order subtotal.
   *
   * @return \Drupal\commerce_price\Price[]
   *   An array of amounts keyed by order item ID.
   */
  public function split(OrderInterface $order, Price $amount, $percentage = NULL);

}

Members

Namesort descending Modifiers Type Description Overrides
PriceSplitterInterface::split public function Splits the given amount across order items. 1