MivaLearn

Public Snippets 196

Miva - Add & Remove Basket Charges

<mvt:if expr="g.Delete_Charge">
	<h2>Delete Charge</h2>
	<mvt:do file="g.Module_Library_DB" name="l.gone" value="BasketCharge_Delete_All_Type(g.Basket:basket_id, 'CUSTOM_CHARGE')" />
</mvt:if>


<mvt:if expr="g.Add_Charge">
	<mvt:assign name="l.basket_charge:basket_id" value="g.Basket:basket_id" />
	<mvt:assign name="l.basket_charge:module_id" value="0" />
	<mvt:assign name="l.basket_charge:type" value="'CUSTOM_CHARGE'" />
	<mvt:assign name="l.basket_charge:descrip" value="'Custom Char

Miva - Load Custom Field in URI Template

<mvt:do file="g.Module_Library_DB" name="l.loaded_module" value="Module_Load_Code_Cached( 'customfields', l.customfields_module )" />
<mvt:if expr="l.loaded_module">
	<mvt:do file="g.Module_Root $ l.customfields_module:module" name="l.settings:product:brand" value="Module_Product_Field_Value( l.customfields_module, l.settings:product:id, 'brand' )" />
</mvt:if>

<mvt:if expr="l.settings:product:brand">
	/product/&mvts:product:brand;/&mvts:product:name;.html
<mvt:else>
	/product/&mvts:pro

CTGY PageBuilder

<mvt:comment>Ability to have a page with the same code as the current category code and use that page via page builder for specific category landing pages/layouts</mvt:comment>
<mvt:do file="g.Module_Feature_TUI_DB" name="l.settings:Page_Load_CodeOK" value="Page_Load_Code( g.Category_Code, l.settings:category:pagebuilder_cat_page )" />
<mvt:if expr="l.settings:Page_Load_CodeOK">
	<mvt:capture variable="l.settings:category:pagebuilder_design"><mvt:do name="l.settings:foundPageOK" file="g.Modul

Retrieve PO Description

<mvt:comment> Load order payments </mvt:comment> 
<mvt:do file="g.module_library_db" name="l.success" value="OrderPaymentList_Load_Order(l.settings:order:id, l.settings:orderpayments)" /> 

<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> Loop through payments array to find the payment data </mvt:comment> 
<mvt:foreach iterator="payment" ar

Update Basket Item Weight

<mvt:assign name="l.settings:basketcontents" value="l.settings:basket:groups" />
<mvt:assign name="l.settings:ttl_automatically_updated_items_in_cart" value="0" />
<mvt:foreach iterator="group" array="basketcontents">

    <mvt:comment>Load product as it is right now, Runtime means only Active products</mvt:comment>
    <mvt:do name="l.loadedProductOK" file="g.Module_Library_DB" value="Runtime_Product_Load_Code( l.settings:group:code, l.settings:group:current_product_values )" />

    <mv

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

Force page to download CSV

    <mvt:assign name="l.header" value="miva_output_header( 'Content-Disposition', 'attachment; filename='ADD_FILE_NAME.xls' )" />

Levels Framework Product and Category Search

<mvt:if expr="g.get EQ 'autocomplete' AND g.Search">

	<mvt:comment><!-- Autocomplete Category & Product Search --></mvt:comment>

	<mvt:comment><!-- Search for Categories --></mvt:comment>

		<mvt:assign name="g.Fields" value="'code,name'" />
		<mvt:assign name="g.Offset" value="0" />
		<mvt:assign name="g.Max" value="5" />
		<mvt:do file="g.Module_Library_DB" name="l.return" value="CategoryList_Load_Offset(g.Offset, g.Search, g.Fields, g.Max, g.NextOffset, l.settings:categories)" />

ProductList_Load_Offset_AvailabilityGroup_Assigned

