Skip to content

Instantly share code, notes, and snippets.

@ddbs
ddbs / woocommerce-remove-from-price.php
Created March 22, 2014 23:58 — forked from BFTrick/woocommerce-remove-from-price.php
Disable the WooCommerce variable product "From: $X" price.
<?php
/**
* Plugin Name: WooCommerce Remove Variation "From: $XX" Price
* Plugin URI: https://gist.github.com/BFTrick/7643587
* Description: Disable the WooCommerce variable product "From: $X" price.
* Author: Patrick Rauland
* Author URI: http://patrickrauland.com/
* Version: 1.0
*
* This program is free software: you can redistribute it and/or modify
<?php
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
function custom_override_checkout_fields( $fields ) {
unset($fields['billing']['billing_first_name']);
unset($fields['billing']['billing_last_name']);
unset($fields['billing']['billing_company']);
unset($fields['billing']['billing_address_1']);
unset($fields['billing']['billing_address_2']);
<?php
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
function custom_override_checkout_fields( $fields ) {
unset($fields['billing']['billing_first_name']);
unset($fields['billing']['billing_last_name']);
unset($fields['billing']['billing_company']);
unset($fields['billing']['billing_address_1']);
unset($fields['billing']['billing_address_2']);
remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 );
<?php
/**
* Code goes in functions.php or a custom plugin.
*/
add_filter( 'woocommerce_states', 'malaysia_woocommerce_states' );
function malaysia_woocommerce_states( $states ) {
$states['MY'] = array(
'JHR' => __('Johor', 'woocommerce') ,
@ddbs
ddbs / functions.php
Last active August 29, 2015 14:01 — forked from claudiosanches/functions.php
WooCommerce: Hide price and add-to-cart button for non-logged in users.
//Hide price and add-to-cart button for non-logged in users.
function woocommerce_template_loop_price() {
if ( is_user_logged_in() )
woocommerce_get_template( 'loop/price.php' );
}
function woocommerce_template_loop_add_to_cart() {
if ( is_user_logged_in() )
woocommerce_get_template( 'loop/add-to-cart.php' );
@ddbs
ddbs / .gitignore
Last active August 29, 2015 14:27 — forked from octocat/.gitignore
Some common .gitignore configurations
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
@ddbs
ddbs / 0_reuse_code.js
Created November 28, 2015 09:56
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@ddbs
ddbs / stratifiedCV.r
Created June 5, 2016 23:41 — forked from mrecos/stratifiedCV.r
Stratified K-folds Cross-Validation with Caret
require(caret)
#load some data
data(USArrests)
### Prepare Data (postive observations)
# add a column to be the strata. In this case it is states, it can be sites, or other locations
# the original data has 50 rows, so this adds a state label to 10 consecutive observations
USArrests$state <- c(rep(c("PA","MD","DE","NY","NJ"), each = 5))
# this replaces the existing rownames (states) with a simple numerical index
@ddbs
ddbs / ipak.R
Created October 19, 2016 22:04 — forked from stevenworthington/ipak.R
Install and load multiple R packages at once
# ipak function: install and load multiple R packages.
# check to see if packages are installed. Install them if they are not, then load them into the R session.
ipak <- function(pkg){
new.pkg <- pkg[!(pkg %in% installed.packages()[, "Package"])]
if (length(new.pkg))
install.packages(new.pkg, dependencies = TRUE)
sapply(pkg, require, character.only = TRUE)
}