Skip to content

Instantly share code, notes, and snippets.

@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>
@steveosoule
steveosoule / miva-points-and-loyalty-bonus-for-new-customers.xml
Last active May 26, 2022 16:15
Miva - Points and Loyalty Bonus for New Customers
<mvt:comment>
|
| Points and Loyalty Bonus for New Customers
|
| Further Reading: https://docs.miva.com/how-to-guides/points-loyalty#functions
|
</mvt:comment>
<mvt:assign name="l.just_created_customer_account" value="(g.Action EQ 'ICST' OR g.Action EQ 'ICSQ') AND NOT g.UI_Exception AND g.Basket:cust_id" />
<mvt:if expr="l.just_created_customer_account">
<mvt:assign name="l.settings:transaction:cust_id" value="g.Basket:cust_id" />
@steveosoule
steveosoule / 00__README.md
Last active May 3, 2022 16:58
Miva - miva_output_flush() Demo

Example of miva_output_flush()

Output flushing can have inconsistent performance based on the server and client setup for a given web-request (See "The Flush Checklist"), but the following is a basic example of how miva_output_flush can work with a Miva server.

Demo Instructions

  1. Create new page in a store (ex. miva-output-flush-test)
  2. Paste the contents of one of the following files onto it
@steveosoule
steveosoule / miva-load-variant-data-from-order-items-with-extra-common-component-field.xml
Last active April 8, 2022 17:09
Miva - Load Variant Data From Order Items (with Extra Common Component Field)
<mvt:comment>
<!-- Determine Order To Load -->
</mvt:comment>
<mvt:if expr="g.order_id GT 0">
<mvt:assign name="l.order_id" value="int(trim(g.order_id))" />
<mvt:else>
<mvt:assign name="l.order_id" value="200000785" />
</mvt:if>
<mvt:comment>