Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
joshine
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
joshine
Commits
cd35381b
Commit
cd35381b
authored
Jul 12, 2023
by
dhn
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'developer' of
http://47.99.244.21:9999/root/joshine
into Branchs_developer
parents
123ef8b9
6ea330bc
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
92 additions
and
44 deletions
+92
-44
app/code/Joshine/GoogleFeed/Helper/GAHelper.php
+28
-0
app/design/frontend/Joshine/breeze/Magento_Checkout/templates/success.phtml
+53
-23
app/design/frontend/Joshine/breeze/Magento_Swatches/web/js/swatch-renderer.js
+11
-21
No files found.
app/code/Joshine/GoogleFeed/Helper/GAHelper.php
0 → 100644
View file @
cd35381b
<?php
namespace
Joshine\GoogleFeed\Helper
;
use
\Magento\Framework\App\Helper\AbstractHelper
;
class
GAHelper
extends
AbstractHelper
{
public
static
function
normalizeAndHash
(
string
$hashAlgorithm
,
string
$value
)
:
string
{
return
hash
(
$hashAlgorithm
,
strtolower
(
trim
(
$value
)));
}
public
static
function
normalizeAndHashEmailAddress
(
string
$hashAlgorithm
,
string
$emailAddress
)
:
string
{
$normalizedEmail
=
strtolower
(
$emailAddress
);
$emailParts
=
explode
(
"@"
,
$normalizedEmail
);
if
(
count
(
$emailParts
)
>
1
&&
preg_match
(
'/^(gmail|googlemail)\.com\s*/'
,
$emailParts
[
1
])
)
{
$emailParts
[
0
]
=
str_replace
(
"."
,
""
,
$emailParts
[
0
]);
$normalizedEmail
=
sprintf
(
'%s@%s'
,
$emailParts
[
0
],
$emailParts
[
1
]);
}
return
self
::
normalizeAndHash
(
$hashAlgorithm
,
$normalizedEmail
);
}
}
\ No newline at end of file
app/design/frontend/Joshine/breeze/Magento_Checkout/templates/success.phtml
View file @
cd35381b
...
...
@@ -4,25 +4,11 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
$lid
=
$block
->
getOrderId
();
$totalPrice
=
0
;
$googleItems
=
[];
if
(
$lid
)
{
$objectManager
=
\Magento\Framework\App\ObjectManager
::
getInstance
();
$order
=
$objectManager
->
create
(
'Magento\Sales\Model\Order'
)
->
loadByIncrementId
(
$lid
);
if
(
$order
)
{
$totalPrice
=
$order
->
getGrandTotal
();
$_itemsTmp
=
$order
->
getAllItems
();
foreach
(
$_itemsTmp
as
$value
)
{
$_item
[
'google_business_vertical'
]
=
'retail'
;
$_item
[
'id'
]
=
$value
->
getSku
();
$googleItems
[]
=
$_item
;
}
}
}
$currency
=
$block
->
getCurrency
();
$tracking_show
=
$block
->
getTrackingEnabled
();
$tracking_conversion
=
$block
->
getTrackingConversion
();
?>
<div
class=
"checkout-success"
>
...
...
@@ -72,18 +58,62 @@ $tracking_conversion = $block->getTrackingConversion();
</style>
<script>
dataLayer
=
[];
dataLayer
.
push
({
'event'
:
'purchase'
,
'value'
:
<?=
$totalPrice
?>
,
'items'
:
<?
=
json_encode
(
$googleItems
,
true
)
?>
});
//window.dataLayer = window.dataLayer ||
[];
//
dataLayer.push({
//
'event': 'purchase',
// 'value':
<?php
//= $totalPrice ?>//
,
// 'items': <?php //
= json_encode($googleItems, true) ?>
//
});
<?
php
if
(
$block
->
getOrderId
()
&&
$tracking_show
>
0
&&
!
empty
(
$tracking_conversion
))
:?>
<?
php
$lid
=
$block
->
getOrderId
();
$totalPrice
=
0
;
$googleItems
=
[];
$objectManager
=
\Magento\Framework\App\ObjectManager
::
getInstance
();
if
(
$lid
)
{
$order
=
$objectManager
->
create
(
'Magento\Sales\Model\Order'
)
->
loadByIncrementId
(
$lid
);
if
(
$order
)
{
$totalPrice
=
$order
->
getGrandTotal
();
$_itemsTmp
=
$order
->
getAllVisibleItems
();
foreach
(
$_itemsTmp
as
$value
)
{
$_item
[
'google_business_vertical'
]
=
'retail'
;
$_item
[
'id'
]
=
$value
->
getSku
();
$_item
[
'item_name'
]
=
$value
->
getName
();
$_item
[
'quantity'
]
=
intval
(
$value
->
getQtyOrdered
());
$googleItems
[]
=
$_item
;
}
$email
=
$order
->
getCustomerEmail
();
}
}
$helper
=
$objectManager
->
get
(
'Joshine\GoogleFeed\Helper\GAHelper'
);
?>
setTimeout
(
function
()
{
<?php
if
(
isset
(
$email
)
&&
!
empty
(
$email
))
:?>
gtag
(
'set'
,
'user_data'
,
{
"sha256_email_address"
:
'<?= $helper::normalizeAndHashEmailAddress("sha256", $email); ?>'
});
<?
php
endif
;
?>
gtag
(
'event'
,
'conversion'
,
{
'send_to'
:
'
<?=
/* @noEscape */
$tracking_conversion
?>
'
,
'value'
:
<?=
/* @noEscape */
$totalPrice
?>
,
'value'
:
'
<?=
/* @noEscape */
$totalPrice
?>
'
,
'currency'
:
'
<?=
/* @noEscape */
$currency
?>
'
,
'transaction_id'
:
'
<?=
/* @noEscape */
$block
->
getOrderId
()
?>
'
});
gtag
(
'event'
,
'purchase'
,
{
"transaction_id"
:
'
<?=
/* @noEscape */
$block
->
getOrderId
()
?>
'
,
"value"
:
'
<?=
/* @noEscape */
$totalPrice
?>
'
,
"currency"
:
'
<?=
/* @noEscape */
$currency
?>
'
,
"items"
:
<?=
json_encode
(
$googleItems
,
true
);
?>
});
},
1500
);
<?php
endif
;
?>
</script>
app/design/frontend/Joshine/breeze/Magento_Swatches/web/js/swatch-renderer.js
View file @
cd35381b
...
...
@@ -543,34 +543,28 @@ define([
if
(
!
this
.
hasOwnProperty
(
'products'
)
||
this
.
products
.
length
<=
0
)
{
attr
+=
' data-option-empty="true"'
;
}
var
selectedStr
=
''
;
if
(
index
==
0
)
{
selectedStr
=
' selected'
;
}
if
(
type
===
0
)
{
// Text
html
+=
'<div class="'
+
optionClass
+
' text'
+
selectedStr
+
'" '
+
attr
+
'>'
+
(
value
?
value
:
label
)
+
html
+=
'<div class="'
+
optionClass
+
' text'
+
'" '
+
attr
+
'>'
+
(
value
?
value
:
label
)
+
'</div>'
;
}
else
if
(
type
===
1
)
{
// Color
html
+=
'<div class="'
+
optionClass
+
' color'
+
selectedStr
+
'" '
+
attr
+
html
+=
'<div class="'
+
optionClass
+
' color'
+
'" '
+
attr
+
' style="background: '
+
value
+
' no-repeat center; background-size: cover;">'
+
''
+
'</div>'
;
}
else
if
(
type
===
2
)
{
// Image
html
+=
'<div class="'
+
optionClass
+
' image'
+
selectedStr
+
'" '
+
attr
+
html
+=
'<div class="'
+
optionClass
+
' image'
+
'" '
+
attr
+
' style="background: url('
+
value
+
') no-repeat center; background-size: cover;width:'
+
swatchImageWidth
+
'px; height:'
+
swatchImageHeight
+
'px">'
+
''
+
'</div>'
;
}
else
if
(
type
===
3
)
{
// Clear
html
+=
'<div class="'
+
optionClass
+
selectedStr
+
'" '
+
attr
+
'></div>'
;
html
+=
'<div class="'
+
optionClass
+
'" '
+
attr
+
'></div>'
;
}
else
{
// Default
html
+=
'<div class="'
+
optionClass
+
selectedStr
+
'" '
+
attr
+
'>'
+
label
+
'</div>'
;
html
+=
'<div class="'
+
optionClass
+
'" '
+
attr
+
'>'
+
label
+
'</div>'
;
}
});
...
...
@@ -800,34 +794,30 @@ define([
if
(
!
this
.
hasOwnProperty
(
'products'
)
||
this
.
products
.
length
<=
0
)
{
attr
+=
' data-option-empty="true"'
;
}
var
selectedStr
=
''
;
if
(
index
==
0
)
{
selectedStr
=
' selected'
;
}
if
(
type
===
0
)
{
// Text
html
+=
'<div class="'
+
optionClass
+
' text'
+
selectedStr
+
'" '
+
attr
+
'>'
+
(
value
?
value
:
label
)
+
html
+=
'<div class="'
+
optionClass
+
' text'
+
'" '
+
attr
+
'>'
+
(
value
?
value
:
label
)
+
'</div>'
;
}
else
if
(
type
===
1
)
{
// Color
html
+=
'<div class="'
+
optionClass
+
' color'
+
selectedStr
+
'" '
+
attr
+
html
+=
'<div class="'
+
optionClass
+
' color'
+
'" '
+
attr
+
' style="background: '
+
value
+
' no-repeat center; background-size: cover;">'
+
''
+
'</div>'
;
}
else
if
(
type
===
2
)
{
// Image
html
+=
'<div class="'
+
optionClass
+
' image'
+
selectedStr
+
'" '
+
attr
+
html
+=
'<div class="'
+
optionClass
+
' image'
+
'" '
+
attr
+
' style="background: url('
+
value
+
') no-repeat center; background-size: cover;width:'
+
swatchImageWidth
+
'px; height:'
+
swatchImageHeight
+
'px">'
+
''
+
'</div>'
;
}
else
if
(
type
===
3
)
{
// Clear
html
+=
'<div class="'
+
optionClass
+
selectedStr
+
'" '
+
attr
+
'></div>'
;
html
+=
'<div class="'
+
optionClass
+
'" '
+
attr
+
'></div>'
;
}
else
{
// Default
html
+=
'<div class="'
+
optionClass
+
selectedStr
+
'" '
+
attr
+
'>'
+
label
+
'</div>'
;
html
+=
'<div class="'
+
optionClass
+
'" '
+
attr
+
'>'
+
label
+
'</div>'
;
}
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment