Skip to content

Instantly share code, notes, and snippets.

View machelinos's full-sized avatar

Marcel Cabrera machelinos

View GitHub Profile
@machelinos
machelinos / react-test-setup
Last active September 26, 2022 16:58
Vite - Jest initial setup
React + Vite projects
npm install jest babel-jest @babel/preset-env @babel/preset-react --save-dev
npm install @testing-library/react @types/jest jest-environment-jsdom --save-dev
--------------
Whwen using fetch
npm install whatwg-fetch --save-dev
------------.
@machelinos
machelinos / functions.php
Last active February 11, 2020 01:37
Conditional fields in Woocommerce checkout
<?php
function claserama_cart_only_has_virtual_product()
{
//Primero declaramos algunas variables que ocuparemos
$has_only_virtual=false; //Esta será la variable final que retornaremos y que nos dice si solo hay artículos virtuales en el pedido
$virtual_products = 0; //Primero iniciamos el contador de productos virtuales a 0
$total_products = 0; // Iniciamos el contador de todos los productos a cero
// Vamos a checar cada uno de los elementos que se encuentran en el carrito, uno por uno por medio de la función WC()->cart->get_cart() que nos regresa un objeto con cada uno de los elementos
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
@machelinos
machelinos / functions.php
Last active December 25, 2023 17:33
Several ways to customize checkout fields in woocommerce
<?php
/**
* Función para cambiar de lugar los campos del checkout de Woocommerce
*/
function claserama_rearrange_checkout_fields($fields){
//para mover el orden de los elementos del array, debemos asignar una propiedad de prioridad a cada campo, en nuestro ejemplo le dimos una prioridad menor al email, entonces colocará este campo al principio de nuestra forma
$fields['billing']['billing_email']['priority'] = 10;
$fields['billing']['billing_first_name']['priority'] = 20;
$fields['billing']['billing_last_name']['priority'] = 30;
@machelinos
machelinos / style.css
Created August 7, 2018 17:19
Some Gutenberg block styles for the frontend using SASS and some internal mixins
/*
breakpoint(intern) is a mixin to show this block only on screen sizez bigger than 768px
*/
.alignfull {
@include breakpoint(intern){
margin-left: calc(50% - 50vw);
margin-right: calc(50% - 50vw);
width: auto;
max-width: 1000%;
@machelinos
machelinos / functions.php
Last active August 7, 2018 17:16
Add basic support for Gutenberg wide align and editor palette colors
/* Add support for wide alignment odf images in Gutenberg */
add_theme_support( 'align-wide' );
/* Add 2 colors palette for the editor in Gutenberg */
add_theme_support('editor-color-palette',
array(
array(
'name' => 'primary color',
'color' => '#02b3e4'
),