Skip to content

Instantly share code, notes, and snippets.

View mijimoco's full-sized avatar

Serhan 德睿 mijimoco

View GitHub Profile
@mijimoco
mijimoco / functions.php
Created December 1, 2016 13:25
Woocommerce remove billing&shipping fields from checkout form
// Hook in to Remove Checkout Fields
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
function custom_override_checkout_fields( $fields ) {
unset($fields['billing']['billing_state']);
unset($fields['billing']['billing_address_2']);
unset($fields['billing']['billing_city']);
unset($fields['billing']['billing_postcode']);
unset($fields['billing']['billing_country']);
@mijimoco
mijimoco / functions.php
Created December 1, 2016 13:26
Hide shipping rates when free shipping is available
/**
* 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 ) {
@mijimoco
mijimoco / functions.php
Last active December 1, 2016 13:29
Woocommerce add a custom field to checkout form (ex: tax number 統一編號 in Chinese)
/**
* Add new field to Checkout
*/
// Hook in
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields_add_tongbian' );
// Our hooked in function - $fields is passed via the filter!
function custom_override_checkout_fields_add_tongbian( $fields ) {
$fields['billing']['billing_tongbian'] = array(
@mijimoco
mijimoco / functions.php
Created December 1, 2016 13:30
Woocommerce checkout form - Reorder billing fields
/*
* Reorder Billing Field
*/
add_filter( 'woocommerce_checkout_fields', 'reorder_billing_fields');
function reorder_billing_fields($fields) {
$order = array(
'billing_first_name',
'billing_last_name',
@mijimoco
mijimoco / check-for-palindromes-challenge.markdown
Last active January 10, 2017 08:14
Check for Palindromes Challenge
@mijimoco
mijimoco / find-the-longest-word-in-an-array.markdown
Created January 11, 2017 10:39
Find the Longest Word in an Array
@mijimoco
mijimoco / return-largetst-numbers-in-array.markdown
Created January 14, 2017 05:58
Return Largetst Numbers in Array
@mijimoco
mijimoco / confirm-the-ending.markdown
Created January 17, 2017 12:03
Confirm the Ending
@mijimoco
mijimoco / repeat-a-string-repeat-a-string.markdown
Created January 17, 2017 12:34
Repeat a string repeat a string
@mijimoco
mijimoco / script.js
Created January 18, 2017 22:45
Truncate a string
function truncateString(str, num) {
// Clear out that junk in your trunk
var trunStr = "";
if (str.length>num){ //first checking wheter given string needs to truncated
if (num>3) { // check whether given num is bigger than 3 or not
trunStr = str.slice(0, num-3); //we need to take additional 3 from the ...
console.log(trunStr);