Ok so after further analysis I have changed to this(below). Would an expert on OC be able to tell me if they have a reasonable feeling this would work on OC 1.4.9.6? Does anyone see anything wrong with this before I commit to
making these changes and testing?
Modifications to be made:
Mod 1:
in file /view/theme/*/template/common/success.tpl
Code: Select all
before
<?php echo $footer; ?>
<!-- begin ADD google tracking code -->
<?php if(isset($orderDetails) && isset($orderProducts)) { ?>
<script type="text/javascript">
_gaq.push(['_addTrans',
'<?php echo $orderDetails['order_id']; /* orderId */ ?>',
<?php echo json_encode($orderDetails['store_name']); /* affiliation */ ?>,
'<?php echo $orderDetails['total']; /* total */ ?>',
'<?php if (isset($orderTax)) echo $orderTax[0]['value']; /* tax */ ?>',
'<?php if (isset($orderShipping)) echo $orderShipping[0]['value']; /* shipping */ ?>',
<?php echo json_encode($orderDetails['shipping_city']); /* city */ ?>,
<?php echo json_encode($orderDetails['shipping_zone']); /* state */ ?>,
<?php echo json_encode($orderDetails['shipping_country']); /* country */ ?> ]);
<?php foreach($orderProducts as $product) { ?>
_gaq.push(['_addItem',
'<?php echo $product['order_id']; /* orderId */ ?>',
<?php echo json_encode($product['model']); /* sku */ ?>,
<?php echo json_encode($product['name']); /* name (product) */ ?>,
<?php echo json_encode('Products'); /* category */ ?>,
'<?php echo $product['price']; /* price */ ?>',
'<?php echo $product['quantity']; /* quantity */ ?>' ]);
<?php } ?>
_gaq.push(['_trackTrans']);
</script>
<?php } ?>
<!-- end google tracking code -->
Mod 2
In file /catalog/controller/checkout/success.php
Code: Select all
if (isset($this->session->data['order_id'])) {
<!-- begin ADD google tracking code -->
$this->load->model('checkout/order');
$this->data['orderDetails'] = $this->model_checkout_order->getOrder($this->session->data['order_id']);
$this->data['orderProducts'] = $this->model_checkout_order->getOrderProducts($this->session->data['order_id']);
$this->data['orderShipping'] = $this->model_checkout_order->getOrderShipping($this->session->data['order_id']);
$this->data['orderTax'] = $this->model_checkout_order->getOrderTax($this->session->data['order_id']);
<!-- end google tracking code -->
$this->cart->clear();
Mod 3:
in file /catalog/model/checkout/order.php
Code: Select all
<!-- begin ADD google tracking code -->
public function getOrderProducts($order_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_product WHERE order_id = '" . (int)$order_id . "'");
return $query->rows; }
public function getOrderShipping($order_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_total WHERE order_id = '" . (int)$order_id . "' AND
code = 'shipping' AND EXISTS (SELECT * FROM " . DB_PREFIX . "order_total WHERE order_id = '" . (int)$order_id . "' AND
code = 'shipping') UNION SELECT 0, ". (int)$order_id. ", '', '', '', 0, 0 FROM " . DB_PREFIX . "order_total WHERE
NOT EXISTS (SELECT * FROM " . DB_PREFIX . "order_total WHERE order_id = '" . (int)$order_id . "' AND code = 'shipping')");
return $query->rows; }
public function getOrderTax($order_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_total WHERE
order_id = '" . (int)$order_id . "' AND code = 'tax' AND EXISTS (SELECT * FROM " . DB_PREFIX . "order_total WHERE
order_id = '" . (int)$order_id . "' AND code = 'tax') UNION SELECT 0, ". (int)$order_id. ", '', '', '', 0, 0 FROM
" . DB_PREFIX . "order_total WHERE NOT EXISTS (SELECT * FROM " . DB_PREFIX . "order_total WHERE
order_id = '" . (int)$order_id . "' AND code = 'tax')");
return $query->rows; }
<!-- end google tracking code -->
<!-- BEFORE -->
public function create($data)