steveosoule
4/20/2017 - 10:32 PM

Miva - Template Feed - variant_id, sale prices, and variant prices

Miva - Template Feed - variant_id, sale prices, and variant prices

<mvt:if expr="g.variant_id GT 0">
    <mvt:do file="g.Module_Library_DB" name="l.success" value="ProductList_Load_Variant(l.settings:product:id, g.variant_id, l.settings:loaded_variants)" />
    <mvt:if expr="l.settings:loaded_variants[1]:price GT 0">
        <mvt:do name="l.success" file="g.Module_Feature_TUI_UT" value="CommonComponentFields_Initialize_Product_Discounts_Runtime(l.settings:loaded_variants, miva_array_elements(l.settings:loaded_variants))" />
        <meta itemprop="price" content="&mvt:loaded_variants[1]:price;" />
    <mvt:else>
        <meta itemprop="price" content="&mvt:product:price;" />
    </mvt:if>    
<mvt:else>
    <meta itemprop="price" content="&mvt:product:price;" />
</mvt:if>
<mvt:if expr="NOT l.settings:record:variant:variant_id">
    <mvt:do name="l.settings:record:variant:product_part_count" file="g.Module_Library_DB" value="ProductVariantPartList_Load_Part(l.settings:record:variant:id, l.settings:record:variant:productvariantparts)" />
    <mvt:if expr="miva_array_elements( l.settings:record:variant:productvariantparts ) GT 0">
        <mvt:foreach iterator="pvp" array="record:variant:productvariantparts">
            <mvt:if expr="l.settings:pvp:product_id EQ l.settings:record:id">
                <mvt:assign name="l.settings:record:variant:variant_id" value="l.settings:pvp:variant_id" />
                <mvt:foreachstop />
            </mvt:if>
        </mvt:foreach>
    </mvt:if>
</mvt:if>
<mvt:assign name="l.settings:record:variant:canonical_uri" value="l.settings:record:canonical_uri $ '?variant_id=' $ l.settings:record:variant:variant_id" />
<mvt:foreach iterator="attribute" array="attributes">
	<mvt:foreach iterator="option" array="attribute:options">
		<mvt:if expr="l.settings:attribute:attmpat_id GT 0">
			<mvt:do file="g.Module_Library_DB" name="l.null" value="ProductVariantList_Load_AttributeTemplateOption(l.settings:attribute:attmpat_id, l.settings:option:id, l.settings:variantlist)" />
		<mvt:else>
			<mvt:do file="g.Module_Library_DB" name="l.null" value="ProductVariantList_Load_Product_Option(l.settings:product:id, l.settings:attribute:id, l.settings:option:id, l.settings:variantlist)" />
		</mvt:if>

		<mvt:foreach iterator="variant" array="variantlist">
			<mvt:do file="g.Module_Library_DB" name="l.null" value="ProductList_Load_Variant(l.settings:product:id, l.settings:variant:variant_id, l.variant)" />
		</mvt:foreach>

		<mvt:if expr="g.dump">
			<mvt:eval expr="glosub(miva_array_serialize(l.settings:variant), ',', '<br>')" />
			<hr>
		</mvt:if>

		<span class="product-color-swatch-item" data-item-var-id="&mvt:variant:variant_id;"><a href="#&mvte:option:code;" class="product-color-swatch-link" id="color-swatch-&mvte:option:code;" data-select-var-id="&mvt:variant:variant_id;" data-select-val="&mvte:option:code;" data-select-label="&mvte:option:prompt;"><img src="&mvte:option:image;" class="base-img" /></a></span>

	</mvt:foreach>
</mvt:foreach>
<mvt:do name="l.settings:getbaseprice" file="g.Module_Feature_TUI_UT" value="CommonComponentFields_Initialize_Product_Discounts_Runtime(l.settings:search_results:products, miva_array_elements(l.settings:search_results:products))" />
<mvt:do file="g.Module_Library_DB" name="l.success" value="ProductVariantList_Load_Variant( l.settings:product:id, l.settings:variant:variant_id, l.settings:variant:productvariant_options )" />