MivaLearn

Public Snippets 179

Sorts Shipping Methods Low to High

<mvt:comment> Sorts Shipping Methods Low to Hi </mvt:comment>	
<mvt:do file="g.module_library_utilities" name="l.null" value="QuickSortArray(l.settings:shippingmethods, ':price', 1)" />			

Miva - Load Price Table Based Shipping

<mvt:comment>Load Module</mvt:comment>
<mvt:do file="g.Module_Library_DB" name="l.ptbship:module_loaded" value="Module_Load_Code_Cached( 'ptbship', l.ptbship:module)" />
<mvt:if expr="l.ptbship:module_loaded">
	<mvt:do file="g.Module_Library_DB" name="l.ptbship:store_module_loaded" value="StoreModule_Load_Cached( l.ptbship:module:id, 'shipping',  l.ptbship:store_module )" />
	<mvt:if expr="l.ptbship:store_module_loaded">
		<mvt:assign name="l.ptbship:module_path" value="g.Module_Root $ l.pt

Get Last Four From pay_data

<mvt:comment> Set delimiter variables </mvt:comment>
<mvt:assign name="g.colon" value="':'" />
<mvt:assign name="g.comma" value="','" />
<mvt:assign name="g.equal" value="'='" />
<mvt:comment> First seperate string by the colon and add to an array </mvt:comment>
<mvt:do file="g.Module_Library_Utilities" name="l.null" value="SplitString( l.settings:order:pay_data, g.colon, l.settings:pay_data_array )" />
<mvt:comment> Loop through the array </mvt:comment>
<mvt:foreach iterator="data" array

ProductPaymentRules_Update

<ProductPaymentRules_Update product_code="prod">
	<LimitPaymentMethods>No</LimitPaymentMethods>
	<PaymentMethods>
		<PaymentMethod module_code="authnet" method_code="VISA" />    (multiple allowed)
	</PaymentMethods>
</ProductPaymentRules_Update>

Load Price Range for Product Options

<mvt:comment>
====Load Product Attributes====
</mvt:comment>
<mvt:do file="g.Module_Library_DB" name="l.success" value="AttributeList_Load_Product(l.settings:product:id, l.settings:product:attributes)" />

<mvt:if expr="l.settings:product:attributes[1]:attemp_id GT 0">
	<mvt:do file="g.Module_Feature_ATT_DB" name="l.success" value="AttributeTemplateAttrList_Load_Template(l.settings:product:attributes[1]:attemp_id, l.settings:product:attributes)" />
</mvt:if>

<mvt:comment>
====Load Pro

Runtime API - Runtime_ValidateAddress - Response

{
	"success": 1,
	"data": {
		"total": 328.75,
		"subtotal": 300.00,
		"formatted_total": "$328.75",
		"formatted_subtotal": "$300.00",
		"ready_for_checkout": true
	}
}

Runtime API - Runtime_ValidateAddress - Request

{
	"Store_Code": "Store_Code",
	"Function": "Runtime_UpdateShipping",
	"Session_Type": "runtime",
	"Session_ID": "b65e340b3fb23e4b30e3ac3ddde33680",
	"Address_ID": 1,
	"Update_Customer": true,
	"FirstName":"John",
	"LastName":"Doe",
	"Email":"jdoe@miva.com",
	"Phone":"654-456-7894",
	"Address1":"16745 W. Bernardo Dr, Fourth Floor",
	"City":"San Diego",
	"State":"CA",
	"Zip":"92127",
	"Country":"US"
}

Runtime API - Runtime_ValidateAddress - Response

{
	"success": 1,
	"data": [
		{
			"addr1": "16745 W BERNARDO DR # 4",
			"addr2": "",
			"comp": "Miva",
			"city": "SAN DIEGO",
			"state": "CA",
			"zip": "92127-1907",
			"country": "US",
			"resdntl": false
		}
	]
}

Runtime API - Runtime_ValidateAddress - Request

{
	"Store_Code": "STORE_CODE",
	"Function": "Runtime_ValidateAddress",
	"Session_Type": "runtime",
	"Company": "Miva",
	"Address1": "16745 W. Bernardo Dr",
	"Address2": "Fourth Floor",
	"City": "San Diego",
	"State": "CA",
	"Zip": "92127",
	"Country": "US"
}

