@@ -82,6 +82,7 @@ public function getPageName()
8282 * @link https://developers.google.com/analytics/devguides/collection/analyticsjs/method-reference#set
8383 * @link https://developers.google.com/analytics/devguides/collection/analyticsjs/method-reference#gaObjectMethods
8484 * @deprecated 100.2.0 please use getPageTrackingData method
85+ * @see getPageTrackingData method
8586 */
8687 public function getPageTrackingCode ($ accountId )
8788 {
@@ -103,6 +104,7 @@ public function getPageTrackingCode($accountId)
103104 *
104105 * @return string|void
105106 * @deprecated 100.2.0 please use getOrdersTrackingData method
107+ * @see getOrdersTrackingData method
106108 */
107109 public function getOrdersTrackingCode ()
108110 {
@@ -124,12 +126,12 @@ public function getOrdersTrackingCode()
124126 "ga('ec:addProduct', {
125127 'id': '%s',
126128 'name': '%s',
127- 'price': '%f' ,
129+ 'price': %.2f ,
128130 'quantity': %d
129131 }); " ,
130132 $ this ->escapeJsQuote ($ item ->getSku ()),
131133 $ this ->escapeJsQuote ($ item ->getName ()),
132- $ item ->getPrice (),
134+ round ( $ item ->getPrice (), 2 ),
133135 $ item ->getQtyOrdered ()
134136 );
135137 }
@@ -138,15 +140,15 @@ public function getOrdersTrackingCode()
138140 "ga('ec:setAction', 'purchase', {
139141 'id': '%s',
140142 'affiliation': '%s',
141- 'revenue': '%f' ,
142- 'tax': '%f' ,
143- 'shipping': '%f'
143+ 'revenue': %.2f ,
144+ 'tax': %.2f ,
145+ 'shipping': %.2f
144146 }); " ,
145147 $ order ->getIncrementId (),
146148 $ this ->escapeJsQuote ($ this ->_storeManager ->getStore ()->getFrontendName ()),
147- $ order ->getGrandTotal (),
148- $ order ->getTaxAmount (),
149- $ order ->getShippingAmount ()
149+ round ( $ order ->getGrandTotal (), 2 ),
150+ round ( $ order ->getTaxAmount (), 2 ),
151+ round ( $ order ->getShippingAmount (), 2 )
150152 );
151153
152154 $ result [] = "ga('send', 'pageview'); " ;
@@ -235,16 +237,16 @@ public function getOrdersTrackingData()
235237 $ result ['products ' ][] = [
236238 'id ' => $ this ->escapeJsQuote ($ item ->getSku ()),
237239 'name ' => $ this ->escapeJsQuote ($ item ->getName ()),
238- 'price ' => ( float )$ item ->getPrice (),
240+ 'price ' => round (( float )$ item ->getPrice (), 2 ),
239241 'quantity ' => (int )$ item ->getQtyOrdered (),
240242 ];
241243 }
242244 $ result ['orders ' ][] = [
243245 'id ' => $ order ->getIncrementId (),
244246 'affiliation ' => $ this ->escapeJsQuote ($ this ->_storeManager ->getStore ()->getFrontendName ()),
245- 'revenue ' => ( float )$ order ->getGrandTotal (),
246- 'tax ' => ( float )$ order ->getTaxAmount (),
247- 'shipping ' => ( float )$ order ->getShippingAmount (),
247+ 'revenue ' => round (( float )$ order ->getGrandTotal (), 2 ),
248+ 'tax ' => round (( float )$ order ->getTaxAmount (), 2 ),
249+ 'shipping ' => round (( float )$ order ->getShippingAmount (), 2 )
248250 ];
249251 $ result ['currency ' ] = $ order ->getOrderCurrencyCode ();
250252 }
0 commit comments