steveosoule
7/31/2015 - 11:09 PM

Miva - DataLayer

Miva - DataLayer

<mvt:item name="ry_toolbelt" param="assign|l.null|''" />
<script id="mv-data-layer">
	var dataLayer = {
		g: {
			screen: "&mvtj:global:Screen;",
			action: "&mvtj:global:Action;",
			show: "&mvtj:global:show;",
			q: "&mvtj:global:q;"
		},
		store: {
			code: "&mvtj:store:code;",
			company: "&mvtj:store:company;",
			country: "&mvtj:store:country;",
			email: "&mvtj:store:email;"
		},
		<mvt:comment>
			/*
				page: <mvt:item name="ry_toolbelt" param="eval|Json_Stringify(l.all_settings:page)" />,
				category: <mvt:item name="ry_toolbelt" param="eval|Json_Stringify(l.all_settings:category)" />,
				customer: <mvt:item name="ry_toolbelt" param="eval|Json_Stringify(g._customer)" />,
			*/
		</mvt:comment>
		page: {
			code: "&mvtj:page:code;",
			name: "&mvtj:page:name;"
		},
		messages: <mvt:item name="ry_toolbelt" param="eval|Json_Stringify(l.all_settings:messages)" />,
		breadcrumbs: <mvt:item name="ry_toolbelt" param="eval|Json_Stringify(l.all_settings:breadcrumbs)" />,
		customer: {
			id: "&mvtj:customer:id;",
			login: "&mvtj:customer:login;"
		},
		<mvt:if expr="l.settings:page:code EQ 'PROD'">
			product: {
				id: "&mvtj:product:id;",
				code: "&mvtj:product:code;",
				name: "&mvtj:product:name;",
				image: "&mvtj:product:image;"
			},
		</mvt:if>
		<mvt:if expr="l.settings:page:code EQ 'CTGY'">
			category: {
				id: "&mvtj:category:id;",
				code: "&mvtj:category:code;",
				name: "&mvtj:category:name;",
			},
			category_listing: {
				total_prod_count: "&mvtj:category_listing:total_prod_count;",
				page_disp_count: "&mvtj:category_listing:page_disp_count;",
				products_on_page_count: "&mvtj:category_listing:products_on_page_count;",
				page_links: {
					current_page: "&mvtj:category_listing:page_links:current_page;",
					first_link: "&mvtj:category_listing:page_links:first_link;",
					next_link: "&mvtj:category_listing:page_links:next_link;",
					last_link: "&mvtj:category_listing:page_links:last_link;"
				},
				per_page: "&mvtj:category_listing:per_page;",
				products: [
					<mvt:foreach iterator="product" array="category_listing:products">
						{
							code: "&mvt:product:code;",
							name: "&mvt:product:name;",
							base_price: "&mvt:product:base_price;",
							price: "&mvt:product:price;",
							image: "&mvt:product:imagetypes:main;",
							link: "&mvt:product:link;"
						},
					</mvt:foreach>
				]
			},
		</mvt:if>
		<mvt:if expr="l.settings:page:code EQ 'PLST'">
			product_listing: {
				total_prod_count: "&mvtj:product_listing:total_prod_count;",
				products_on_page_count: "&mvtj:product_listing:products_on_page_count;",
				page_links: {
					current_page: "&mvtj:product_listing:page_links:current_page;",
					last_page: "&mvtj:product_listing:page_links:last_page;",
					first_link: "&mvtj:product_listing:page_links:first_link;",
					next_link: "&mvtj:product_listing:page_links:next_link;",
					last_link: "&mvtj:product_listing:page_links:last_link;"
				},
				per_page: "&mvtj:product_listing:per_page;",
				products: [
					<mvt:foreach iterator="product" array="product_listing:products">
						{
							code: "&mvt:product:code;",
							name: "&mvt:product:name;",
							base_price: "&mvt:product:base_price;",
							price: "&mvt:product:price;",
							image: "&mvt:product:imagetypes:main;",
							link: "&mvt:product:link;"
						},
					</mvt:foreach>
				]
			},
		</mvt:if>
		<mvt:if expr="l.settings:page:code EQ 'INVC'">
			order: {
				id: "&mvtj:order:id;",
				cust_id: "&mvtj:order:cust_id;",
				date: "&mvtj:order:date;",
				orderdate: "&mvtj:order:orderdate;",
				subtotal: "&mvtj:order:subtotal;",
				total: "&mvtj:order:total;",
				ship_addr: "&mvtj:order:ship_addr;",
				ship_addr1: "&mvtj:order:ship_addr1;",
				ship_addr2: "&mvtj:order:ship_addr2;",
				ship_city: "&mvtj:order:ship_city;",
				ship_cntry: "&mvtj:order:ship_cntry;",
				ship_comp: "&mvtj:order:ship_comp;",
				ship_data: "&mvtj:order:ship_data;",
				ship_email: "&mvtj:order:ship_email;",
				ship_fax: "&mvtj:order:ship_fax;",
				ship_fname: "&mvtj:order:ship_fname;",
				ship_id: "&mvtj:order:ship_id;",
				ship_lname: "&mvtj:order:ship_lname;",
				bill_addr: "&mvtj:order:bill_addr;",
				bill_addr1: "&mvtj:order:bill_addr1;",
				bill_addr2: "&mvtj:order:bill_addr2;",
				bill_city: "&mvtj:order:bill_city;",
				bill_cntry: "&mvtj:order:bill_cntry;",
				bill_comp: "&mvtj:order:bill_comp;",
				bill_data: "&mvtj:order:bill_data;",
				bill_email: "&mvtj:order:bill_email;",
				bill_fax: "&mvtj:order:bill_fax;",
				bill_fname: "&mvtj:order:bill_fname;",
				bill_id: "&mvtj:order:bill_id;",
				bill_lname: "&mvtj:order:bill_lname;",
				items: [
					<mvt:foreach iterator="group" array="order:groups">
						{
							code: "&mvtj:group:product:code;",
							name: "&mvtj:group:name;",
							variant_code: "&mvtj:group:parts:code;",
							variant_name: "&mvtj:group:product:name;",
							quantity: "&mvtj:group:quantity;",
							weight: "&mvtj:group:weight;",
							image: "&mvtj:group:imagetypes:main;",
							price: "&mvtj:group:price;",
							base_price: "&mvtj:group:base_price;",
							retail: "&mvtj:group:retail;",
							subtotal: "&mvtj:group:subtotal;",
							subtotal_retail: "&mvtj:group:subtotal_retail;",
							subtotal_base_price: "&mvtj:group:subtotal_base_price;"
						},
					</mvt:foreach>
				]
			},
		</mvt:if>
		data: <mvt:item name="ry_toolbelt" param="eval|Json_Stringify(g.dataLayer)" />
	};
</script>
<script id="mv-data-layer--basket">
	dataLayer.basket = {
		total: "&mvtj:global_minibasket:total;",
		items: [
			<mvt:foreach iterator="group" array="global_minibasket:groups">
				{
					code: "&mvtj:group:product:code;",
					name: "&mvtj:group:name;",
					variant_code: "&mvtj:group:parts:code;",
					variant_name: "&mvtj:group:product:name;",
					quantity: "&mvtj:group:quantity;",
					weight: "&mvtj:group:weight;",
					image: "&mvtj:group:imagetypes:main;",
					price: "&mvtj:group:price;",
					base_price: "&mvtj:group:base_price;",
					retail: "&mvtj:group:retail;",
					subtotal: "&mvtj:group:subtotal;",
					subtotal_retail: "&mvtj:group:subtotal_retail;",
					subtotal_base_price: "&mvtj:group:subtotal_base_price;"
				},
			</mvt:foreach>
		]
	}
</script>