This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Making Pharmacies Smarter in Jumpseller: Custom Fields & Bioequivalents | |
In Chile, pharmacies are legally required to **show the cheapest bioequivalent medications first** in search results. Makes sense, right? Why push people to pay more when there’s a perfectly good alternative? | |
Now, **Jumpseller doesn’t do this by default**—but we can fix that using **Custom Fields**. The problem? Well... our custom fields setup is a bit like talking to a robot. Ever seen code like `field[0]`? Yeah, super intuitive. Thanks, past developers. | |
But don’t worry—I’ll guide you through **how to add bioequivalents** and **make sure they show up first** in search results, while still keeping Jumpseller’s original search logic intact. | |
--- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
$(function() { | |
fetch("/geocoder/ip", { | |
method: "get" | |
}).then(function (response) { | |
if (response.ok) { | |
return response.json().then(function(json) { | |
var country_code = json["country_code"]; | |
switch(country_code) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
$(document).ready(function() { | |
// Get the variant_id from the parameter | |
const queryString = window.location.search; | |
const urlParams = new URLSearchParams(queryString); | |
if (urlParams.has('variant_id')) { | |
const variant_id = urlParams.get('variant_id') | |
console.log('-------> '+variant_id) | |
var update_function = function(data) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const coupon = "ABCDEFG" | |
var coupons = function(){ | |
i("#payments_options input:checked").val() == 362229 ? Jumpseller.addCouponToCart(coupon , {callback: alert("Cupon Agregado")}) : Jumpseller.removeCouponFromCart(coupon, {callback: alert("No hay cupon")}) ; | |
} | |
$("#checkout").submit(coupons); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function cleanEstimates() { | |
// remove all prices and errors | |
$('#shipping_options li').each(function() { | |
$(this).children().last().detach(); | |
}); | |
// add empty messages - placeholders | |
$('#shipping_options li').each(function() { | |
$(this).append('<span></span>') | |
}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let products = [7966034,7966035]; // Add products IDs here | |
// This may take a while, so it's better to create a loader | |
var setLoading = function(par){if(par){console.log("Inicio")}else{console.log("Inicio")}} | |
setLoading(true); | |
const addListToCart = (index, quantity) => { | |
if(index < products.length){ | |
product = products[index]; | |
Jumpseller.addProductToCart(product, quantity, {}, {callback: addListToCart(++index,quantity)}) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
// Define all codes from many promotions | |
const coupons = ["cupon1", "cupon2", "cupon3"] | |
//Callback that returns all coupons in cart | |
var callback_added = function(data) { | |
console.log(data.coupons) | |
} | |
// Callback that searches intersections between the codes in cart and the promotional codes. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
const shipping_method_id = 1234556 // id of free shipping option | |
const normal_shipping = 654321 // id of normal shipping option | |
const municipalities_free_shipping = ["merchant needs to complete this field"] // Ideally a theme option separated by comma | |
const products_free_shipping = ["merchant needs to complete this field"] // Ideally a theme option separated by comma | |
var conditions = function() { | |
// certain product is in the cart and certain municipalities are selected. The work is to construct this function | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var callbackFunction = function() { | |
console.log("Coupon " + discount + " added") | |
} | |
var add_url_coupon = function() { | |
queryString = window.location.search; | |
urlParams = new URLSearchParams(queryString); | |
if (urlParams.has('discount')) { | |
discount = urlParams.get('discount') | |
Jumpseller.addCouponToCart(discount, { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function() { | |
// Get the variant_id from the parameter | |
const queryString = window.location.search; | |
const urlParams = new URLSearchParams(queryString); | |
if (urlParams.has('variant_id')) { | |
const variant_id = urlParams.get('variant_id') | |
var update_function = function(data) { | |
// Find the variant | |
active_variant = data.variants.find(item => item.id == variant_id) |
NewerOlder