steveosoule
3/8/2017 - 12:59 AM

Miva - Load Prices AJAX Call

Miva - Load Prices AJAX Call

<mvt:if expr="g.get EQ 'prices'">
	<mvt:comment><!-- g.Product_Codes is a comma separated list of product codes being sent --></mvt:comment>
	<mvt:assign name="l.settings:product_codes" value="miva_array_deserialize(g.Product_Codes)" />
	<mvt:foreach iterator="code" array="product_codes">
		<mvt:do name="l.result" file="g.Module_Library_DB" value="Product_Load_Code( l.settings:code, l.settings:product )" />
		<mvt:do file="g.Module_Feature_TUI_UT" name="l.result" value="CommonComponentFields_Initialize_Product_Runtime( l.settings:product )" />
		<mvt:assign name="l.index" value="miva_array_insert( l.settings:products, l.settings:product, -1 )" />
	</mvt:foreach>

	<mvt:do file="g.Module_Feature_TUI_UT" name="l.result"  value="CommonComponentFields_Initialize_Product_Discounts_Runtime(l.settings:products, miva_array_elements(l.settings:products) )" />

	{
	 <mvt:foreach iterator="product" array="products">
		<mvt:if expr="POS1 GT 1">,</mvt:if>
		"&mvtj:product:code;": {
			"price": "&mvt:product:price;",
			"formatted_price": "&mvt:product:formatted_price;",
			"base_price": "&mvt:product:base_price;",
			"formatted_base_price": "&mvt:product:formatted_base_price;",
			"retail": "&mvt:product:retail;",
			"formatted_retail": "&mvt:product:formatted_retail;",
			"cost": "&mvt:product:cost;",
			"formatted_cost": "&mvt:product:formatted_cost;"
		}
	</mvt:foreach>
	}
<mvt:else>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<title>&mvt:store:name; API</title>
		<meta name="viewport" content="width=device-width, initial-scale=1">

		<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.1/css/bootstrap.min.css">
	</head>
	<body>
		<div class="container">
			<div class="row">
				<div class="col-sm-6 col-sm-offset-3">
					<h1>API</h1>
					<hr>
					<mvt:if expr="g.get EQ 'category'">
						<h2>Category</h2>
						<mvt:if expr="g.ID">
							<h3>ID</h3>
							<mvt:do name="l.result" file="g.Module_Library_DB" value="Category_Load_ID( g.ID, l.settings:category )" />
							<mvt:eval expr="decodeattribute(glosub(miva_array_serialize(l.settings:category), ',', '<br>'))" />
						<mvt:elseif expr="g.Code">
							<h3>Code</h3>
							<mvt:do name="l.result" file="g.Module_Library_DB" value="Category_Load_Code( g.Code, l.settings:category )" />
							<mvt:eval expr="decodeattribute(glosub(miva_array_serialize(l.settings:category), ',', '<br>'))" />
						</mvt:if>
					<mvt:elseif expr="g.get EQ 'product'">
						<h2>Product</h2>
						<mvt:if expr="g.ID">
							<h3>ID</h3>
							<mvt:do name="l.result" file="g.Module_Library_DB" value="Product_Load_ID( g.ID, l.settings:product )" />
							<mvt:eval expr="decodeattribute(glosub(miva_array_serialize(l.settings:product), ',', '<br>'))" />
						<mvt:elseif expr="g.Code">
							<h3>Code</h3>
							<mvt:do name="l.result" file="g.Module_Library_DB" value="Product_Load_Code( g.Code, l.settings:product )" />
							<mvt:eval expr="decodeattribute(glosub(miva_array_serialize(l.settings:product), ',', '<br>'))" />
						</mvt:if>
					</mvt:if>
				</div>
			</div>
		</div>
	</body>
</html>
</mvt:if>