| 1 |
<?php |
| 2 |
|
| 3 |
class Order_Items_Count extends Tag_Base { |
| 4 |
|
| 5 |
// phpcs:disable Generic.CodeAnalysis.UselessOverridingMethod |
| 6 |
public function __construct() { |
| 7 |
parent::__construct(); |
| 8 |
} |
| 9 |
|
| 10 |
/** |
| 11 |
* Get class id. |
| 12 |
* |
| 13 |
* @return string |
| 14 |
*/ |
| 15 |
public function get_id() { |
| 16 |
return '_order_items_count'; |
| 17 |
} |
| 18 |
|
| 19 |
/** |
| 20 |
* Get class title. |
| 21 |
* |
| 22 |
* @return string |
| 23 |
*/ |
| 24 |
public function get_title() { |
| 25 |
return esc_html__( 'Order Item Count', 'sellkit' ); |
| 26 |
} |
| 27 |
|
| 28 |
/** |
| 29 |
* Render true content. |
| 30 |
* |
| 31 |
* @return string |
| 32 |
*/ |
| 33 |
public function render_content() { |
| 34 |
if ( empty( self::$order ) ) { |
| 35 |
$this->get_data(); |
| 36 |
} |
| 37 |
|
| 38 |
$order_data = $this->get_order_item_count_data( self::$order ); |
| 39 |
|
| 40 |
return $order_data['quantity']; |
| 41 |
} |
| 42 |
|
| 43 |
/** |
| 44 |
* Get order item count data. |
| 45 |
* |
| 46 |
* @since 1.1.0 |
| 47 |
* @param object $order object of order parameters. |
| 48 |
* @return array |
| 49 |
*/ |
| 50 |
public function get_order_item_count_data( $order ) { |
| 51 |
foreach ( $order->get_items() as $item ) { |
| 52 |
$order_data = $item->get_data(); |
| 53 |
} |
| 54 |
|
| 55 |
return $order_data; |
| 56 |
} |
| 57 |
} |
| 58 |
|