first commit
This commit is contained in:
551
modules/psxmarketingwithgoogle/classes/DTO/Carrier.php
Normal file
551
modules/psxmarketingwithgoogle/classes/DTO/Carrier.php
Normal file
@@ -0,0 +1,551 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
|
||||
namespace PrestaShop\Module\PsxMarketingWithGoogle\DTO;
|
||||
|
||||
use JsonSerializable;
|
||||
|
||||
class Carrier implements JsonSerializable
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $collection = 'carriers';
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $idCarrier;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $idReference;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $taxesRatesGroupId;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $url;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $active;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $deleted;
|
||||
|
||||
/**
|
||||
* @var float
|
||||
*/
|
||||
private $shippingHandling = 0;
|
||||
|
||||
/**
|
||||
* @var float
|
||||
*/
|
||||
private $freeShippingStartsAtPrice;
|
||||
|
||||
/**
|
||||
* @var float
|
||||
*/
|
||||
private $freeShippingStartsAtWeight;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $disableCarrierWhenOutOfRange;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $isModule;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $isFree;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $shippingExternal;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $needRange;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $externalModuleName;
|
||||
|
||||
/**
|
||||
* @var float
|
||||
*/
|
||||
private $maxWidth;
|
||||
|
||||
/**
|
||||
* @var float
|
||||
*/
|
||||
private $maxHeight;
|
||||
|
||||
/**
|
||||
* @var float
|
||||
*/
|
||||
private $maxDepth;
|
||||
|
||||
/**
|
||||
* @var float
|
||||
*/
|
||||
private $maxWeight;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $grade;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $delay;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $currency;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $weightUnit;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $countryIsoCodes;
|
||||
|
||||
/**
|
||||
* @var CarrierDetail[]
|
||||
*/
|
||||
private $carrierDetails = [];
|
||||
|
||||
/**
|
||||
* @var CarrierTax[]
|
||||
*/
|
||||
private $carrierTaxes = [];
|
||||
|
||||
public function getCollection(): string
|
||||
{
|
||||
return $this->collection;
|
||||
}
|
||||
|
||||
public function setCollection(string $collection): Carrier
|
||||
{
|
||||
$this->collection = $collection;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getIdCarrier(): int
|
||||
{
|
||||
return $this->idCarrier;
|
||||
}
|
||||
|
||||
public function setIdCarrier(int $idCarrier): Carrier
|
||||
{
|
||||
$this->idCarrier = $idCarrier;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getIdReference(): int
|
||||
{
|
||||
return $this->idReference;
|
||||
}
|
||||
|
||||
public function setIdReference(int $idReference): Carrier
|
||||
{
|
||||
$this->idReference = $idReference;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTaxesRatesGroupId(): int
|
||||
{
|
||||
return $this->taxesRatesGroupId;
|
||||
}
|
||||
|
||||
public function setTaxesRatesGroupId(int $taxesRatesGroupId): Carrier
|
||||
{
|
||||
$this->taxesRatesGroupId = $taxesRatesGroupId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName(string $name): Carrier
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUrl(): string
|
||||
{
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
public function setUrl(string $url): Carrier
|
||||
{
|
||||
$this->url = $url;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isActive(): bool
|
||||
{
|
||||
return $this->active;
|
||||
}
|
||||
|
||||
public function setActive(bool $active): Carrier
|
||||
{
|
||||
$this->active = $active;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isDeleted(): bool
|
||||
{
|
||||
return $this->deleted;
|
||||
}
|
||||
|
||||
public function setDeleted(bool $deleted): Carrier
|
||||
{
|
||||
$this->deleted = $deleted;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getShippingHandling(): float
|
||||
{
|
||||
return $this->shippingHandling;
|
||||
}
|
||||
|
||||
public function setShippingHandling(float $shippingHandling): Carrier
|
||||
{
|
||||
$this->shippingHandling = $shippingHandling;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getFreeShippingStartsAtPrice(): float
|
||||
{
|
||||
return $this->freeShippingStartsAtPrice;
|
||||
}
|
||||
|
||||
public function setFreeShippingStartsAtPrice(float $freeShippingStartsAtPrice): Carrier
|
||||
{
|
||||
$this->freeShippingStartsAtPrice = $freeShippingStartsAtPrice;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getFreeShippingStartsAtWeight(): float
|
||||
{
|
||||
return $this->freeShippingStartsAtWeight;
|
||||
}
|
||||
|
||||
public function setFreeShippingStartsAtWeight(float $freeShippingStartsAtWeight): Carrier
|
||||
{
|
||||
$this->freeShippingStartsAtWeight = $freeShippingStartsAtWeight;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isDisableCarrierWhenOutOfRange(): bool
|
||||
{
|
||||
return $this->disableCarrierWhenOutOfRange;
|
||||
}
|
||||
|
||||
public function setDisableCarrierWhenOutOfRange(bool $disableCarrierWhenOutOfRange): Carrier
|
||||
{
|
||||
$this->disableCarrierWhenOutOfRange = $disableCarrierWhenOutOfRange;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isModule(): bool
|
||||
{
|
||||
return $this->isModule;
|
||||
}
|
||||
|
||||
public function setIsModule(bool $isModule): Carrier
|
||||
{
|
||||
$this->isModule = $isModule;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isFree(): bool
|
||||
{
|
||||
return $this->isFree;
|
||||
}
|
||||
|
||||
public function setIsFree(bool $isFree): Carrier
|
||||
{
|
||||
$this->isFree = $isFree;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isShippingExternal(): bool
|
||||
{
|
||||
return $this->shippingExternal;
|
||||
}
|
||||
|
||||
public function setShippingExternal(bool $shippingExternal): Carrier
|
||||
{
|
||||
$this->shippingExternal = $shippingExternal;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isNeedRange(): bool
|
||||
{
|
||||
return $this->needRange;
|
||||
}
|
||||
|
||||
public function setNeedRange(bool $needRange): Carrier
|
||||
{
|
||||
$this->needRange = $needRange;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getExternalModuleName(): string
|
||||
{
|
||||
return $this->externalModuleName;
|
||||
}
|
||||
|
||||
public function setExternalModuleName(string $externalModuleName): Carrier
|
||||
{
|
||||
$this->externalModuleName = $externalModuleName;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getMaxWidth(): float
|
||||
{
|
||||
return $this->maxWidth;
|
||||
}
|
||||
|
||||
public function setMaxWidth(float $maxWidth): Carrier
|
||||
{
|
||||
$this->maxWidth = $maxWidth;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getMaxHeight(): float
|
||||
{
|
||||
return $this->maxHeight;
|
||||
}
|
||||
|
||||
public function setMaxHeight(float $maxHeight): Carrier
|
||||
{
|
||||
$this->maxHeight = $maxHeight;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getMaxDepth(): float
|
||||
{
|
||||
return $this->maxDepth;
|
||||
}
|
||||
|
||||
public function setMaxDepth(float $maxDepth): Carrier
|
||||
{
|
||||
$this->maxDepth = $maxDepth;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getMaxWeight(): float
|
||||
{
|
||||
return $this->maxWeight;
|
||||
}
|
||||
|
||||
public function setMaxWeight(float $maxWeight): Carrier
|
||||
{
|
||||
$this->maxWeight = $maxWeight;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getGrade(): int
|
||||
{
|
||||
return $this->grade;
|
||||
}
|
||||
|
||||
public function setGrade(int $grade): Carrier
|
||||
{
|
||||
$this->grade = $grade;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDelay(): string
|
||||
{
|
||||
return $this->delay;
|
||||
}
|
||||
|
||||
public function setDelay(string $delay): Carrier
|
||||
{
|
||||
$this->delay = $delay;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCurrency(): string
|
||||
{
|
||||
return $this->currency;
|
||||
}
|
||||
|
||||
public function setCurrency(string $currency): Carrier
|
||||
{
|
||||
$this->currency = $currency;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getWeightUnit(): string
|
||||
{
|
||||
return $this->weightUnit;
|
||||
}
|
||||
|
||||
public function setWeightUnit(string $weightUnit): Carrier
|
||||
{
|
||||
$this->weightUnit = $weightUnit;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCountryIsoCodes(): array
|
||||
{
|
||||
return $this->countryIsoCodes;
|
||||
}
|
||||
|
||||
public function setCountryIsoCodes(array $countryIsoCodes): Carrier
|
||||
{
|
||||
$this->countryIsoCodes = $countryIsoCodes;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCarrierDetails(): array
|
||||
{
|
||||
return $this->carrierDetails;
|
||||
}
|
||||
|
||||
public function setCarrierDetails(array $carrierDetails): Carrier
|
||||
{
|
||||
$this->carrierDetails = $carrierDetails;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCarrierTaxes(): array
|
||||
{
|
||||
return $this->carrierTaxes;
|
||||
}
|
||||
|
||||
public function setCarrierTaxes(array $carrierTaxes): Carrier
|
||||
{
|
||||
$this->carrierTaxes = $carrierTaxes;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function jsonSerialize()
|
||||
{
|
||||
$return = [];
|
||||
|
||||
$return[] = [
|
||||
'collection' => $this->getCollection(),
|
||||
'id' => (string) $this->getIdReference(),
|
||||
'properties' => [
|
||||
'id_carrier' => (string) $this->getIdCarrier(),
|
||||
'id_reference' => (string) $this->getIdReference(),
|
||||
'name' => (string) $this->getName(),
|
||||
'carrier_taxes_rates_group_id' => (string) $this->getTaxesRatesGroupId(),
|
||||
'url' => (string) $this->getUrl(),
|
||||
'active' => (bool) $this->isActive(),
|
||||
'deleted' => (bool) $this->isDeleted(),
|
||||
'shipping_handling' => (float) $this->getShippingHandling(),
|
||||
'free_shipping_starts_at_price' => (float) $this->getFreeShippingStartsAtPrice(),
|
||||
'free_shipping_starts_at_weight' => (float) $this->getFreeShippingStartsAtWeight(),
|
||||
'disable_carrier_when_out_of_range' => (bool) $this->isDisableCarrierWhenOutOfRange(),
|
||||
'is_module' => (bool) $this->isModule(),
|
||||
'is_free' => (bool) $this->isFree(),
|
||||
'shipping_external' => (bool) $this->isShippingExternal(),
|
||||
'need_range' => (bool) $this->isNeedRange(),
|
||||
'external_module_name' => (string) $this->getExternalModuleName(),
|
||||
'max_width' => (float) $this->getMaxWidth(),
|
||||
'max_height' => (float) $this->getMaxHeight(),
|
||||
'max_depth' => (float) $this->getMaxDepth(),
|
||||
'max_weight' => (float) $this->getMaxWeight(),
|
||||
'grade' => (int) $this->getGrade(),
|
||||
'delay' => (string) $this->getDelay(),
|
||||
'currency' => (string) $this->getCurrency(),
|
||||
'weight_unit' => (string) $this->getWeightUnit(),
|
||||
'country_ids' => (string) implode(',', $this->getCountryIsoCodes()),
|
||||
],
|
||||
];
|
||||
|
||||
$carrierDetails = [];
|
||||
foreach ($this->getCarrierDetails() as $carrierDetail) {
|
||||
$carrierDetails[] = $carrierDetail->jsonSerialize();
|
||||
}
|
||||
|
||||
$carrierTaxRates = [];
|
||||
foreach ($this->getCarrierTaxes() as $carrierTax) {
|
||||
$carrierTaxRates[] = $carrierTax->jsonSerialize();
|
||||
}
|
||||
|
||||
return array_merge($return, $carrierDetails, $carrierTaxRates);
|
||||
}
|
||||
}
|
||||
239
modules/psxmarketingwithgoogle/classes/DTO/CarrierDetail.php
Normal file
239
modules/psxmarketingwithgoogle/classes/DTO/CarrierDetail.php
Normal file
@@ -0,0 +1,239 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
|
||||
namespace PrestaShop\Module\PsxMarketingWithGoogle\DTO;
|
||||
|
||||
use JsonSerializable;
|
||||
|
||||
class CarrierDetail implements JsonSerializable
|
||||
{
|
||||
public const RANGE_BY_WEIGHT = 0;
|
||||
|
||||
public const RANGE_BY_PRICE = 1;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $collection = 'carrier_details';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $shippingMethod;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $carrierReference;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $carrierDetailId;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $zoneId;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $rangeId;
|
||||
|
||||
/**
|
||||
* @var float
|
||||
*/
|
||||
private $delimiter1;
|
||||
|
||||
/**
|
||||
* @var float
|
||||
*/
|
||||
private $delimiter2;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $countryIsoCodes;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $stateIsoCodes;
|
||||
|
||||
/**
|
||||
* @var float
|
||||
*/
|
||||
private $price;
|
||||
|
||||
public function getCollection(): string
|
||||
{
|
||||
return $this->collection;
|
||||
}
|
||||
|
||||
public function setCollection(string $collection): CarrierDetail
|
||||
{
|
||||
$this->collection = $collection;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getShippingMethod(): string
|
||||
{
|
||||
return $this->shippingMethod;
|
||||
}
|
||||
|
||||
public function setShippingMethod(string $shippingMethod): CarrierDetail
|
||||
{
|
||||
$this->shippingMethod = $shippingMethod;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCarrierReference(): int
|
||||
{
|
||||
return $this->carrierReference;
|
||||
}
|
||||
|
||||
public function setCarrierReference(int $carrierReference): CarrierDetail
|
||||
{
|
||||
$this->carrierReference = $carrierReference;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCarrierDetailId(): int
|
||||
{
|
||||
return $this->carrierDetailId;
|
||||
}
|
||||
|
||||
public function setCarrierDetailId(int $carrierDetailId): CarrierDetail
|
||||
{
|
||||
$this->carrierDetailId = $carrierDetailId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getZoneId(): int
|
||||
{
|
||||
return $this->zoneId;
|
||||
}
|
||||
|
||||
public function setZoneId(int $zoneId): CarrierDetail
|
||||
{
|
||||
$this->zoneId = $zoneId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getRangeId(): int
|
||||
{
|
||||
return $this->rangeId;
|
||||
}
|
||||
|
||||
public function setRangeId(int $rangeId): CarrierDetail
|
||||
{
|
||||
$this->rangeId = $rangeId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDelimiter1(): float
|
||||
{
|
||||
return $this->delimiter1;
|
||||
}
|
||||
|
||||
public function setDelimiter1(float $delimiter1): CarrierDetail
|
||||
{
|
||||
$this->delimiter1 = $delimiter1;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDelimiter2(): float
|
||||
{
|
||||
return $this->delimiter2;
|
||||
}
|
||||
|
||||
public function setDelimiter2(float $delimiter2): CarrierDetail
|
||||
{
|
||||
$this->delimiter2 = $delimiter2;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCountryIsoCodes(): array
|
||||
{
|
||||
return $this->countryIsoCodes;
|
||||
}
|
||||
|
||||
public function setCountryIsoCodes(array $countryIsoCodes): CarrierDetail
|
||||
{
|
||||
$this->countryIsoCodes = $countryIsoCodes;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getStateIsoCodes(): array
|
||||
{
|
||||
return $this->stateIsoCodes;
|
||||
}
|
||||
|
||||
public function setStateIsoCodes(array $stateIsoCodes): CarrierDetail
|
||||
{
|
||||
$this->stateIsoCodes = $stateIsoCodes;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPrice(): float
|
||||
{
|
||||
return $this->price;
|
||||
}
|
||||
|
||||
public function setPrice(float $price): CarrierDetail
|
||||
{
|
||||
$this->price = $price;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function jsonSerialize()
|
||||
{
|
||||
$countryIds = implode(',', $this->getCountryIsoCodes());
|
||||
$stateIds = implode(',', $this->getStateIsoCodes());
|
||||
$shippingMethod = $this->getShippingMethod() === 'range_weight' ? self::RANGE_BY_WEIGHT : self::RANGE_BY_PRICE;
|
||||
|
||||
return [
|
||||
'collection' => $this->getCollection(),
|
||||
'id' => $this->getCarrierReference() . '-' . $this->getZoneId() . '-' . $shippingMethod . '-' . $this->getRangeId(),
|
||||
'properties' => [
|
||||
'id_reference' => (string) $this->getCarrierReference(),
|
||||
'id_carrier_detail' => (string) $this->getCarrierDetailId(),
|
||||
'shipping_method' => (string) $this->getShippingMethod(),
|
||||
'delimiter1' => (float) $this->getDelimiter1(),
|
||||
'delimiter2' => (float) $this->getDelimiter2(),
|
||||
'country_ids' => (string) $countryIds,
|
||||
'state_ids' => (string) $stateIds,
|
||||
'price' => (float) $this->getPrice(),
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
142
modules/psxmarketingwithgoogle/classes/DTO/CarrierTax.php
Normal file
142
modules/psxmarketingwithgoogle/classes/DTO/CarrierTax.php
Normal file
@@ -0,0 +1,142 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
|
||||
namespace PrestaShop\Module\PsxMarketingWithGoogle\DTO;
|
||||
|
||||
use JsonSerializable;
|
||||
|
||||
class CarrierTax implements JsonSerializable
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $collection = 'carrier_taxes';
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $carrierReference;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $taxRulesGroupId;
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $countryIsoCode;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $stateIsoCodes;
|
||||
|
||||
/**
|
||||
* @var float
|
||||
*/
|
||||
private $taxRate;
|
||||
|
||||
public function getCollection(): string
|
||||
{
|
||||
return $this->collection;
|
||||
}
|
||||
|
||||
public function setCollection(string $collection): CarrierTax
|
||||
{
|
||||
$this->collection = $collection;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCarrierReference(): int
|
||||
{
|
||||
return $this->carrierReference;
|
||||
}
|
||||
|
||||
public function setCarrierReference(int $carrierReference): CarrierTax
|
||||
{
|
||||
$this->carrierReference = $carrierReference;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTaxRulesGroupId(): int
|
||||
{
|
||||
return $this->taxRulesGroupId;
|
||||
}
|
||||
|
||||
public function setTaxRulesGroupId(int $taxRulesGroupId): CarrierTax
|
||||
{
|
||||
$this->taxRulesGroupId = $taxRulesGroupId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCountryIsoCode(): string
|
||||
{
|
||||
return $this->countryIsoCode;
|
||||
}
|
||||
|
||||
public function setCountryIsoCode(string $countryIsoCode): CarrierTax
|
||||
{
|
||||
$this->countryIsoCode = $countryIsoCode;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getStateIsoCodes(): string
|
||||
{
|
||||
return $this->stateIsoCodes;
|
||||
}
|
||||
|
||||
public function setStateIsoCodes(string $stateIsoCodes): CarrierTax
|
||||
{
|
||||
$this->stateIsoCodes = $stateIsoCodes;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTaxRate(): float
|
||||
{
|
||||
return $this->taxRate;
|
||||
}
|
||||
|
||||
public function setTaxRate(float $taxRate): CarrierTax
|
||||
{
|
||||
$this->taxRate = $taxRate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return [
|
||||
'collection' => $this->getCollection(),
|
||||
'id' => $this->getCarrierReference(),
|
||||
'properties' => [
|
||||
'id_reference' => (string) $this->getCarrierReference(),
|
||||
'id_carrier_tax' => (string) $this->getTaxRulesGroupId(),
|
||||
'country_id' => (string) $this->getCountryIsoCode(),
|
||||
'state_ids' => (string) $this->getStateIsoCodes(),
|
||||
'tax_rate' => (float) $this->getTaxRate(),
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
|
||||
namespace PrestaShop\Module\PsxMarketingWithGoogle\DTO;
|
||||
|
||||
use JsonSerializable;
|
||||
|
||||
/**
|
||||
* @see https://developers.google.com/analytics/devguides/collection/gtagjs/enhanced-ecommerce#action-data
|
||||
*/
|
||||
class ConversionEventData implements JsonSerializable
|
||||
{
|
||||
/**
|
||||
* Value (i.e. revenue) associated with the event.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $value;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $currency;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $sendTo;
|
||||
|
||||
/**
|
||||
* The transaction ID (e.g. T1234).
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $transactionId;
|
||||
|
||||
public function jsonSerialize(): array
|
||||
{
|
||||
$eventData = [
|
||||
'send_to' => $this->sendTo,
|
||||
'value' => $this->value,
|
||||
'currency' => $this->currency,
|
||||
];
|
||||
if ($this->transactionId) {
|
||||
$eventData['transaction_id'] = $this->transactionId;
|
||||
}
|
||||
|
||||
return $eventData;
|
||||
}
|
||||
|
||||
public function setTransactionId(string $transactionId)
|
||||
{
|
||||
$this->transactionId = $transactionId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set value (i.e. revenue) associated with the event.
|
||||
*
|
||||
* @param string|null $value Value (i.e. revenue) associated with the event.
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setValue($value)
|
||||
{
|
||||
$this->value = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $currency
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setCurrency($currency)
|
||||
{
|
||||
$this->currency = $currency;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $sendTo
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setSendTo($sendTo)
|
||||
{
|
||||
$this->sendTo = $sendTo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
|
||||
namespace PrestaShop\Module\PsxMarketingWithGoogle\DTO\Remarketing;
|
||||
|
||||
use JsonSerializable;
|
||||
|
||||
class ProductData implements JsonSerializable
|
||||
{
|
||||
/**
|
||||
* The product ID or SKU (e.g. P67890).
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
* The price of a product (e.g. 29.20).
|
||||
* Kept as a float
|
||||
*
|
||||
* @var float|null
|
||||
*/
|
||||
protected $price;
|
||||
|
||||
/**
|
||||
* The quantity of a product (e.g. 2).
|
||||
*
|
||||
* @var int|null
|
||||
*/
|
||||
protected $quantity;
|
||||
|
||||
public function jsonSerialize(): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'quantity' => $this->quantity,
|
||||
'price' => $this->price,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the product ID or SKU (e.g. P67890).
|
||||
*
|
||||
* @param string $id The product ID or SKU (e.g. P67890).
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setId(string $id)
|
||||
{
|
||||
$this->id = $id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set kept as a string to avoid float issues
|
||||
*
|
||||
* @param float|null $price Kept as a string to avoid float issues
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setPrice($price)
|
||||
{
|
||||
$this->price = $price;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the quantity of a product (e.g. 2).
|
||||
*
|
||||
* @param int|null $quantity The quantity of a product (e.g. 2).
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setQuantity($quantity)
|
||||
{
|
||||
$this->quantity = $quantity;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright since 2007 PrestaShop SA and Contributors
|
||||
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License version 3.0
|
||||
* that is bundled with this package in the file LICENSE.md.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* https://opensource.org/licenses/AFL-3.0
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* @author PrestaShop SA and Contributors <contact@prestashop.com>
|
||||
* @copyright Since 2007 PrestaShop SA and Contributors
|
||||
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
|
||||
*/
|
||||
|
||||
namespace PrestaShop\Module\PsxMarketingWithGoogle\DTO\Remarketing;
|
||||
|
||||
use PrestaShop\Module\PsxMarketingWithGoogle\DTO\ConversionEventData;
|
||||
|
||||
class PurchaseEventData extends ConversionEventData
|
||||
{
|
||||
/**
|
||||
* @var ProductData[]
|
||||
*/
|
||||
protected $items;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $awMerchandId;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $awFeedCountry;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $awFeedLanguage;
|
||||
|
||||
/**
|
||||
* @var float
|
||||
*/
|
||||
protected $discount;
|
||||
|
||||
public function jsonSerialize(): array
|
||||
{
|
||||
return array_merge(
|
||||
parent::jsonSerialize(),
|
||||
[
|
||||
'items' => $this->items,
|
||||
'discount' => $this->discount,
|
||||
'aw_merchant_id' => $this->awMerchandId,
|
||||
'aw_feed_country' => $this->awFeedCountry,
|
||||
'aw_feed_language' => $this->awFeedLanguage,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of awFeedLanguage
|
||||
*
|
||||
* @param string $awFeedLanguage
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setAwFeedLanguage(string $awFeedLanguage)
|
||||
{
|
||||
$this->awFeedLanguage = $awFeedLanguage;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of awMerchandId
|
||||
*
|
||||
* @param int $awMerchandId
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setAwMerchandId(int $awMerchandId)
|
||||
{
|
||||
$this->awMerchandId = $awMerchandId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of awFeedCountry
|
||||
*
|
||||
* @param string $awFeedCountry
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setAwFeedCountry(string $awFeedCountry)
|
||||
{
|
||||
$this->awFeedCountry = $awFeedCountry;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of items
|
||||
*
|
||||
* @param array $items
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setItems(array $items)
|
||||
{
|
||||
$this->items = $items;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of discount
|
||||
*
|
||||
* @param float $discount
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setDiscount(float $discount)
|
||||
{
|
||||
$this->discount = $discount;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
11
modules/psxmarketingwithgoogle/classes/DTO/index.php
Normal file
11
modules/psxmarketingwithgoogle/classes/DTO/index.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
Reference in New Issue
Block a user