コード例 #1
0
ファイル: Analytics.php プロジェクト: jeffhorus/sepatuku
    static function renderEcommerceScript($order)
    {
        $functionContent = '';
        $anContent = '';
        $functionContent .= "var _gaq = _gaq || [];\n";
        $revenue = $order['total_amount_raw'] - $order['shipping'] - $order['tax'];
        $addTrans = array('_addTrans', $order['order_id'], '', $revenue, $order['tax'], $order['shipping'], '', '', '');
        $addTransJson = json_encode($addTrans);
        $functionContent .= "_gaq.push({$addTransJson});\n";
        $newAddTrans = array('id' => $order['order_id'], 'revenue' => $revenue, 'tax' => $order['tax'], 'shipping' => $order['shipping']);
        $newAddTransJson = json_encode($newAddTrans);
        $anContent .= "ga('require', 'ecommerce', 'ecommerce.js');\n";
        $anContent .= "ga('ecommerce:addTransaction', {$newAddTransJson});\n";
        foreach ($order['detailed_items'] as $item) {
            $sku = $item['title'];
            if (isset($item['product_code']) && $item['product_code']) {
                $sku = $item['product_code'];
            }
            $addItem = array('_addItem', $order['order_id'], $sku, $item['title'], '', $item['price'], $item['quantity']);
            $newItem = array('id' => $order['order_id'], 'sku' => $sku, 'name' => $item['title'], 'price' => $item['price'], 'quantity' => $item['quantity']);
            $addItemJson = json_encode($addItem);
            $newAddItemJson = json_encode($newItem);
            $functionContent .= "_gaq.push({$addItemJson});\n";
            $anContent .= "ga('ecommerce:addItem', {$newAddItemJson});\n";
        }
        $functionContent .= "_gaq.push(['_trackTrans']);\n";
        $anContent .= "ga('ecommerce:send');\n";
        $scriptContent = $functionContent;
        $s = Helper_Xml::xmlTag('script', $scriptContent, array('type' => 'text/javascript'));
        $gaContent = "";
        $newContent = <<<EOD
if (window.ga) {
{$anContent}
}

EOD;
        $new = Helper_Xml::xmlTag('script', $newContent, array('type' => 'text/javascript'));
        return $s . $new;
    }
コード例 #2
0
ファイル: Cart.php プロジェクト: jeffhorus/sepatuku
 function _getDeliveryDateForm($cart)
 {
     if (isset($this->withDeliveryDate) && $this->withDeliveryDate) {
         $inputs = '';
         $inputs .= Helper_Xml::xmlInputHidden('cmd', 'delivery_date');
         $delDate = '';
         if ($cart['delivery_timestamp']) {
             $delDate = Helper_Date::formatSgpDatetime($cart['delivery_timestamp'], FALSE);
             if ($this->withDeliveryDate === 'date') {
                 $delDate = Helper_Date::formatSgpDate($cart['delivery_timestamp'], FALSE);
             }
         }
         $inputs .= Helper_Xml::xmlEmptyTag('input', array('type' => 'text', 'name' => 'delivery_date', 'value' => $delDate));
         $inputs .= Helper_Xml::xmlEmptyTag('input', array('type' => 'submit', 'value' => 'Update'));
         $ddLabel = 'Delivery Date';
         if (isset($this->deliveryDateLabel) && $this->deliveryDateLabel) {
             $ddLabel = $this->deliveryDateLabel;
         }
         $label = Helper_Xml::xmlTag('span', "{$ddLabel}: ");
         $shippingForm = Helper_Xml::xmlTag('form', $label . $inputs, array('action' => $cart['link'], 'method' => 'post', 'class' => 'cart-delivery-date'));
         return $shippingForm;
     }
     return '';
 }
コード例 #3
0
ファイル: PageView.php プロジェクト: andresusanto/sepatuku
 function xmlTag($tag, $content, $attrs = array(), $is_empty = FALSE, $isInline = FALSE)
 {
     return Helper_Xml::xmlTag($tag, $content, $attrs, $is_empty, $isInline);
 }