Skip to content

Instantly share code, notes, and snippets.

@steveosoule
steveosoule / 00__README.md
Last active August 30, 2024 19:57
Miva JSON API - Add X-Miva-API-Authorization HMAC Signature with JavaScript's CryptoJS as a Postman Pre-Request Script

Add X-Miva-API-Authorization HMAC Signature to a Postman Request

Uses JavaScript's CryptoJS library within a Postman Pre-Request script to: parse the request-body, create a SHA256 HMAC signature, build the Miva JSON API's authorization HTTP Header, and add the header to the current Postman request.

Instructions

Setup Postman Environmental Variables

  1. Navigate to the "Miva Admin > Settings > Users > API Tokens"
  2. Edit a token
@steveosoule
steveosoule / miva-domain-setting-variables.md
Last active January 18, 2024 16:52
Miva - Domain Setting Variables
Name Submit Variable Front End Variable Default
Root Directory for Graphics g.Domain_ImageRoot g.domain:image_root /mm5/
Secure Root Directory for Graphics g.Domain_SecureBaseURL g.domain:img_sroot, g.imageroot /mm5/
Base URL for Graphics g.Domain_BaseURL g.domain:base_url, g.baseurl http://www.example.com/mm5/
Secure Base URL for Graphics g.Domain_SecureBaseURL g.domain:base_surl, g.secure_baseurl, g.basehref https://www.example.com/mm5/
@steveosoule
steveosoule / Nework_throttling_profiles.md
Created January 12, 2024 18:27 — forked from theodorosploumis/Nework_throttling_profiles.md
Web development - Custom network throttling profiles
Profile download (kb/s) upload (kb/s) latency (ms)
Native 0 0 0
GPRS 50 20 500
56K Dial-up 50 30 120
Mobile EDGE 240 200 840
2G Regular 250 50 300
2G Good 450 150 150
3G Slow 780 330 200
@steveosoule
steveosoule / miva-get-full-url-of-current-page.xml
Created November 28, 2023 21:23
Miva - get full URL of current page
<mvt:do file="g.Module_Feature_URI_DB" name="l.success" value="URISettings_Load_Cached( l.uri_settings )" />
<mvt:do file="g.Module_Feature_URI_UT" name="l.settings:request_url" value="URL_Build_URI( l.uri_settings, l.flags, s.request_uri, '' )" />
&mvt:request_url;
@steveosoule
steveosoule / miva-mvt-call-and-get-the-content-length-header.xml
Created November 28, 2023 16:09
Miva - mvt:call and get the Content-Length header
<mvt:call action="'https://www.example.com'" method="'GET'">
<mvt:assign name="l.settings:headers" value="s.callreturnheader" />
</mvt:call>
<mvt:foreach iterator="header" array="headers">
<mvt:if expr="'Content-Length:' IN l.settings:header EQ 1">
<mvt:assign name="l.found" value="miva_splitstring( l.settings:header, ':', l.header_parts, 'trim' )" />
<mvt:assign name="l.content_length" value="l.header_parts[2]" />
</mvt:if>
</mvt:foreach>
@steveosoule
steveosoule / miva-prod-price-debugger.xml
Last active July 26, 2023 20:08
Miva - PROD Price Debugger
<pre>
@@price
product:price=&mvte:product:price;
product:inv_level=&mvte:product:inv_level;
attributemachine:product:price=&mvte:attributemachine:product:price;
attributemachine:product:inv_level=&mvte:attributemachine:product:inv_level;
attributemachine:variant_id=&mvte:attributemachine:variant_id;
<mvt:assign name="g.mvt_debug" value="glosub( miva_array_serialize( l.settings:product ), ',', asciichar( 10 ) )" />
@@l.settings:product
@steveosoule
steveosoule / tokenize-object.js
Created July 25, 2023 16:31
JavaScript Tokenize Object
const tokenizeObject = (obj = {}, tokens = [], replacements = []) => {
if (!Array.isArray(tokens) || !Array.isArray(replacements) || tokens.length !== replacements.length) {
return obj;
}
const replacedJsonObj = tokens.reduce((jsonObj, token, i) => {
return jsonObj.replace(token, replacements[i]);
}, JSON.stringify(obj));
return JSON.parse(replacedJsonObj);
@steveosoule
steveosoule / miva-failed-icsq-redirect-to-http-referer.xml
Last active July 20, 2023 19:45
Miva - Failed ICSQ Redirect to HTTP Referer
<mvt:if expr="g.Session:cache:last_ui_exception EQ 'customer_invalid_addinfo' AND NOT ISNULL s.http_referer">
<mvt:do file="g.Module_Feature_URI_UT" name="l.http_referer_uri" value="URL_To_URI( s.http_referer )" />
<mvt:do file="g.Module_Feature_URI_DB" name="l.uri_found" value="URI_Load_URI( l.http_referer_uri, l.uri )" />
<mvt:if expr="l.uri_found">
<mvt:assign name="l.flags:sep" value="1" />
<mvt:if expr="l.uri:product_id">
<mvt:do file="g.Module_Library_DB" name="l.success" value="Product_Load_ID_Cached( l.uri:product_id, l.product )" />
<mvt:do file="g.Module_Feature_URI_UT" name="l.referer_url" value="Store_Product_URL( l.product, l.flags )" />
<mvt:elseif expr="l.uri:cat_id">
<mvt:do file="g.Module_Library_DB" name="l.success" value="Category_Load_ID_Cached( l.uri:cat_id, l.category )" />
@steveosoule
steveosoule / .bashrc
Created June 26, 2023 16:20
Helpful Bash Aliases and Functions for MMT
alias mmt-push-commit='mmt push --notes="mmt-push-commit: `git log --pretty=oneline -n 1`"'
alias mpc='mmt-push-commit'
alias mmt-tag-git-branch='mmt tag add $(git rev-parse --abbrev-ref HEAD)'
alias mmt-tag-git-commit='mmt tag add $(git rev-parse --short HEAD)'
function mmt-push() {
mmt tag delete --all
mmt-tag-git-branch
mmt-tag-git-commit
@steveosoule
steveosoule / 01__miva-user-friendly-date-time-with-am-pm.md
Last active February 27, 2024 18:05
Miva - User Friendly Date & Time with AM/PM (ex MM/DD/YYYY HH:MM AM/PM)

Miva - User Friendly Date & Time with AM/PM

The following code snippet will output a date with a format like this pattern:

MM/DD/YYYY HH:MM (AM/PM)

For example: