Skip to content

Instantly share code, notes, and snippets.

View bheyde's full-sized avatar

Brennan Heyde bheyde

View GitHub Profile
@bheyde
bheyde / 301_redirect.html
Created November 21, 2016 16:52
Miva 301 Redirect to Canonical
<mvt:comment>Build l.uri structure with required data</mvt:comment>
<mvt:assign name="l.uri:store_id" value="g.Store:id" />
<mvt:assign name="l.uri:screen" value="''" />
<mvt:assign name="l.uri:page_id" value="0" />
<mvt:assign name="l.uri:cat_id" value="0" />
<mvt:assign name="l.uri:product_id" value="l.settings:product:id" />
<mvt:comment>Load canonical URI for this product</mvt:comment>
<mvt:do file="g.Module_Feature_URI_DB" name="l.has_uri" value="URI_Load_Item_Canonical( l.uri, l.settings:product:uri )" />
@bheyde
bheyde / Varinat_Load.html
Last active November 17, 2016 00:26
Load Variant Data
<mvt:if expr="NOT ISNULL g.product_code AND NOT ISNULL g.variant_id">
<mvt:do file="g.Module_Library_DB" name="l.success" value="Product_Load_Code(g.product_code, l.product)" />
<mvt:do file="g.Module_Library_DB" name="l.success" value="ProductList_Load_Variant(l.product:id, g.variant_id, l.productvariants)" />
<mvt:comment>Load Variant Product To Get Description</mvt:comment>
<mvt:do file="g.Module_Library_DB" name="l.success" value="Product_Load_Code(l.productvariants[1]:code, l.product)" />
<mvt:assign name="l.productvariants[1]:descrip" value="l.product:descrip" />
@bheyde
bheyde / variant_price_range.html
Created November 15, 2016 23:12
Load High / Low Price Range for a Product with Attributes (pricing at attribute level)
<mvt:comment>
Load all possible variants using toolkit
</mvt:comment>
<mvt:item name="toolkit" param="variantarray|vcount|g.product_code" />
<mvt:comment>
Loop though variants, load product information for each variant, insert into new array
</mvt:comment>
@bheyde
bheyde / subscription_insert.html
Last active November 7, 2016 18:48
Subscription Examples
<MvCOMMENT>Build Subscription Structure and Insert</MvCOMMENT>
<MvASSIGN NAME = "l.subscription:custpc_id" VALUE = 0>
<MvASSIGN NAME = "l.subscription:ship_id" VALUE = "{ l.shipping_module:id }">
<MvASSIGN NAME = "l.subscription:ship_data" VALUE = "{ l.module_data }">
<MvASSIGN NAME = "l.subscription:order_id" VALUE = 0>
<MvASSIGN NAME = "l.subscription:line_id" VALUE = 0>
<MvASSIGN NAME = "l.subscription:cust_id" VALUE = "{ l.customer:id }">
<MvASSIGN NAME = "l.subscription:product_id" VALUE = "{ l.product:id }">
<MvASSIGN NAME = "l.subscription:subterm_id" VALUE = "{ l.productsubscriptionterm:id }">
<div id="payment-fields">
<mvt:if expr="l.settings:paymentsettings:mivapay:enabled AND ( l.settings:mivapay:paymentcardtype:id OR l.settings:mivapay:paymentcard:id )">
<mvt:item name="mivapay" />
<mvt:else>
<mvt:foreach array="payment:fields" iterator="field">
<div class="form_row">
<mvt:if expr="l.settings:field:invalid">
<label class="bold red">&mvt:field:prompt;</label>
<mvt:else>
<label class="bold">&mvt:field:prompt;</label>
<mvt:foreach array="paymentmethods" iterator="method">
<mvt:if expr="l.settings:method:paymentcard:id">
<option value="paymentcard:&mvte:method:paymentcard:id;">&mvt:method:name;</option>
<mvt:elseif expr="l.settings:method:paymentcardtype:id">
<option value="paymentcardtype:&mvte:method:paymentcardtype:id;">&mvt:method:name;</option>
<mvt:else>
<option value="&mvte:method:module;:&mvte:method:code;">&mvt:method:name;</option>
</mvt:if>
</mvt:foreach>
@bheyde
bheyde / multi_add.js
Last active October 26, 2017 16:24
Multi-Add Example
<form name="add" method="post" action="&mvte:urls:BASK:auto;" id="AddToCart">
<div id="swatches" class="swatches"></div>
<div class="clear"></div>
<input type="hidden" name="Old_Screen" value="&mvte:global:Screen;" />
<input type="hidden" name="Old_Search" value="&mvte:global:Search;" />
<input type="hidden" name="Action" value="ADPM" />
<input type="hidden" name="Products[1]:code" value="&mvte:product:code;" />
<input type="hidden" name="Category_Code" value="&mvte:global:category_code;" />
<input type="hidden" name="Offset" value="&mvte:global:Offset;" />
<input type="hidden" name="AllOffset" value="&mvte:global:AllOffset;" />
@bheyde
bheyde / scheduled_task.mv
Last active July 15, 2016 15:35
Example Scheduled Task Module
<MvFUNCTION NAME = "Module_Description" PARAMETERS = "module var" STANDARDOUTPUTLEVEL = "">
<MvASSIGN NAME = "l.module:code" VALUE = "call_url_stsk">
<MvASSIGN NAME = "l.module:name" VALUE = "HTTP Request to URL">
<MvASSIGN NAME = "l.module:provider" VALUE = "Miva Merchant">
<MvASSIGN NAME = "l.module:version" VALUE = "9.0003">
<MvASSIGN NAME = "l.module:api_ver" VALUE = "9.05">
<MvASSIGN NAME = "l.module:description" VALUE = "This Scheduled Task allows you to setup a URL which will get called via an http request when the task is run.">
<MvASSIGN NAME = "l.module:features" VALUE = "util, vis_util, scheduledtask">
</MvFUNCTION>
@bheyde
bheyde / mvt_call_headers.html
Created July 14, 2016 15:49
mvt:call - passing custom headers example
<mvt:assign name="g.api_endpoint" value="'https://DJDHGSDJD-dsn.algolia.net'" />
<mvt:assign name="g.index_name" value="'docs.miva'" />
<mvt:assign name="g.path" value="'/1/indexes/' $ g.index_name $ '/390342730'" />
<mvt:assign name="g.api_request" value="g.api_endpoint $ g.path" />
<mvt:assign name="g.headers" value="'X-Algolia-API-Key: 17181817181912' $ asciichar( 13 ) $ asciichar( 10 )" />
<mvt:assign name="g.headers" value=" g.headers $ 'X-Algolia-Application-Id: HSGDJDJDGD' $ asciichar( 13 ) $ asciichar( 10 )" />
<mvt:call action="g.api_request" method="'PUT'" headers="'g.headers'">
<Product_Add>
<Code>ale-gallon</Code>
<SKU>sku</SKU>
<Name><![CDATA[Ale, gallon jug]]></Name>
<Price>2.00</Price>
<Cost>1.50</Cost>
<Weight>8.00</Weight>
<Description><![CDATA[A gallon jug of quality ale.]]></Description>
<Taxable>Yes</Taxable>
<Active>Yes</Active>