Skip to content

Instantly share code, notes, and snippets.

@BurlesonBrad
Created April 9, 2015 20:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BurlesonBrad/2f249e5834e810e26b76 to your computer and use it in GitHub Desktop.
Save BurlesonBrad/2f249e5834e810e26b76 to your computer and use it in GitHub Desktop.
checkout fields
<?php
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
function custom_override_checkout_fields( $fields ) {
unset($fields['billing']['billing_company']);
unset($fields['billing']['billing_address_1']);
unset($fields['billing']['billing_address_2']);
unset($fields['billing']['billing_city']);
unset($fields['billing']['billing_postcode']);
unset($fields['billing']['billing_country']);
unset($fields['billing']['billing_state']);
unset($fields['billing']['billing_phone']);
unset($fields['billing']['billing_address_2']);
unset($fields['billing']['billing_postcode']);
unset($fields['billing']['billing_company']);
unset($fields['billing']['billing_city']);
return $fields;
}
// Hook in
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
// Our hooked in function - $fields is passed via the filter!
function custom_override_checkout_fields( $fields ) {
$fields['order']['order_comments']['placeholder'] = 'We need you to type in the addresses here';
$fields['order']['order_comments']['label'] = 'Be sure they are correct. Thanks!';
return $fields;
}
//set the default quantity to one//
add_filter( 'woocommerce_quantity_input_args', 'jk_woocommerce_quantity_input_args', 10, 2 );
function jk_woocommerce_quantity_input_args( $args, $product ) {
$args['input_value'] = 1;
//Increment Buttons//
add_action( 'wp_enqueue_scripts', 'wcs_dequeue_quantity' );
function wcs_dequeue_quantity() {
wp_dequeue_style( 'wcqi-css' );
}
add_action( 'wp_enqueue_scripts', 'wcqi_enqueue_polyfill' );
function wcqi_enqueue_polyfill() {
wp_enqueue_script( 'wcqi-number-polyfill' );
}
/* Custom Code to get WooCommerce One Page Checkout to work with The One Pager */
class SG_OPC_Mods {
private static $modified_opc_properties = false;
public static function init() {
add_action( 'wp_enqueue_scripts', array( __CLASS__, 'always_load_opc' ), 5 );
add_filter( 'is_wcopc_checkout', '__return_true' );
}
public static function always_load_opc() {
global $post;
if ( class_exists( 'PP_One_Page_Checkout' ) && false === PP_One_Page_Checkout::$add_scripts ) {
PP_One_Page_Checkout::$add_scripts = true;
PP_One_Page_Checkout::$shortcode_page_id = $post->ID;
PP_One_Page_Checkout::enqueue_scripts();
self::$modified_opc_properties = true;
}
}
}
SG_OPC_Mods::init();
@altendorfme
Copy link

Thanks for SG_OPC_Mods!

@ShaneJohnsonCC
Copy link

BRO!! Yes ditto what @altendorfme said! SG_OPC_Mods is brilliant!

@TannerHolm
Copy link

@BurlesonBrad Thank you very much for the SG_OPC_Mods!! Life saver!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment