CHOON7UFJCWBEFPYPXHT2PPBSF6MPSZPWELPH2HRCJ6ZKQBDWKYAC
function pq(item, type) {
let portions;
let quantity;
if(item.variant_title === 'Default Title') {
portions = item.meta.variant.retail_pack_number_of_items
quantity = item.meta.variant.retail_pack_net_content;
} else if(type === 'gummy' || type === 'mint' || type === 'chocolate' || type === 'baked') {//for https://ocs.ca/products/pineapple-soft-chews-san-rafael-71 4 vs 4.3(21.5 / 5)
portions = item.meta.variant.retail_pack_number_of_items;
if(item.handle === '64-cocoa-dark-chocolate-aurora-drift') {
quantity = '5.2';//dumbfucks have it labelled as 27g net, instead of 26g
} else {
quantity = (new Big(item.meta.variant.retail_pack_net_content)).div(portions).toString();
}
} else {
[, , portions, quantity] = item.variant_title.match(qty);
if(portions === undefined && type === 'preroll' && item.meta.variant.retail_pack_number_of_items > 1) {
portions = item.meta.variant.retail_pack_number_of_items;
quantity = (new Big(quantity)).div(portions).toString();
}
}
if(!portions || portions < 2) {
portions = null;
}
return [portions, quantity];
}
let minTHC, maxTHC, minCBD, maxCBD, unit;
let UOM = 'g';
for(let j = 0; j < e[i][0].tags.length; ++j) {
if(e[i][0].tags[j] === 'subsubcategory--Oral Sprays') {
e[i][0].type = 'spray';
}
let minTHC = e[i][0].meta.variant.thc_min_per === undefined || e[i][0].meta.variant.thc_min_per === null ? null : new Big(e[i][0].meta.variant.thc_min_per);
let maxTHC = e[i][0].meta.variant.thc_max_per === undefined || e[i][0].meta.variant.thc_max_per === null ? null : new Big(e[i][0].meta.variant.thc_max_per);
let minCBD = e[i][0].meta.variant.cbd_min_per === undefined || e[i][0].meta.variant.cbd_min_per === null ? null : new Big(e[i][0].meta.variant.cbd_min_per);
let maxCBD = e[i][0].meta.variant.cbd_max_per === undefined || e[i][0].meta.variant.cbd_max_per === null ? null : new Big(e[i][0].meta.variant.cbd_max_per);
if(e[i][0].handle === 'rest-cove-pink-kush' || e[i][0].handle === 'thc-indica-aces-pre-roll-aurora') {//high I'm a dumbfuck that works at ocs and I don't know how to multiply by 10 :)
minTHC = e[i][0].meta.product.thc_content_min === undefined || e[i][0].meta.product.thc_content_min === null ? null : (new Big(e[i][0].meta.product.thc_content_min)).times(10);
maxTHC = e[i][0].meta.product.thc_content_max === undefined || e[i][0].meta.product.thc_content_max === null ? null : (new Big(e[i][0].meta.product.thc_content_max)).times(10);
minCBD = e[i][0].meta.product.cbd_content_min === undefined || e[i][0].meta.product.cbd_content_min === null ? null : (new Big(e[i][0].meta.product.cbd_content_min)).times(10);
maxCBD = e[i][0].meta.product.cbd_content_max === undefined || e[i][0].meta.product.cbd_content_max === null ? null : (new Big(e[i][0].meta.product.cbd_content_max)).times(10);
} else if(e[i][0].handle === 'lemon-skunk-oil-dna-genetics') {
minTHC = e[i][0].meta.variant.thc_min_per_secondary === undefined || e[i][0].meta.variant.thc_min_per_secondary === null ? null : new Big(e[i][0].meta.variant.thc_min_per_secondary);
maxTHC = e[i][0].meta.variant.thc_max_per_secondary === undefined || e[i][0].meta.variant.thc_max_per_secondary === null ? null : new Big(e[i][0].meta.variant.thc_max_per_secondary);
minCBD = e[i][0].meta.variant.cbd_min_per_secondary === undefined || e[i][0].meta.variant.cbd_min_per_secondary === null ? null : new Big(e[i][0].meta.variant.cbd_min_per_secondary);
maxCBD = e[i][0].meta.variant.cbd_max_per_secondary === undefined || e[i][0].meta.variant.cbd_max_per_secondary === null ? null : new Big(e[i][0].meta.variant.cbd_max_per_secondary);
} else if(e[i][0].handle === 'thc-softgel-capsules-vertical-expedus') {
minTHC = maxTHC = new Big(8);
minCBD = new Big(0);
maxCBD = new Big(1);
} else if(e[i][0].handle === 'balanced-softgel-capsules-vertical-umbrae') {
minTHC = maxTHC = new Big(6);
minCBD = maxCBD = new Big(8);
if(e[i][0].type === 'flower' || e[i][0].type === 'preroll' || e[i][0].type === 'cartridge' || e[i][0].type === 'disposable') {
minTHC = percent2proportion(e[i][0].meta.product.thc_content_min);
maxTHC = percent2proportion(e[i][0].meta.product.thc_content_max);
minCBD = percent2proportion(e[i][0].meta.product.cbd_content_min);
maxCBD = percent2proportion(e[i][0].meta.product.cbd_content_max);
unit = 'proportion';
} else {
minTHC = e[i][0].meta.variant.thc_min_per
maxTHC = e[i][0].meta.variant.thc_max_per;
minCBD = e[i][0].meta.variant.cbd_min_per;
maxCBD = e[i][0].meta.variant.cbd_max_per;
unit = 'mg';
if(e[i][0].type === 'spray' || e[i][0].type === 'oil' || e[i][0].type === 'tea') {
UOM = 'ml';
} else if(e[i][0].type === 'capsule') {
UOM = 'capsules';
if(e[i][0].type === 'tea' || e[i][0].type === 'gummy' || e[i][0].type === 'mint' || e[i][0].type === 'chocolate' || e[i][0].type === 'baked' && ok(minTHC, maxTHC, minCBD, maxCBD)) {
let [portions, quantity] = pq(e[i][0], e[i][0].type);
if(portions !== null) {
quantity = (new Big(quantity)).times(portions);
if(e[i][0].type === 'chocolate' || e[i][0].type === 'gummy' || e[i][0].type === 'mint' || e[i][0].type === 'spray' || e[i][0].type === 'tea') {
let n = e[i][0].meta.variant;
if(e[i][0].type === 'spray') {
n = new Big(n.retail_pack_net_content);
} else {
n = new Big(n.retail_pack_number_of_items);
}
minTHC = (new Big(minTHC)).div(n).toString();
maxTHC = (new Big(maxTHC)).div(n).toString();
minCBD = (new Big(minCBD)).div(n).toString();
minCBD = (new Big(minCBD)).div(n).toString();
}
minTHC = (new Big(minTHC)).div(quantity);
maxTHC = (new Big(maxTHC)).div(quantity);
minCBD = (new Big(minCBD)).div(quantity);
maxCBD = (new Big(maxCBD)).div(quantity);
f2 = e[i][0].tags[f].substring(12);
f2 = e[i][0].tags[j].substring(12);
} else if(e[i][0].tags[j] === 'subsubcategory--Oral Sprays' && ok(minTHC, maxTHC, minCBD, maxCBD)) {
let [, quantity] = pq(e[i][0], e[i][0].type = 'spray');//assume 1 bottle only
minTHC = (new Big(minTHC)).div(10).div(quantity);
maxTHC = (new Big(maxTHC)).div(10).div(quantity);
minCBD = (new Big(minCBD)).div(10).div(quantity);
maxCBD = (new Big(maxCBD)).div(10).div(quantity);
} else if(e[i][0].tags[j].startsWith('terpenes--')) {
if(terpenes === null) {
terpenes = [];
}
let terpene = e[i][0].tags[j].substring(10).toLowerCase();
if(terpene) {
if(terpene.includes('remove')) {
if(terpenes.length) {
console.log(terpenes);
console.log(e[i][0].tags);
console.log(`${url}/products/${e[i][0].handle}`);
}
terpenes = [];
} else {
terpenes.push(terpene);
}
}
}
let terpenes = [];
for(let j = 0; j < e[i][0].tags.length; ++j) {
if(e[i][0].tags[j].startsWith('terpenes--')) {
let terpene = e[i][0].tags[j].substring(10).toLowerCase();
if(terpene) {
if(terpene.includes('remove')) {
if(terpenes.length) {
console.log(terpenes);
console.log(e[i][0].tags);
console.log(`${url}/products/${e[i][0].handle}`);
}
terpenes = null;
break;
} else {
terpenes.push(terpene);
}
}
let temp = description.toLowerCase();
if(temp.includes('terpene') && temp.includes('remove')) {
terpenes = [];
$1, $2, $3, $4, $5, $6, (select id from strain_family where joined_name = $7), $8, $9, $10, true, $11
$1, $2, $3, $4, $5, $6, (select id from strain_family where joined_name = $7), $8, true, $9${brand === 'dosist' ? `,$${ppams.push('2.25')}` : ''}
[
producer,
brand,
name,
join_name,
e[i][0].type,
strain,
strain_family_clean(quickview.product.metafields.product.street_name),
description,
unit,
UOM,
terpenes
]
ppams
}
let portions;
let quantity;
if(e[i][j].variant_title === 'Default Title') {
portions = e[i][j].meta.variant.retail_pack_number_of_items
quantity = e[i][j].meta.variant.retail_pack_net_content;
} else {
[, , portions, quantity] = e[i][j].variant_title.match(qty);
if(portions === undefined && e[i][0/*since we only modify the first index*/].type === 'preroll' && e[i][j].meta.variant.retail_pack_number_of_items > 1) {
portions = e[i][j].meta.variant.retail_pack_number_of_items;
quantity = (new Big(quantity)).div(portions).toString();
}
}
if(!portions || portions < 2) {
portions = null;
if(ok(minCBD, maxCBD, minTHC, maxTHC, e[i][j].price, e[i][j].inventory_quantity) && minCBD > 0 || maxCBD > 0 || minTHC > 0 || maxTHC > 0) {
if(ok(minCBD, maxCBD, minTHC, maxTHC, e[i][j].price, e[i][j].inventory_quantity) && (minCBD.gt(0) || maxCBD.gt(0) || minTHC.gt(0) || maxTHC.gt(0))) {