Ejemplo n.º 1
0
    /**
     * Displays Google Analytics tracking code in the header as the LAST item before closing </head> tag
     */
    public function googleAnalyticsTracking()
    {
        // Do not track admin pages
        if ($this->wp->isAdmin()) {
            return;
        }
        // Do not track shop owners
        if ($this->wp->currentUserCan('manage_jigoshop')) {
            return;
        }
        $trackingId = $this->options->get('advanced.integration.google_analytics');
        if (empty($trackingId)) {
            return;
        }
        $userId = '';
        if ($this->wp->isUserLoggedIn()) {
            $userId = $this->wp->getCurrentUserId();
        }
        ?>
		<script type="text/javascript">
			(function(i, s, o, g, r, a, m) {
				i['GoogleAnalyticsObject'] = r;
				i[r] = i[r] || function() {
						(i[r].q = i[r].q || []).push(arguments)
					}, i[r].l = 1 * new Date();
				a = s.createElement(o),
					m = s.getElementsByTagName(o)[0];
				a.async = 1;
				a.src = g;
				m.parentNode.insertBefore(a, m)
			})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'jigoshopGoogleAnalytics');
			jigoshopGoogleAnalytics('create', '<?php 
        echo $trackingId;
        ?>
', {'userId': '<?php 
        echo $userId;
        ?>
'});
			jigoshopGoogleAnalytics('send', 'pageview');
		</script>
		<?php 
    }
Ejemplo n.º 2
0
    /**
     * Displays Google Analytics eCommerce tracking code to add order data.
     */
    function googleAnalyticsTracking()
    {
        // Do not track admin pages
        if ($this->wp->isAdmin()) {
            return;
        }
        // Do not track shop owners
        if ($this->wp->currentUserCan('manage_jigoshop')) {
            return;
        }
        $trackingId = $this->options->get('advanced.integration.google_analytics');
        if (empty($trackingId)) {
            return;
        }
        /** @var Order $order */
        $order = $this->orderService->find((int) $_REQUEST['order']);
        if ($order->getKey() != $_REQUEST['key']) {
            return;
        }
        ?>
		<script type="text/javascript">
			jigoshopGoogleAnalytics('require', 'ecommerce');
			jigoshopGoogleAnalytics('ecommerce:addTransaction', {
				'id': '<?php 
        echo $order->getNumber();
        ?>
', // Transaction ID. Required.
				'affiliation': '<?php 
        bloginfo('name');
        ?>
', // Affiliation or store name.
				'revenue': '<?php 
        echo $order->getTotal();
        ?>
', // Grand Total.
				'shipping': '<?php 
        echo $order->getShippingPrice();
        ?>
', // Shipping.
				'tax': '<?php 
        echo $order->getTotalTax();
        ?>
' // Tax.
			});
			<?php 
        foreach ($order->getItems() as $item) {
            /** @var $item Order\Item */
            ?>
			<?php 
            $product = $item->getProduct();
            if ($product instanceof Product\Variable) {
                $variation = $product->getVariation($item->getMeta('variation_id')->getValue());
            }
            ?>
			jigoshopGoogleAnalytics('ecommerce:addItem', {
				'id': '<?php 
            echo $order->getNumber();
            ?>
', // Transaction ID. Required.
				'name': '<?php 
            echo $item->getName();
            ?>
', // Product name. Required.
				'sku': '<?php 
            echo $product->getSku();
            ?>
', // SKU/code.
				'category': '<?php 
            if (isset($variation)) {
                echo $variation->getTitle();
            }
            ?>
', // Category or variation.
				'price': '<?php 
            echo $item->getPrice();
            ?>
', // Unit price.
				'quantity': '<?php 
            echo $item->getQuantity();
            ?>
' // Quantity.
			});
			<?php 
        }
        ?>
			jigoshopGoogleAnalytics('ecommerce:send');
		</script>
		<?php 
    }
Ejemplo n.º 3
0
 /**
  * @return string Human readable name of method.
  */
 public function getName()
 {
     return $this->wp->isAdmin() ? __('Cheque', 'jigoshop') : $this->options['title'];
 }
Ejemplo n.º 4
0
 /**
  * @return string Human readable name of method.
  */
 public function getName()
 {
     return $this->wp->isAdmin() ? $this->getLogoImage() . ' ' . __('PayPal', 'jigoshop') : $this->settings['title'];
 }
Ejemplo n.º 5
0
 /**
  * @return string Human readable name of method.
  */
 public function getName()
 {
     return $this->wp->isAdmin() ? __('Bank Transfer', 'jigoshop') : $this->options['title'];
 }