Skip to content

Instantly share code, notes, and snippets.

View danichim's full-sized avatar

Dan Ichim danichim

View GitHub Profile
@danichim
danichim / gist:f2891ad306481f0eec1233da8ab9729f
Created February 21, 2022 19:25
date-estimate-delivery.php
add_action('woocommerce_after_add_to_cart_form', 'cjuk_estimated_delivery');
function cjuk_estimated_delivery(){
date_default_timezone_set( 'Europe/Bucharest' );
//$today = date_i18n("j F, Y"); //, strtotime('+2 days')
if ( date( 'N' ) <= 4 ) {
$today = date_i18n("j F, Y", strtotime('+1 day'));
$today2 = date_i18n("j F, Y", strtotime('+3 days'));
}
if (date('N') === 5 && date('H') < 16) {
@danichim
danichim / tampermonkey.txt
Last active November 10, 2021 16:36
tiktokbuttons
{"created_by":"Tampermonkey","version":"1","scripts":[{"name":"Tiktok Scripts","options":{"check_for_updates":false,"comment":null,"compatopts_for_requires":true,"compat_wrappedjsobject":false,"compat_metadata":false,"compat_foreach":false,"compat_prototypes":false,"noframes":null,"run_at":null,"override":{"merge_connects":true,"merge_excludes":true,"merge_includes":true,"merge_matches":true,"orig_connects":[],"orig_excludes":[],"orig_includes":[],"orig_matches":["https://www.tiktok.com/*"],"orig_noframes":null,"orig_run_at":"document-idle","use_blockers":[],"use_connects":[],"use_excludes":[],"use_includes":[],"use_matches":[]}},"storage":{"data":{},"ts":1636394651269},"enabled":true,"position":1,"uuid":"942abbe1-ca30-40b2-9f8b-b5873595fce8","source":"Ly8gPT1Vc2VyU2NyaXB0PT0KLy8gQG5hbWUgICAgICAgICBUaWt0b2sgU2NyaXB0cwovLyBAbmFtZXNwYWNlICAgIGh0dHA6Ly90YW1wZXJtb25rZXkubmV0LwovLyBAdmVyc2lvbiAgICAgIDAuMQovLyBAZGVzY3JpcHRpb24gIHRyeSB0byB0YWtlIG92ZXIgdGhlIHdvcmxkIQovLyBAYXV0aG9yICAgICAgIERhbiBJY2hpbQovLyBAbWF0Y2ggI
@danichim
danichim / order-by-meta-value.php
Created March 15, 2021 09:04
order by custom meta field date
$args = array(
'post_type' => 'event',
'order' => 'DESC',
'orderby' => 'meta_value',
'meta_key' => 'start_date',
'meta_query' => array(
array(
'key' => 'start_date',
'value' => date('Ymd'),
'compare' => '>='
@danichim
danichim / wccheckout.php
Last active February 20, 2021 21:51
check number and country at checkout
add_action('woocommerce_checkout_process', 'check_phone_number_length');
function check_phone_number_length() {
global $woocommerce;
if ( !(preg_match('/^[0-9]{10}$/D', $_POST['billing_phone'] )) && $_POST['billing_country'] == 'RO') {
wc_add_notice( "<strong>Telefon</strong> Număr incorect ! Trebuie să conțină 10 cifre" ,'error' );
}
}
@danichim
danichim / woocommerce-optimize-scripts.php
Created February 15, 2021 10:11 — forked from apsolut/woocommerce-optimize-scripts.php
Only load WooCommerce scripts on shop pages and checkout + cart
/**
* 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
remove_action( 'wp_head', array( $GLOBALS['woocommerce'], 'generator' ) );
@danichim
danichim / training-RN.md
Last active April 6, 2020 09:28
React Native Prerequisites

Introduction

React Native makes it possible to make native iOS and Android mobile apps without needing to know any iOS or Android programming - just JavaScript!

In this training, we'll write a simple mobile app that you can run on your own phone and share with your friends!

Prerequisites

In order to take advantage this training, you should have the following experience.

@danichim
danichim / hide-other-shipping.php
Created November 20, 2019 21:55
ascunde alte metode cand ai free shipping wc 3.0+
/**
* Hide shipping rates when free shipping is available.
* Updated to support WooCommerce 2.6 Shipping Zones.
*
* @param array $rates Array of rates found for the package.
* @return array
*/
function my_hide_shipping_when_free_is_available( $rates ) {
$free = array();
foreach ( $rates as $rate_id => $rate ) {
@danichim
danichim / d-visibility-hidden.css
Created September 11, 2019 07:37
A utility class to hide content visually, but leave it available to assistive technologies
.d-visibility-hidden {
border: none !important;
clip: rect(0 0 0 0) !important;
height: 1px !important;
margin: -1px !important;
overflow: hidden !important;
padding: 0 !important;
position: absolute !important;
white-space: nowrap !important;
width: 1px !important;
@danichim
danichim / validate-length-billing-phone-and-shipping-phone-woocommerce.php
Created November 7, 2018 20:26
validate length billing phone and shipping phone woocommerce
add_action('woocommerce_checkout_process', 'check_phone_number_length');
function check_phone_number_length() {
global $woocommerce;
if ( ! (preg_match('/^[0-9]{10}$/D', $_POST['billing_phone'] ))){
wc_add_notice( "<strong>Telefon facturare</strong> Număr incorect ! Trebuie să conțină 10 cifre" ,'error' );
}
if (isset($_POST['shipping_phone']) && !empty($_POST['shipping_phone'])) {
if ( ! (preg_match('/^[0-9]{10}$/D', $_POST['shipping_phone'] ))){
wc_add_notice( "<strong>Telefon livrare</strong> Număr incorect ! Trebuie să conțină 10 cifre" ,'error' );
}