Skip to content

Instantly share code, notes, and snippets.

View guilhermemarconi's full-sized avatar

Guilherme Marconi guilhermemarconi

  • Brazil
  • 16:25 (UTC -03:00)
View GitHub Profile
@guilhermemarconi
guilhermemarconi / woocommerce-optimize-scripts.php
Last active October 14, 2015 20:38 — forked from DevinWalker/woocommerce-optimize-scripts.php
Only load WooCommerce scripts on shop pages and checkout + cart
<?php
/**
* Optimize WooCommerce Scripts
* Remove WooCommerce Generator tag, styles, and scripts from non WooCommerce pages.
*/
add_action( 'wp_enqueue_scripts', 'child_manage_woocommerce_styles', 99 );
function child_manage_woocommerce_styles() {
//remove generator meta tag
body.on('click', '.js-add-to-cart', function(event) {
var sizeSelected = $('.size-selected').find(':selected'),
skuId = parseInt($('.size-selection').val()),
skuQty = parseInt($('.qty-selection').val()),
skuName = sizeSelected.text(),
skuPrice = sizeSelected.data('sku-price'),
skuCache = $('.size-selection').data('cache-version'),
requestUrl = '/checkout/cart/add?sku=' + skuId + '&qty=' + skuQty + '&price=' + skuPrice + '&seller=1&cv=' + skuCache + '&sc=1';
event.preventDefault();
https://instagram.com/oauth/authorize/?client_id=e4e2e067732640baa760eb82d0a624a8&redirect_uri=http://guilhermemarconi.me/instagram/&response_type=token
{
"recommendations": [
"thisismanta.stylus-supremacy"
]
}
@guilhermemarconi
guilhermemarconi / discount.js
Last active January 16, 2018 17:25
Este script não escreve nada no DOM. Apenas retorna o preço formatado no console. É preciso pegar o resultado desse cálculo e imprimir no DOM, no lugar certo.
$.ajax('/api/catalog_system/pub/products/search?fq=productId:' + skuJson.productId)
.done(function(product) {
product = product[0];
if (!product['Desconto progressivo'][0]) return;
/**
* Pega a porcentagem de desconto, de acordo com a descrição da promoção
* Ex.: "<b>GANHE 10% DE DESCONTO</b> COLOCANDO <b>12 UNIDADES</b> OU MAIS NO CARRINHO."
*/
var discountBase = +product['Desconto progressivo'][0].match(/\d+\%/g)[0].replace('%','');
// Pega o preço do SKU
@guilhermemarconi
guilhermemarconi / gist:b20b835d552ccaf63f8d0127f0f283d3
Last active January 4, 2019 20:43
Endpoint para buscar, externamente, os pedidos de um usuário específico na VTEX
/api/checkout/pub/orders/?customerEmail=${email}
//marketingData Example
//vtexjs.checkout.orderForm.marketingData
import { getCookie } from 'path/to/cookies.js'
utms = {
utmCampaign: (getCookie('IPS') && ~getCookie('IPS').indexOf('Campanha') ? getCookie('IPS').split('Campanha=')[1].split('&')[0] : ""),
utmMedium: (getCookie('IPS') && ~getCookie('IPS').indexOf('Midia') ? getCookie('IPS').split('Midia=')[1].split('&')[0] : ""),
utmSource: (getCookie('IPS') && ~getCookie('IPS').indexOf('Parceiro') ? getCookie('IPS').split('Parceiro=')[1].split('&')[0] : ""),
utmiCampaign: (getCookie('ISICI') && ~getCookie('ISICI').indexOf('InternalCampaign') ? getCookie('ISICI').split('InternalCampaign=')[1].split('&')[0] : ""),
utmiPart: (getCookie('ISICI') && ~getCookie('ISICI').indexOf('InternalPart') ? getCookie('ISICI').split('InternalPart=')[1].split('&')[0] : "")
@guilhermemarconi
guilhermemarconi / deleteAddress.js
Last active June 20, 2024 02:11
Deal with User Profile and User Addresses in VTEX
fetch(`/no-cache/postalcode/address/delete/${addressName}`, {
credentials: 'same-origin',
})
.then(res => res.json())
.then(addressData => {
// ...
})
@guilhermemarconi
guilhermemarconi / .zshconfig
Last active August 28, 2019 21:18
Oh-My-ZSH configuration file
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH="/home/marconi/.oh-my-zsh"
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
function gco
git checkout $argv
end
function gb
git branch $argv
end
function gcm
git checkout master
end
function gcd