Skip to content

Instantly share code, notes, and snippets.

View sisaacrussell's full-sized avatar

Isaac Russell sisaacrussell

View GitHub Profile
@woogists
woogists / hide-trailing-zeros-on-prices.php
Last active August 2, 2023 02:25
[General Snippets][Hide trailing zeros on prices]
/**
* Trim zeros in price decimals
**/
add_filter( 'woocommerce_price_trim_zeros', '__return_true' );
@dancameron
dancameron / functions.php
Created June 15, 2018 17:05
Don't show payment terms with a zero balance
<?php // don't include this line in your functions.php, since it already starts with it.
/**
* Don't show fees that are 0.00
**/
add_filter( 'si_show_all_payment_terms', '__return_false' );
@dancameron
dancameron / functions.php
Last active November 27, 2018 18:18
Set Default Due Date to 1st of Next Month
<?php // don't add this line since it's already in your functions.php file
/**
* Edited invoices
*/
function _si_information_meta_box_args( $args ) {
if ( 'auto-draft' == $args['post']->post_status ) { // only adjust drafts
$args['due_date'] = strtotime('first day of next month');
}
return $args;
@xadapter
xadapter / functions.php
Last active January 26, 2022 21:06
Set a default weight and dimensions for the products in your WooCommerce store. Useful for WooCommerce shipping plugins like https://www.pluginhive.com/product-category/woocommerce-plugin/woocommerce-shipping/ Supports ELEX Shipping Plugins https://elextensions.com/product-category/shipping/
/**
* Snippet to set default weight and Dimension if it's not set for any product.
* Created at : 14 May 2018
* Updated at : 16 May 2018
* PluginHive Plugins : https://www.pluginhive.com/product-category/woocommerce-plugin/
* Gist Link : https://gist.github.com/xadapter/4fb8dbfc6c025630558e43488775eb7d
*/
// To set Default Length
add_filter( 'woocommerce_product_get_length', 'xa_product_default_length' );
@dancameron
dancameron / functions.php
Created March 30, 2018 22:29
Set the Default Redirect URL
<?php // don't add this line since it's already in your functions.php file
function _si_redirect_url_meta_fields( $fields ) {
if ( '' === $fields['payment_redirect']['default'] ) {
$fields['payment_redirect']['default'] = 'http://yoursite.com/url/';
}
return $fields;
}
add_filter( 'si_redirect_url_meta_fields', '_si_redirect_url_meta_fields' );
@SJ-James
SJ-James / etModules-icon-codes.css
Created March 21, 2018 21:33
A list of the codes for Divi's built in icon collection
/* example of use */
h1:before {
font-family: 'etModules';
content: "\24";
}
/* codes */
.arrow_up:before {
content: "\21";
@woogists
woogists / wc-add-depending-cart-total.php
Last active November 7, 2022 12:38
Add another product depending on the cart total
/**
* Add another product depending on the cart total
*/
add_action( 'template_redirect', 'add_product_to_cart' );
function add_product_to_cart() {
if ( ! is_admin() ) {
global $woocommerce;
$product_id = 2831; //replace with your product id
$found = false;
$cart_total = 30; //replace with your cart total needed to add above item
@woogists
woogists / usps-remove-priority-flat-rate-envelopes.php
Created March 9, 2018 16:38
[USPS Shipping Method] To remove all the USPS Priority Flat Rate envelopes, leaving only the Small, Medium, and Large Flat Rate boxes, add this to your theme's functions.php file:
/**
* Remove USPS Flat rate envelopes from the available options
* Once added the customer will not see any rates for envelopes
* Only Small, Medium, and Large Flat Rate boxes will be used
*/
add_filter( 'wc_usps_flat_rate_boxes', 'custom_usps_flat_rate_boxes' );
function custom_usps_flat_rate_boxes( $flat_rate_boxes ) {
unset($flat_rate_boxes["d29"]);
unset($flat_rate_boxes["d30"]);
@SJ-James
SJ-James / functions.php
Created January 3, 2018 11:39
Clear Local Storage Button For Divi
<?php
function ClearLocalCacheButton() { ?>
// Create Button
<a href="#" onclick="ClearLocalCache()" class="et-pb-layout-buttons et-pb-layout-buttons-cache" title="Clear Cache">
<span>Clear Cache</span>
</a>
<script type="text/javascript">
// Move Button to Divi Tabs
jQuery(window).load(function(){
@andrasguseo
andrasguseo / change-wording-with-context.php
Created May 12, 2017 20:21
Change the wording of any bit of text or string, which has a context
<?php
function tribe_custom_theme_text_with_context ( $translation, $text, $context, $domain ) {
// Put your custom text here in a key => value pair
// Example: 'Text you want to change' => 'This is what it will be changed to'
// The text you want to change is the key, and it is case-sensitive
// The text you want to change it to is the value
// You can freely add or remove key => values, but make sure to separate them with a comma
// This example changes the label "Venue" to "Location", and "Related Events" to "Similar Events"