<mvt:assign name="g.offset" value="0" />
<mvt:assign name="g.search" value="''" />
<mvt:assign name="g.searchable_fields" value="''" />
<mvt:assign name="g.max" value="0" />

<mvt:do file="g.Module_Feature_AGR_DB" name="l.success" value="AvailabilityGroupList_Load_All(l.settings:availabilitygroups)" />

<mvt:foreach iterator="group" array="availabilitygroups">
    <mvt:do file="g.Module_Library_DB" name="l.success" value="ProductList_Load_Offset_AvailabilityGroup_Assigned(l.settings:grou

ProductVariant_Update

{
	"Store_Code": "STORE_CODE",
	"Function": "ProductVariant_Update",
	"Product_Code": "PRODUCT_CODE",
	"Variant_ID": "VARIANT_ID",
	"Attributes":[
		{
			"attr_code":"ATRIBUTE_CODE",
			"option_code": "OPTION_CODE"
		},
		{
			"attr_code":"ATRIBUTE_CODE",
			"option_code": "OPTION_CODE"
		}
	],
	"Parts":[
		{
			"part_code":"PART_PRODCUCT_CODE",
			"quantity": 1
		},
		{
			"part_code":"PART_PRODCUCT_CODE",
			"quantity": 1
		}
	]
}	

ProductVariantPricing_Update

{
	"Store_Code": "STORE_CODE",
	"Function": "ProductVariantPricing_Update",
	"Product_ID": 1,
	"Variant_ID": 1,
	"Method": 2,
	"Price": 99.99,
	"Cost": 99.99,
	"Weight": 99.99
}

Flex Component Text Example

{
	"code": "heading_text",
	"prompt": "Heading Text",
	"type": "text",
	"textsettings": {
		"fields": [
			{
				"code": "size",
				"options": [
					{
						"text": "Small",
						"value": "16px"
					},
					{
						"text": "Medium",
						"value": "20px"
					},
					{
						"text": "Large",
						"value": "24px"
					}
				],
				"prompt": "Font Size",
				"pseudoclasses": [
					"normal",
					"hover",
					"focus",
					"active"
				],
				"size": "half",
			

ProductPaymentRules_Update

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

Product Data Field Master Product Inventory Count

<mvt:comment>
	------------------------------------------------
	Variant Inventory Count
	Code: PRODUCTDATAFIELD_VINC
	Main Template
 
	Instructions:
		1. Install Product Data Fields and Feed module.
		2. Add Field
			- Name: Variant Inventory Count
			- Code: VINC
			- On Inventory Change: Queue Modified Products and Variants Masters
			- Trigger: VINC
			- Public: True (checked)
		3. Navigate to the `PRODUCTDATAFIELD_VINC` page template code in the Admin
		4. Clear out the "Main

Variant Inventory Count

<mvt:comment>
	------------------------------------------------
	Variant Inventory Count
	Code: PRODUCTDATAFIELD_VINC
	Main Template

	Instructions:
		1. Install Product Data Fields and Feed module.
		2. Add Field
			- Name: Variant Inventory Count
			- Code: VINC
			- On Inventory Change: Queue Modified Products and Variants Masters
			- Trigger: VINC
			- Public: True (checked)
		3. Navigate to the `PRODUCTDATAFIELD_VINC` page template code in the Admin
		4. Clear out the "Mian 

Customer Assigned Price Groups

<mvt:comment>
	Looping through all price groups after confirming the customer is logged in
</mvt:comment>
<mvt:if expr="g.basket:cust_id">
	<mvt:comment> 
		Get all price groups assigned to a customer
	</mvt:comment>
	<mvt:do name="g.pgroupcount" file="g.Module_Feature_PGR_DB" value="PriceGroupAndModuleList_Load_Customer( g.basket:cust_id, l.settings:customer_pricegroups )" />
	<mvt:comment> 
		Loop through customer assigned price groups
	</mvt:comment>
	<mvt:foreach iterator="custome