Skip to content

Instantly share code, notes, and snippets.

View StefsterNYC's full-sized avatar

Stef StefsterNYC

  • Bucks County, PA
  • 00:48 (UTC -04:00)
View GitHub Profile
@StefsterNYC
StefsterNYC / dynamic variable snippet for woocommerce
Last active October 25, 2019 19:28
Specific call for Dynamic Values within WooCommerce
<script>
var dataLayer = window.dataLayer || [];
dataLayer.push({
'event':'Transaction',
'ecommerce': {
'purchase': {
'actionField': {
'id': '<?php echo $order->get_order_number(); ?>', //Required for purchases and refunds.
'revenue': '<?php echo number_format($order->get_subtotal(), 2, ".", ""); ?>', // Total transaction value (incl. tax and shipping)
'tax':'<?php echo number_format($order->get_total_tax(), 2, ".", ""); ?>',