add paymentType to puchase-event
extend Basket-Model to add method to get payment-desc
Cette révision appartient à :
Parent
fec30b1109
révision
d2ef663dd3
@ -4,8 +4,8 @@
|
||||
<script>
|
||||
dataLayer.push({"event": null, "eventLabel": null, "ecommerce": null}); /* Clear the previous ecommerce object. */
|
||||
[{assign var="gtmOrder" value=$oView->getOrder()}]
|
||||
[{assign var="gtmBasket" value=$oView->getBasket()}]
|
||||
[{assign var="gtmArticles" value=$gtmOrder->getOrderArticles()}]
|
||||
[{assign var="gtmOrderPayment" value=$gtmOrder->getPayment()}]
|
||||
[{assign var="gtmOrderVouchers" value=$gtmOrder->getVoucherNrList()}]
|
||||
|
||||
dataLayer.push({
|
||||
@ -18,8 +18,8 @@
|
||||
'tax': [{math equation="x+y" x=$gtmOrder->getFieldData("oxartvatprice1") y=$gtmOrder->getFieldData("oxartvatprice2") }],
|
||||
'shipping': [{$gtmOrder->getFieldData("oxdelcost")}],
|
||||
'currency': '[{$gtmOrder->getFieldData('oxcurrency')}]',
|
||||
'coupon': '[{foreach from=$gtmOrderVouchers item="gtmOrderVoucher" name="gtmOrderVoucherIteration"}][{$gtmOrderVoucher}][{if !$smarty.foreach.gtmOrderVoucherIteration.last}], [{/if}][{/foreach}]',
|
||||
'paymentType': '[{*$gtmOrderPayment->getFieldData('oxdesc')*}]',
|
||||
'coupon': '[{foreach from=$gtmOrderVouchers item="gtmOrderVoucher" name="gtmOrderVoucherIteration"}][{$gtmOrderVoucher}][{if !$smarty.foreach.gtmOrderVoucherIteration.last}], [{/if}][{/foreach}]',
|
||||
'paymentType': '[{$gtmBasket->getPaymentOnPaymentId()}]',
|
||||
'items': [
|
||||
[{foreach from=$gtmArticles item="gtmBasketItem" name="gtmArticles"}]
|
||||
[{assign var="gtmPurchaseItemPriceObject" value=$gtmBasketItem->getPrice()}]
|
||||
|
@ -19,4 +19,5 @@ namespace D3\GoogleAnalytics4\Modules\Core{
|
||||
|
||||
namespace D3\GoogleAnalytics4\Modules\Application\Model{
|
||||
class Category_parent extends \OxidEsales\Eshop\Application\Model\Category {}
|
||||
class Basket_parent extends \OxidEsales\Eshop\Application\Model\Basket {}
|
||||
}
|
23
Modules/Application/Model/Basket.php
Fichier normal
23
Modules/Application/Model/Basket.php
Fichier normal
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace D3\GoogleAnalytics4\Modules\Application\Model;
|
||||
|
||||
use OxidEsales\Eshop\Application\Model\Payment;
|
||||
|
||||
class Basket extends Basket_parent
|
||||
{
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function getPaymentOnPaymentId() :string
|
||||
{
|
||||
if ($this->getPaymentId()){
|
||||
$oPayment = oxNew(Payment::class);
|
||||
if ($oPayment->load($this->getPaymentId())){
|
||||
return $oPayment->getFieldData('oxdesc');
|
||||
}
|
||||
}
|
||||
|
||||
return "couldn't load payment!";
|
||||
}
|
||||
}
|
@ -1,7 +1,9 @@
|
||||
<?php
|
||||
|
||||
use D3\GoogleAnalytics4\Modules\Application\Model\Basket as Basket;
|
||||
use D3\GoogleAnalytics4\Modules\Application\Model\Category as Category;
|
||||
use D3\GoogleAnalytics4\Modules\Core\ViewConfig;
|
||||
use OxidEsales\Eshop\Application\Model\Basket as OEBasket;
|
||||
use OxidEsales\Eshop\Application\Model\Category as OECategory;
|
||||
use OxidEsales\Eshop\Core\ViewConfig as OEViewConfig;
|
||||
|
||||
@ -26,7 +28,8 @@ $aModule = [
|
||||
'url' => 'https://www.oxidmodule.com/',
|
||||
'extend' => [
|
||||
OEViewConfig::class => ViewConfig::class,
|
||||
OECategory::class => Category::class
|
||||
OECategory::class => Category::class,
|
||||
OEBasket::class => Basket::class
|
||||
],
|
||||
'templates' => [
|
||||
// GA4 events
|
||||
|
Chargement…
Référencer dans un nouveau ticket
Block a user