WC_Discounts::set_items_from_order( WC_Order $order )
Normalise order items which will be discounted.
Description Description
Parameters Parameters
- $order
-
(Required) Order object.
Source Source
File: includes/class-wc-discounts.php
public function set_items_from_order( $order ) { $this->items = array(); $this->discounts = array(); if ( ! is_a( $order, 'WC_Order' ) ) { return; } $this->object = $order; foreach ( $order->get_items() as $order_item ) { $item = new stdClass(); $item->key = $order_item->get_id(); $item->object = $order_item; $item->product = $order_item->get_product(); $item->quantity = $order_item->get_quantity(); $item->price = wc_add_number_precision_deep( $order_item->get_subtotal() ); if ( $order->get_prices_include_tax() ) { $item->price += wc_add_number_precision_deep( $order_item->get_subtotal_tax() ); } $this->items[ $order_item->get_id() ] = $item; } uasort( $this->items, array( $this, 'sort_by_price' ) ); }
Changelog Changelog
Version | Description |
---|---|
3.2.0 | Introduced. |