34 lines
		
	
	
		
			895 B
		
	
	
	
		
			PHP
		
	
	
		
			Executable File
		
	
	
			
		
		
	
	
			34 lines
		
	
	
		
			895 B
		
	
	
	
		
			PHP
		
	
	
		
			Executable File
		
	
	
| <?php
 | |
| 
 | |
| namespace IpSupply\SyncOrder\Sync;
 | |
| 
 | |
| class Detail implements \JsonSerializable
 | |
| {
 | |
|     public $productId = 0;
 | |
|     public $title = null;
 | |
|     public $sku = null;
 | |
|     public $condition = null;
 | |
|     public $qty = 0;
 | |
|     public $price = 0;
 | |
|     public $amount = 0;
 | |
| 
 | |
|     function __construct(\Magento\Sales\Model\Order\Item $item)
 | |
|     {
 | |
|         $this->productId = $item->getProductId();
 | |
|         $this->title = $item->getProduct()->getName();
 | |
|         $this->sku = $item->getSku();
 | |
|         $this->qty = $item->getQtyOrdered();
 | |
|         $this->price = $item->getPrice();
 | |
|         $this->amount = $item->getQtyOrdered() * $item->getPrice();
 | |
| 
 | |
|         if ($condition = $item->getProductOptionByCode()) {
 | |
|             $this->condition = $condition['attributes_info'][0]['value'] ?? null;
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     public function jsonSerialize(): mixed
 | |
|     {
 | |
|         return (array) get_object_vars($this);
 | |
|     }
 | |
| }
 |