Skip to content

Instantly share code, notes, and snippets.

@steveosoule
steveosoule / 00-add-custom-hero-banner-after-first-slide.js
Last active February 3, 2023 17:23
Miva - MMX Hero Slider Manipulations
// Add a new mmx-hero slide after the first slide
const slider = document.getElementById('mmx-hero-slider__mmx_heroslider');
const firstSlide = slider.querySelector('[slot="hero_slide"]');
const newSlideHTML = /*html*/`
<mmx-hero
slot="hero_slide"
data-href="#foo"
data-heading="This is the heading!"
data-body="this is the body text"
data-content-location="center"
@steveosoule
steveosoule / miva-set-product-s-combination-facet-value.xml
Last active December 20, 2022 18:48
Miva - Set Product's Combination Facet Value
<mvt:comment>
Parameters
</mvt:comment>
<mvt:assign name="l.combofacet_field_code" value="'ymm'" />
<mvt:assign name="l.combofacet_product_value" value="'1967>Ford>Mustang|1967>Chevy>Camaro'" />
<mvt:assign name="l.product_code" value="'fitment-test'" />
<mvt:comment>
Loading the Data and Module Settings
</mvt:comment>
@steveosoule
steveosoule / miva-full-mvt-do-with-load-module-path-check-active-check-installed.xml
Created December 1, 2022 17:24
Miva - Full mvt:do with Load Module Path, Check Active, & Check Installed
<mvt:comment>One-Time Setup</mvt:comment>
<mvt:do file="g.Module_Library_DB" name="l.module_loaded" value="Module_Load_Code_Cached('tg_transients', l.tg_transients_module)" />
<mvt:do file="g.Module_Library_DB" name="l.storemodule_installed" value="StoreModule_Load_Cached(l.tg_transients_module:id, 'util', l.null)" />
<mvt:if expr="l.tg_transients_module:active AND l.storemodule_installed">
<mvt:assign name="g.Module_TG_Transients" value="g.Module_Root $ l.tg_transients_module:module" />
<mvt:else>
<mvt:assign name="g.Module_TG_Transients" value="''" />
</mvt:if>
<mvt:comment>Each Usage</mvt:comment>
@steveosoule
steveosoule / step_01--miva-template.xml
Last active July 6, 2022 16:33
Miva - mvt:call to PHP-middleware to perform HTTP GET with POST Data
<mvt:assign name="l.data_for_api:thing_1" value="'Foobar'" />
<mvt:assign name="l.data_for_api:thing_2" value="'Lorem ipsum...'" />
<mvt:capture variable="l.json_string">
<mvt:do file="g.Module_JSON" name="l.success" value="JSON_Output( l.data_for_api )" />
</mvt:capture>
<mvt:call action="'https://ssoule.mivamerchantdev.com/php/mvt-call-converter.php'" method="'GET'" fields="'json_string'">
<mvt:eval expr="s.callvalue" />
</mvt:call>
@steveosoule
steveosoule / miva-mvt-use-s-null-for-null-values--00-README.md
Last active September 7, 2022 16:52
Miva / MVT: Use s.null for Null Values

Use s.null For Unused Return Values

MivaScript 5.36 added support for s.null. s.null will always be null. Assigning a value to s.null does not change the value of s.null and avoids keeping the result of a function or expression in memory.

You can assign variables to s.null when you do not need to use the return variable for anything. By assigning variables to s.null, it more clearly indicates that the variable will not be used (as opposed to l.result or l.success). Just be sure you do not pass s.null (or variables assign to s.null by reference) into MivaScript or mvt:do functions

Incorrect

	
@steveosoule
steveosoule / miva-mvt-parse-xml-example--01.xml
Last active June 17, 2022 16:41
Miva - MVT Parse XML Example
<mvt:capture variable="l.xml:string">
<?xml version="1.0" encoding="UTF-8"?>
<codes>
<code>ABC-123-DEF-456</code>
<code>XYZ-987-TUV-000</code>
</codes>
</mvt:capture>
<mvt:assign name="l.xml:xml_parse_var_result" value="xml_parse_var( l.xml:string, l.xml:var )" />
@steveosoule
steveosoule / color-palette__01.js
Last active July 11, 2022 19:02
CSS Variable Color Palette from Material Colors
// https://materialui.co/colors/
// https://github.com/shuhei/material-colors/blob/master/dist/colors.json
const colors = {
"red": {
"50": "#ffebee",
"100": "#ffcdd2",
"200": "#ef9a9a",
"300": "#e57373",
"400": "#ef5350",
"500": "#f44336",
<mvt:comment>
Loop over the mvt:call response headers
</mvt:comment>
<mvt:call action="'https://ssoule.mivamerchantdev.com/robots.txt'" method="'GET'">
<mvt:assign name="l.settings:headers" value="s.callreturnheader" />
</mvt:call>
<mvt:foreach iterator="header" array="headers">
<mvt:if expr="'Set-Cookie' CIN l.settings:header">
&mvt:header;
@steveosoule
steveosoule / duti.sh
Created May 24, 2022 17:19
Install Duti to Quickly Set File Extensions
# https://formulae.brew.sh/formula/duti
brew install duti
# Use duti to set defaults for specific files to VSCode
duti -s com.microsoft.VSCode public.plain-text all
duti -s com.microsoft.VSCode public.source-code all
duti -s com.microsoft.VSCode public.data all
duti -s com.microsoft.VSCode .css all
duti -s com.microsoft.VSCode .gitattributes all
duti -s com.microsoft.VSCode .gitignore all
@steveosoule
steveosoule / 01__new-customer-discount-coupon--import.xml
Last active May 19, 2022 19:44
Miva - New Customer Discount Coupon
<PriceGroup_Add>
<Name>New Customer Discount</Name>
<Eligibility>Coupon</Eligibility>
<Module>discount_basket</Module>
<Settings>
<Type>Percent</Type> <!-- Fixed,Percent -->
<Discount>5.00</Discount>
</Settings>
</PriceGroup_Add>