Check for customer business account in order emal

<mvt:if expr="l.settings:order:cust_id">
    <mvt:do file="g.Module_Feature_CUS_DB" name="l.success" value="Customer_Load_ID(l.settings:order:cust_id, l.new_cust)" />
    <mvt:do file="g.Module_Feature_CUS_DB" name="l.result_account" value="CustomerAndBusinessAccount_Load_CustomerID(l.settings:order:cust_id, l.new_cust, l.settings:businessaccount)" />
	<mvt:if expr="l.settings:businessaccount:title">
		&mvt:businessaccount:title;
	</mvt:if>
</mvt:if>

Miva - Formatted Time with Day and Month

<mvt:comment>
	| Account for Daylight Savings time
</mvt:comment>
	<mvt:if expr="s.tm_isdst">
		<mvt:assign name="g.Timezone_Offset" value="'-5'" />
		<mvt:assign name="g.Timezone_Abbreviation" value="'CDT'" />
	<mvt:else>
		<mvt:assign name="g.Timezone_Offset" value="'-6'" />
		<mvt:assign name="g.Timezone_Abbreviation" value="'CST'" />
	</mvt:if>

<mvt:comment>
	| Assign a Days-of-the-week text array for later
</mvt:comment>

	<mvt:assign name="g.delivery_estimator:days_of_week"

Miva - MivaScript Formatted Date Timestamp

<mvt:assign name="g.current_time" value="s.time_t" />
<mvt:assign name="g.timezone_offset" value="'local'" />
<mvt:comment><!-- <mvt:assign name="g.timezone_offset" value="'-4'" /> --></mvt:comment>


<mvt:assign name="g.year" value="time_t_year( g.current_time, g.timezone_offset )" />
<mvt:assign name="g.month" value="padl(time_t_month( g.current_time, g.timezone_offset ), 2, 0)" />
<mvt:assign name="g.day" value="padl(time_t_dayofmonth( g.current_time, g.timezone_offset ), 2, 0)" />
<m

AttributeTemplateOption_Update

{
	"Store_Code": "STORE_CODE",
	"Function": "AttributeTemplateOption_Update",
	"AttributeTemplateOption_Code": "AttributeTemplateOption_Code",
	"AttributeTemplate_Code": "AttributeTemplate_Code",
	"AttributeTemplateAttribute_Code": "AttributeTemplateAttribute_Code",
	"Price": 4.00 // Price to update
}

Product Specific Combination Facets

		<form class="mm_combination_facet_container" aria-label="&mvte:combination_facets:facet:name;">
			<span class="mm_combination_facet_fields">
				<mvt:foreach iterator="field" array="combination_facets:fields">
					<select id="mm_combination_facet_&mvte:combination_facets:facet:id;_&mvte:field:id;"
						autocomplete="off" aria-label="&mvte:field:name;" aria-live="assertive" aria-atomic="true"
						disabled></select>
				</mvt:foreach>
			</span>
			<span class="mm_combination_facet_

Miva Product Default Variant in feed


<h2>&mvt:record:name;</h2>
<mvt:comment>
====If Product Has Variants ====
l.settings:record:variant:active
l.settings:record:variant:agrpcount
l.settings:record:variant:cancat_id
l.settings:record:variant:catcount
l.settings:record:variant:code
l.settings:record:variant:cost
l.settings:record:variant:cost_formatted
l.settings:record:variant:disp_order
l.settings:record:variant:dt_created
l.settings:record:variant:dt_updated
l.settings:record:variant:id
l.settings:record:variant:i

Load The Main Image To Improve Google's Web Vitals LCP & CL

<mvt:comment>
|
|	Load The Main Image To Improve Google's  Web Vitals LCP & CLS
|
</mvt:comment>

<mvt:comment>
|
|	Default Image
|
</mvt:comment>
<mvt:assign name="l.settings:product:main_image:src"		value="l.settings:image_placeholders:product_image" />
<mvt:assign name="l.settings:product:thumbnails:image_list"	value="''" />

<mvt:comment>
|
|	Load product image list
|
</mvt:comment>
<mvt:do file="g.Module_Library_DB" name="l.settings:product:image_data_list_count" value="P