-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from Promatur/ecommerce
eCommerce Tracking
- Loading branch information
Showing
57 changed files
with
3,966 additions
and
546 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
<?php | ||
|
||
namespace ScAnalytics\Core\ECommerce; | ||
|
||
use Money\Money; | ||
|
||
/** | ||
* Class Product. Represents a product to be sold. | ||
* | ||
* @author Jan-Nicklas Adler | ||
* @version 1.0.0 | ||
* @license http://www.gnu.org/licenses/lgpl.html LGPL v3 or later | ||
* @copyright All Rights Reserved. | ||
*/ | ||
class Product | ||
{ | ||
|
||
/** | ||
* @var string ID or SKU | ||
*/ | ||
private $id; | ||
|
||
/** | ||
* @var string|null A unique key for the product | ||
*/ | ||
private $key; | ||
|
||
/** | ||
* @var string|null The name of the product | ||
*/ | ||
private $name; | ||
|
||
/** | ||
* @var string|null A category for the product | ||
*/ | ||
private $category; | ||
|
||
/** | ||
* @var string|null A variant for the product | ||
*/ | ||
private $variant; | ||
|
||
/** | ||
* @var string|null A brand for the product | ||
*/ | ||
private $brand; | ||
|
||
/** | ||
* @var Money|null The original price of the product | ||
*/ | ||
private $price; | ||
|
||
/** | ||
* @var Money|null A final price, after discounts and taxes | ||
*/ | ||
private $finalPrice; | ||
|
||
/** | ||
* @var int|null The quantity of the product in the cart or checkout process | ||
*/ | ||
private $quantity; | ||
|
||
/** | ||
* @var string|null A coupon code applied to the product | ||
*/ | ||
private $coupon; | ||
|
||
/** | ||
* @param string $id ID or SKU | ||
* @param Money|null $price The original price of the product | ||
* @param Money|null $finalPrice A final price, after discounts and taxes | ||
* @param string|null $key A unique key for the product | ||
* @param string|null $name The name of the product | ||
* @param string|null $category A category for the product | ||
* @param string|null $variant A variant for the product | ||
* @param string|null $brand A brand for the product | ||
* @param int|null $quantity The quantity of the product in the cart or checkout process | ||
* @param string|null $coupon A coupon code applied to the product | ||
*/ | ||
public function __construct(string $id, ?Money $price = null, ?Money $finalPrice = null, ?string $key = null, ?string $name = null, ?string $category = null, ?string $variant = null, ?string $brand = null, ?int $quantity = null, ?string $coupon = null) | ||
{ | ||
$this->id = $id; | ||
$this->key = $key; | ||
$this->name = $name; | ||
$this->category = $category; | ||
$this->variant = $variant; | ||
$this->brand = $brand; | ||
$this->price = $price; | ||
$this->finalPrice = $finalPrice; | ||
$this->quantity = $quantity; | ||
$this->coupon = $coupon; | ||
} | ||
|
||
|
||
/** | ||
* @return string ID or SKU | ||
*/ | ||
public function getId(): string | ||
{ | ||
return $this->id; | ||
} | ||
|
||
/** | ||
* @return string|null A unique key for the product | ||
*/ | ||
public function getKey(): ?string | ||
{ | ||
return $this->key; | ||
} | ||
|
||
/** | ||
* @return string|null The name of the product | ||
*/ | ||
public function getName(): ?string | ||
{ | ||
return $this->name; | ||
} | ||
|
||
/** | ||
* @return string|null A category for the product | ||
*/ | ||
public function getCategory(): ?string | ||
{ | ||
return $this->category; | ||
} | ||
|
||
/** | ||
* @return string|null A variant for the product | ||
*/ | ||
public function getVariant(): ?string | ||
{ | ||
return $this->variant; | ||
} | ||
|
||
/** | ||
* @return string|null A brand for the product | ||
*/ | ||
public function getBrand(): ?string | ||
{ | ||
return $this->brand; | ||
} | ||
|
||
/** | ||
* @return Money|null The original price of the product | ||
*/ | ||
public function getPrice(): ?Money | ||
{ | ||
return $this->price; | ||
} | ||
|
||
/** | ||
* @return Money|null A final price, after discounts and taxes | ||
*/ | ||
public function getFinalPrice(): ?Money | ||
{ | ||
return $this->finalPrice; | ||
} | ||
|
||
/** | ||
* @return int|null The quantity of the product in the cart or checkout process | ||
*/ | ||
public function getQuantity(): ?int | ||
{ | ||
return $this->quantity; | ||
} | ||
|
||
/** | ||
* @return string|null A coupon code applied to the product | ||
*/ | ||
public function getCoupon(): ?string | ||
{ | ||
return $this->coupon; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?php | ||
|
||
namespace ScAnalytics\Core\ECommerce; | ||
|
||
use Money\Money; | ||
|
||
/** | ||
* Class ProductImpression. Represents information about a product that has been viewed. | ||
* | ||
* @author Jan-Nicklas Adler | ||
* @version 1.0.0 | ||
* @license http://www.gnu.org/licenses/lgpl.html LGPL v3 or later | ||
* @copyright All Rights Reserved. | ||
*/ | ||
class ProductImpression | ||
{ | ||
|
||
/** | ||
* @var int The position of the product in the list | ||
*/ | ||
private $position; | ||
|
||
/** | ||
* @var Product The product that has been viewed | ||
*/ | ||
private $product; | ||
|
||
/** | ||
* @var array<int, string> A product-level custom dimension | ||
*/ | ||
private $dimensions; | ||
|
||
/** | ||
* @var array<int, int> A product-level custom metric | ||
*/ | ||
private $metrics; | ||
|
||
/** | ||
* @param int $position The position of the product in the list | ||
* @param Product $product The product that has been viewed | ||
* @param array<int, string> $dimensions A product-level custom dimension | ||
* @param array<int, int> $metrics A product-level custom metric | ||
*/ | ||
public function __construct(int $position, Product $product, array $dimensions = [], array $metrics = []) | ||
{ | ||
$this->position = $position; | ||
$this->product = $product; | ||
$this->dimensions = $dimensions; | ||
$this->metrics = $metrics; | ||
} | ||
|
||
/** | ||
* @return int The position of the product in the list | ||
*/ | ||
public function getPosition(): int | ||
{ | ||
return $this->position; | ||
} | ||
|
||
/** | ||
* @return Product The product that has been viewed | ||
*/ | ||
public function getProduct(): Product | ||
{ | ||
return $this->product; | ||
} | ||
|
||
/** | ||
* @return array<int, string> A product-level custom dimension | ||
*/ | ||
public function getDimensions(): array | ||
{ | ||
return $this->dimensions; | ||
} | ||
|
||
/** | ||
* @return array<int, int> The product-level custom metric | ||
*/ | ||
public function getMetrics(): array | ||
{ | ||
return $this->metrics; | ||
} | ||
|
||
} |
Oops, something went wrong.