Skip to content

Instantly share code, notes, and snippets.

View tiagomatos's full-sized avatar

Tiago Matos tiagomatos

View GitHub Profile
@tiagomatos
tiagomatos / restore_s3_objects_from_glacier.rb
Created December 8, 2017 16:44
Restore S3 Objects from Glacier
s3 = Aws::S3::Resource.new
keys = s3.bucket("jumpseller").objects(prefix: "store/store-name/").collect(&:key)
keys = keys.delete_if {|key| key.include?('themes') || key.include?('assets') || key.include?('pages') || key.include?('logo') } # selecting only products.
keys.each do |key|
p key
object = s3.bucket('jumpseller').object(key)
begin
object.restore_object({
@tiagomatos
tiagomatos / restore_deleted_S3_objects.rb
Created June 29, 2017 00:39
Restore Deleted S3 Objects
# make sure you have the IAM policy allowed to do: "s3:DeleteObject"
# read: http://docs.aws.amazon.com/AmazonS3/latest/dev/RemDelMarker.html
client = Aws::S3::Client.new
ovs = client.list_object_versions(bucket: 'bucket-name', prefix: "store/store-name/")
ovs.delete_markers.each do |ov|
p "key: #{ov.key} - latest: #{ov.is_latest} - last_modified: #{ov.last_modified}"
client.delete_object({ bucket: 'bucket-name', key: ov.key, version_id: ov.version_id }) # the important part here is deleting the correct version.
end
@tiagomatos
tiagomatos / factura_boleta_validator.liquid
Last active February 6, 2018 18:18
Validate Factura / Boleta presence for Jumpseller Checkout (for Invoicing Systems integration in Chile).
<script type="text/javascript">
// On the Admin Panel Configuration: https://www.evernote.com/l/APbc8GhuD4VCBam1eRbZb_M0Jr-wKdQqTVQ add the Custom Fields:
// Select List (Boleta o Factura) with the options: "Boleta Electrónica" and "Factura Electrónica"
// Input Fields: "Razón Social" and "Giro"
// Store Theme Checkout Form: https://www.evernote.com/l/APYKFPLISu9GpJihPufTIFUiLT7bhyUgWBU
// use this on the Template: "Payment/Checkout" with {% include 'factura_boleta_validator' %}
$(document).ready(function(){
//Chile Tax ID Verifier
$("#order_shipping_address_taxid").attr("pattern", "[0-9]{7,8}-[0-9Kk]{1}"); // with . and . [0-9]{1,2}.[0-9]{3}.[0-9]{3}-[0-9Kk]{1}
$("#order_shipping_address_taxid").attr("placeholder", "ej. 12345678-5");
@tiagomatos
tiagomatos / gist:cf8e7544500a5bd4e776cd5e079e8c16
Last active December 8, 2017 01:11
Validate Chilean RUT in HTML5 (input pattern) - Jumpseller
<script type="text/javascript">
$(document).ready(function(){
$("#order_shipping_address_taxid").attr("pattern", "[0-9]{7,8}-[0-9Kk]{1}"); // with . and . [0-9]{1,2}.[0-9]{3}.[0-9]{3}-[0-9Kk]{1}
$("#order_shipping_address_taxid").attr("placeholder", "12345678-5");
$("#order_shipping_address_taxid").attr("title", "ej. 12345678-5");
});
</script>
@tiagomatos
tiagomatos / gist:903f12b021cf113a9465fefe5cd44dcd
Last active May 3, 2017 22:02
Remove 'Shipping Address' from Checkout
<script type="text/javascript">
$( document ).ready(function() {
$('#shipping_address_same_as_shipping').hide(); // removes the checklist button
$('#shipping_address h2').text('{% t "Billing Address" %}'); // change text
});
</script>
// run in console for a Simple Product (without Product Variants):
// Jumpseller.addProductToCart(12345, 1, {}, {callback: addToCartCallback});
<script type="text/javascript">
function addToCartCallback(data) {
var sum = 0; // num of individual products in the cart.
$.each( data.products, function( index, product ){
sum += product.qty;
});
console.log('cart products sum:');
require 'uri'
require 'net/http'
require 'openssl'
require "benchmark"
HOST = 'api.jumpseller.com'
# uri = URI.parse("http://#{HOST}/landing/pricing?currency=CLP")
uri = URI.parse("http://#{HOST}/v1/products/{product_id}.json?login=XXX&authtoken=XXX")
@tiagomatos
tiagomatos / productVariantListener_product_stock.js
Last active May 16, 2016 23:32
Jumpseller's Javascript method: productVariantListener to display Product stock info
<script type="text/javascript">
// more info at: https://jumpseller.com/support/javascript-library
var callbackFunction = function(event, productInfo){
if(!$.isEmptyObject(productInfo)){
console.log(productInfo);
alert('stock: ' + productInfo.stock + ', stock unlimited?:' + productInfo.stock_unlimited);
}
};
//update Product information with current variant
@tiagomatos
tiagomatos / gist:ce23ca38ffa0e666b8364a18d6e18d64
Created May 11, 2016 18:29
API Product Count through Pagination
require 'httparty'
LOGIN = 'my-store-code'
TOKEN = 'XXXXX'
response = HTTParty.get("https://api.jumpseller.com/v1/products/count.json?login=#{LOGIN}&authtoken=#{TOKEN}")
products_count = response.parsed_response["count"]
pages = products_count / 200 # the number of pages used for pagination.
last_pagination_count = products_count - pages * 200 # calculates the number of products present at the last pagination.
Jumpseller.addProductToCart(336248, 1, {"Sexo":379610, "Modelo":379612, "Color": 379615, "Cuello": 379621, "Manga": 379623})