<?

namespace Widgets\Google\AnaliticTransaction;

/**
 * Description of AnaliticTransaction
 *
 * @author Admin
 */
class AnaliticTransaction extends \Widgets\Widget
{
    
    protected $transaction = [];
    
    protected $items = [];

    protected function stableVersions(): array
    {
        return [];
    }

    function getJsLinks(): array
    {
        return [];
    }

    function getCssLinks(): array
    {
        return [];
    }


    function getTransaction()
    {
        return $this->transaction;
    }
    
    function getItems()
    {
        return $this->items;
    }

    function setItems($items)
    {
        $this->items = $items;
        return $this;
    }

        
    /**
     * Добавление товара
     * 
     * <code>
ga('ecommerce:addItem', {
  'id': '1234',                     // Transaction ID. Required.
  'name': 'Fluffy Pink Bunnies',    // Product name. Required.
  'sku': 'DD23444',                 // SKU/code.
  'category': 'Party Toys',         // Category or variation.
  'price': '11.99',                 // Unit price.
  'quantity': '1'                   // Quantity.
});     
     * </code>
     * 
     * @param type $id
     * @param type $name
     * @param type $sku
     * @param type $category
     * @param type $price
     * @param type $quantity
     */
    function addItem($id,$name,$sku,$brand,$category,$price,$desc,$quantity = 1){
	
        $this->items[] = [
            "id"       => $id,
            "name"     => $name,
            "sku"      => $sku,
            "category" => $category,
            "price"    => $price,
            "quantity" => $quantity
        ];

//	$this->buffer .= 
//<<<HTML
//
//ga('ecommerce:addItem', {
//  'id': '$id',                     // Transaction ID. Required.
//  'name': '$name',    // Product name. Required.
//  'sku': '$sku',                 // SKU/code.
//  'category': '$category',         // Category or variation.
//  'price': '$price',                 // Unit price.
//  'quantity': '$quantity'                   // Quantity.
//});  		
//	    
//HTML;
//	
	
    }
    
    /**
     * Добавление заказа
     * 
     * <code>
ga('ecommerce:addTransaction', {
    'id': '1234',                     // Transaction ID. Required.
    'affiliation': 'Acme Clothing',   // Affiliation or store name.
    'revenue': '11.99',               // Grand Total.
    'shipping': '5',                  // Shipping.
    'tax': '1.29'                     // Tax.
}); 
     * </code>
     * 
     * @param type $id
     * @param type $affiliation
     * @param type $revenue
     * @param type $shipping
     * @param type $tax
     */
    function setTransaction($id,$affiliation,$revenue = 0,$shipping = 0,$tax = 0){

        $this->transaction= [
            'id'            =>  $id,
            "affiliation"   =>  $affiliation,
            "revenue"       =>  $revenue,
            "shipping"      =>  $shipping,
            "tax"           =>  $tax
        ];
        
//	$this->buffer .= 
//<<<HTML
//
//ga('ecommerce:addTransaction', {
//    'id': '$id',                     // Transaction ID. Required.
//    'affiliation': '$affiliation',   // Affiliation or store name.
//    'revenue': '$revenue',               // Grand Total.
//    'shipping': '$shipping',                  // Shipping.
//    'tax': '$tax'                     // Tax.
//}); 		
//	    
//HTML;
	
	
    }
        
    
}