Skip to content

Instantly share code, notes, and snippets.

//in product-template.liquid
<div id="canvaTemplateLink" data-value="{{ product.metafields.custom.canva_template_link.value }}"></div>
canva_template_link
//add canva button
// Retrieve the element by its ID
const canvaTemplateLinkFromPageElement = document.getElementById('canvaTemplateLink');
// Get the value from the data attribute
const canvaTemplateLinkFromPageValue = canvaTemplateLinkFromPageElement.getAttribute('data-value');
@Ranjanivraman
Ranjanivraman / .html
Created May 19, 2023 16:05
blog code for quantity selector
<script>
// Find the element with the class "tt-input-counter"
var counterElement = document.querySelector(".tt-input-counter");
// Create a new select (dropdown) element with Bootstrap classes
var selectElement = document.createElement("select");
selectElement.classList.add("form-select", "selectpicker"); // Add form-select and selectpicker classes for Bootstrap styling
selectElement.setAttribute("name", "quantity"); // Set the name attribute
// Add a label to the select element
@Ranjanivraman
Ranjanivraman / .html
Created May 19, 2023 16:02
papaprints quantity tier selection with canva
<script>
// Find the element with the class "tt-input-counter"
var counterElement = document.querySelector(".tt-input-counter");
// Create a new select (dropdown) element with Bootstrap classes
var selectElement = document.createElement("select");
selectElement.classList.add("form-select", "selectpicker"); // Add form-select and selectpicker classes for Bootstrap styling
selectElement.setAttribute("name", "quantity"); // Set the name attribute
@Ranjanivraman
Ranjanivraman / .js
Last active May 19, 2023 13:30
papaprints tier quantity selector without canva
<script>
// Find the element with the class "tt-input-counter"
var counterElement = document.querySelector(".tt-input-counter");
// Create a new select (dropdown) element with Bootstrap classes
var selectElement = document.createElement("select");
selectElement.classList.add("form-select", "selectpicker"); // Add form-select and selectpicker classes for Bootstrap styling
selectElement.setAttribute("name", "quantity"); // Set the name attribute
function outPricePerBucket(prices: number[]): void {
let bucket = 10;
let count = 0;
for (let i=0;i<prices.length;i++) {
// console.log(`${prices[i]} and bucketStart ${bucket} and counter ${count}`);
if (prices[i] < bucket) {
count = count + 1;
}
else {
console.log(`${bucket-10}: ${'*'.repeat(count)}`);
@Ranjanivraman
Ranjanivraman / gist:da25a343b0d40514433b61c85369f812
Created March 14, 2022 15:59
Show more javascript and css
function read_more_less() {
var dots = document.getElementById('dots');
var moretext = document.getElementById('more');
var mybtn = document.getElementById('myBtn');
if (moretext.style.display === 'none') {
moretext.style.display = 'inline';
mybtn.innerHTML = "Show Less";
} else {
moretext.style.display = 'none';
mybtn.innerHTML = "Show More";
@Ranjanivraman
Ranjanivraman / show more html
Last active March 14, 2022 16:48
show more html
<div class="container-indent">
<div class="container container-fluid-custom-mobile-padding">
<div class="demo-typography">
<div class="row">
<div class="readmorepost">
<!-- Start of text that is to be visible -->
Custom stickers are ideal for promotions as they are inexpensive tools
to promote business,brand products and personal items. Personalized
stickers for business like logo stickers increase the visibility of
your business and leave a strong impression on people who use your
express
getUrl from the endpoint
getLocale from the country url mapper (library)
get dynmodb data
Dynamodb schema :
@Ranjanivraman
Ranjanivraman / getReturnItemDynamodb.ts
Last active July 19, 2021 13:14
Get an item from dynamodb
import { DocumentClient } from "aws-sdk/clients/dynamodb";
import { ReturnItem } from "../Type/ReturnItem";
export async function getReturnItem(orderId: string, sku: string): Promise<ReturnItem> {
const db: DocumentClient = new DocumentClient({
region: process.env.AWS_REGION as string,
});
const myKey: DocumentClient.Key = {
orderId,
sku,