Example #1
0
    protected function getShowManufactory($manufactories = array())
    {
        $result = '';
        if ($manufactories) {
            foreach ($manufactories as $manufactory) {
                $manufactoryName = ManufacturerCore::getNameById($manufactory);
                $result .= '<li id="manufacturer-' . $manufactory . '">
								<input type="hidden" class="manufactories" name="manufacturers[]" value="' . $manufactory . '" />
								<span>' . $manufactoryName . '</span>
								<a class="link-trash-manufacturer pull-right" data-id="' . $manufactory . '"><i class="icon-trash "></i></a>
							</li>';
            }
        }
        return $result;
    }
Example #2
0
    public function hookOrderConfirmation($params)
    {
        $context = Context::getContext();
        $id_card = $context->cart->id;
        $id_order = Order::getOrderByCartId(intval($id_cart));
        $order = $params['objOrder'];
        $products = $order->getProducts();
        $dl = '<script>
   		$(window).load(function() {
	window.dataLayer.push({
	    "ecommerce": {
	        "purchase": {
	            "actionField": {
	                "id" : "' . $order->id . '",
	            },
	            "products": [';
        foreach ($products as $product) {
            //id_manufacturer
            //id_category_default
            //product_attribute_id
            $price = $product['total_price'];
            $revenue = $price / 100 * 20;
            $brand = ManufacturerCore::getNameById($product['id_manufacturer']);
            $name = ProductCore::getProductName($product['product_id']);
            $category = CategoryCore::getUrlRewriteInformations($product['id_category_default']);
            $variant = $this->getAttributeName($product['product_attribute_id']);
            $dl .= '{
	                    "id": "' . $product['product_id'] . '",
	                    "name": "' . $name . '",
	                    "price": ' . $price . ',
	                    "brand": "' . $brand . '",
	                    "category": "' . $category[0]['link_rewrite'] . '",
	                    "variant": "' . $variant . '",
	                    "quantity": ' . $product['product_quantity'] . ',
	                    "revenue": ' . $revenue . ',
	                    "shipping": ' . $order->total_shipping . '
	                },';
        }
        $dl .= ']
	        }
	    }
	});
	';
        foreach ($products as $product) {
            $price = $product['total_price'];
            $revenue = $price / 100 * 20;
            $name = ProductCore::getProductName($product['product_id']);
            $category = CategoryCore::getUrlRewriteInformations($product['id_category_default']);
            $brand = ManufacturerCore::getNameById($product['id_manufacturer']);
            $variant = $this->getAttributeName($product['product_attribute_id']);
            $dl .= '/* ga("ec:addProduct", {
				  "id": "' . $product['product_id'] . '",
				  "name": "' . $name . '",
				  "category": "' . $category[0]['link_rewrite'] . '",
				  "brand": "' . $brand . '",
				  "variant": "' . $variant . '",
				  "price": "' . $price . '",
				  "quantity": ' . $product['product_quantity'] . '
				});
				';
        }
        $dl .= 'ga("ec:setAction", "purchase", {
		  "id" : "' . $order->id . '",
		  "affiliation": location.hosts,
		  "revenue": "' . $order->total_paid_real . '",
		  "shipping": "' . $order->total_shipping . '"
		});

		ga("send", "pageview");
   		})*/; 
   		</script>';
        return $dl;
    }