Skip to content

Instantly share code, notes, and snippets.

View woogists's full-sized avatar

WooGists woogists

View GitHub Profile
@woogists
woogists / wc-bookings-modify-in-cart-bookings-expiry.php
Created March 9, 2018 16:20
[WooCommerce Bookings] Modify when In Cart bookings expire
/**
* Will change the minutes it takes an In Cart booking to expire.
* This example reduces the number from 60 to 30.
*
* @param int $minutes 60 is the default passed
* @return int The amount of minutes you'd like to have In Cart bookings expire on.
*/
function change_incart_bookings_expiry_minutes_20170825( $minutes ) {
return 30;
}
@woogists
woogists / wc-product-addons-grand-total.css
Created March 9, 2018 16:21
[Product Addons] Customize the "Grand total" and "Options total"
/*Options Total*/
.product-addon-totals dt:nth-child(1) { color:red;}
/*Options Total Sum*/
.product-addon-totals dd:nth-child(2) { color:red;}
/*Grand Total*/
.product-addon-totals dt:nth-child(3) { color:blue;}
/*Grand Total Sum*/
@woogists
woogists / wc-product-addons-set-default-value.js
Last active May 14, 2024 12:41
[Product Addons] Set default input values for addons.
// Set default value to 0 for Custom price input
jQuery(document).ready(function(){
jQuery('.wc-pao-addon-custom-price').val("0");
});
@woogists
woogists / wc-bookings-enable-big-selects-for-bookings.php
Created March 9, 2018 16:24
[WooCommerce Bookings] Enable Big Selects to fix MAX_JOIN_SIZE errors
/**
* Will enable big selects when the host has a low threshold for MAX_JOIN_SIZE.
* This is sometimes the case with shared hosting.
*/
function enable_big_selects_for_bookings_20170825() {
global $wpdb;
$wpdb->query( 'SET SQL_BIG_SELECTS=1' );
}
add_action( 'init', 'enable_big_selects_for_bookings_20170825' );
@woogists
woogists / wc-bookings-automatically-confirm-cod-bookings.php
Created March 9, 2018 16:25
[WooCommerce Bookings] Automatically confirm bookings purchased via COD
/**
* Will put bookings into a Confirmed status if they were paid for via COD.
*
* @param int $order_id The order id
*/
function set_cod_bookings_confirmed_20170825( $order_id ) {
// Get the order, then make sure its payment method is COD.
$order = wc_get_order( $order_id );
if ( 'cod' !== $order->get_payment_method() ) {
@woogists
woogists / wc-adjust-datepicker.php
Created March 9, 2018 16:27
[Checkout field editor] Adjust the datepicker in the Checkout Field Editor plugin.
function custom_adjust_datepicker_range () {
if ( is_checkout() ) {
wp_enqueue_script( 'jquery' );
?>
<script type="text/javascript">
jQuery( document ).ready( function ( e ) {
if ( jQuery( '.checkout-date-picker' ).length ) {
jQuery( '.checkout-date-picker' ).datepicker( 'option', 'changeYear', true );
jQuery( '.checkout-date-picker' ).datepicker( 'option', 'yearRange', '-40:+0' );
}
@woogists
woogists / wc-bookable-product-to-dependencies.php
Created March 9, 2018 16:27
[WooCommerce Bookings] - Product Dependencies
/**
* Will make it so the Dependencies tab shows on a Bookable product.
*
* @param array $tabs The list of tabs in a product's settings.
*/
function add_bookable_product_to_dependencies( $tabs ) {
// Check to see if the class exists and if the tab is set.
if ( class_exists( 'WC_Product_Dependencies' ) && isset( $tabs['dependencies'] ) ) {
// If so, add our class for the JS hooks.
$tabs['dependencies']['class'][] = 'show_if_booking';
@woogists
woogists / wc-set-default-radio-field.php
Created March 9, 2018 16:28
[Checkout Field Editor] Setting a default value for a radio button field
function custom_override_checkout_fields ( $fields ) {
$fields['billing']['test_radio']['default'] = 'one';
return $fields;
} // End custom_override_checkout_fields()
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
@woogists
woogists / wc-bookings-mdy-format.php
Created March 9, 2018 16:28
[WooCommerce Bookings] Change date format when calendar picker is not used in front end
/**
* Will make it so that the date format when the calendar is not used is DD/MM/YYYY on a Bookable product.
*/
add_filter( 'woocommerce_bookings_mdy_format' , '__return_false' );
@woogists
woogists / wc-add-custom-field.php
Created March 9, 2018 16:29
[Checkout field editor] Add custom fields to WebHooks API
/* WooCommerce - extends woocommerce checkout field editor */
/* adds additional display areas (Admin edit user screen and WooCommerce WebHooks */
/**
* add custom checkout fields to user profile on admin edit screen
*
* @param mixed $payload
*/
function filter_woocommerce_admin_profile__custom_checkout_fields( $payload ) {
if ( class_exists( 'WC_Checkout_Field_Editor' ) ) {
$fieldgroups = array( 'billing'=>'billing', 'shipping'=>'shipping', 'additional'=>'additional' );