Skip to content

Instantly share code, notes, and snippets.

View Luminus's full-sized avatar

Luminus Olumide Alabi Luminus

View GitHub Profile
@WillBrubaker
WillBrubaker / gist:dc691d9df80aa63fc9ac
Created May 28, 2015 10:22
Change the WooCommerce Bookings "Persons" label to something else
add_filter( 'booking_form_fields', 'wooninja_booking_form_fields' );
function wooninja_booking_form_fields( $fields ) {
$fields['wc_bookings_field_persons']['label'] = 'SOMETHING ELSE';
return $fields;
}
@johnbillion
johnbillion / wp_mail.md
Last active June 3, 2024 13:31
WordPress Emails

WordPress Emails

This document lists all the situations where WordPress sends an email, along with how to filter or disable each email.

This documentation has moved here: https://github.com/johnbillion/wp_mail

@bekarice
bekarice / filter-wc-orders-by-gateway.php
Last active August 3, 2023 13:37
Filters WooCommerce Orders by Payment Gateway Used
<?php
/**
* Plugin Name: Filter WooCommerce Orders by Payment Method
* Plugin URI: http://skyverge.com/
* Description: Filters WooCommerce orders by the payment method used :)
* Author: SkyVerge
* Author URI: http://www.skyverge.com/
* Version: 1.0.0
* Text Domain: wc-filter-orders-by-payment
*
@gedex
gedex / custom_rule_cost_distance_shipping.php
Created August 30, 2017 06:31
Override rule cost for distance shipping when destination within 5miles of shop AND order total over $100
<?php
add_filter( 'woocommerce_distance_rate_shipping_rule_cost_distance_shipping', function( $rule_cost, $rule, $distance, $package ) {
$order_total = $package['contents_cost'];
if ( $order_total > 100 && $distance <= 5 ) {
$rule_cost = 0;
}
return $rule_cost;
}, 10, 4 );
@rynaldos-zz
rynaldos-zz / wc-force-tc-new-tab.php
Last active December 14, 2020 17:37
[WooCommerce 3.0+] Disable terms and conditions toggle and force it to open in a new tab
function disable_wc_terms_toggle() {
wp_enqueue_script( 'disable-terms-toggle', '/disable-terms-toggle.js', array( 'wc-checkout', 'jquery' ), null, true );
wp_add_inline_script( 'disable-terms-toggle', "jQuery( document ).ready( function() { jQuery( document.body ).off( 'click', 'a.woocommerce-terms-and-conditions-link' ); } );" );
}
add_action( 'wp_enqueue_scripts', 'disable_wc_terms_toggle', 1000 );
// This snippet can be used alongside https://gist.github.com/rynaldos/0bee7d84a83c5b52096c747c19d088c0 (custom terms and conditions link)
@madeincosmos
madeincosmos / functions.php
Created December 1, 2017 09:51
Automatically approve registered vendors
function automaticallyApproveRegisteredVendors ( $vendorData ) {
$vendorData['role'] = 'wc_product_vendors_admin_vendor';
return $vendorData;
}
add_filter( 'wcpv_registration_default_user_data', 'automaticallyApproveRegisteredVendors', 10, 1);
@rynaldos-zz
rynaldos-zz / wc-sort-checkout-countries-custom.php
Last active July 2, 2020 05:27
[WooCommerce 3.0+] Custom sorting for checkout page country dropdown
// disable woocommerce sorting
add_filter( 'woocommerce_sort_countries', '__return_false' );
add_filter( 'woocommerce_countries', 'wc_custom_countries_order', 10, 1 );
function wc_custom_countries_order( $countries ) {
// replace with iso code of the country (example: US or GB)
unset($countries['country_1_iso_code']);
unset($countries['country_2_iso_code']);
unset($countries['country_3_iso_code']);
// replace with iso code of country AND country name (example: US | United States or GB | United Kingdom (UK)
@jessepearson
jessepearson / rewrite-wc-bookings-get-time-slots-html.php
Last active August 7, 2023 14:48
Make it so that all time slots in a time-based booking in WooCommerce Bookings shows how many spots remain, not just partially booked blocks.
<?php // do not copy this line
function rewrite_wc_bookings_get_time_slots_html( $block_html, $available_blocks, $blocks ) {
$block_html = '';
foreach ( $available_blocks as $block => $quantity ) {
if ( $quantity['available'] > 0 ) {
$block_html .= '<li class="block" data-block="' . esc_attr( date( 'Hi', $block ) ) . '"><a href="#" data-value="' . date( 'c', $block ) . '">' . date_i18n( get_option( 'time_format' ), $block ) . ' <small class="booking-spaces-left">(' . sprintf( _n( '%d left', '%d left', $quantity['available'], 'woocommerce-bookings' ), absint( $quantity['available'] ) ) . ')</small></a></li>';
}
@WillBrubaker
WillBrubaker / file.php
Created March 15, 2018 13:54
WooCommerce Bookings: Remove all available blocks for the day if one is booked
//Don't know what to do with this? See https://www.thathandsomebeardedguy.com/what-do-i-do-with-these-code-snippets/
add_filter( 'wc_bookings_product_get_available_blocks', 'beardedguy_maybe_remove_availability', 10, 5 );
function beardedguy_maybe_remove_availability( $available_blocks, $booking_object, $blocks, $intervals, $resource_id ) {
return ( sizeof( $available_blocks ) < sizeof( $blocks ) ) ? array() : $available_blocks;
}
@Juul
Juul / amazon_fire_2015_7_inc_lineageos_install.md
Last active June 23, 2024 17:51
How to install install LineageOS on a 2015 7" Amazon Fire tablet

This is a guide for getting LineageOS (an older and unofficial version) onto an Amazon Fire 2015 7" tablet (also known as the 5th generation 7" Amazon Fire or under the internal codename "ford").

NOTE: This guide was originally written before someone figured out how to unlock the bootloader. There is now a newer method. Here it is very briefly. The old guide can be found below.

Unlocked bootloader method

First unlock the bootloader using this guide.

Once you're booted into TWRP download the latest LineageOS 14 release for your device here.