D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home3
/
encodto1
/
aegiscae.com
/
wp-content
/
plugins
/
download-monitor
/
src
/
Shop
/
Order
/
Filename :
Manager.php
back
Copy
<?php namespace WPChill\DownloadMonitor\Shop\Order; use WPChill\DownloadMonitor\Shop\Services\Services; class Manager { /** * Build an array with OrderItem objects based on items in current cart * * @return OrderItem[] */ public function build_order_items_from_cart() { $order_items = array(); /** @var \WPChill\DownloadMonitor\Shop\Cart\Cart $cart */ $cart = Services::get()->service( 'cart' )->get_cart(); $cart_items = $cart->get_items(); if ( ! empty( $cart_items ) ) { /** @var \WPChill\DownloadMonitor\Shop\Cart\Item\Item $cart_item */ foreach ( $cart_items as $cart_item ) { $order_item = new OrderItem(); $order_item->set_label( $cart_item->get_label() ); $order_item->set_qty( $cart_item->get_qty() ); $order_item->set_product_id( $cart_item->get_product_id() ); $order_item->set_subtotal( $cart_item->get_subtotal() ); $order_item->set_tax_total( $cart_item->get_tax_total() ); /** @todo set tax class */ $order_item->set_total( $cart_item->get_total() ); $order_items[] = $order_item; } } return $order_items; } }