Skip to content

Instantly share code, notes, and snippets.

View lukecav's full-sized avatar
🪨
Words of GREAT encouragement!

Luke Cavanagh lukecav

🪨
Words of GREAT encouragement!
View GitHub Profile
@lukecav
lukecav / functions.php
Last active September 25, 2024 19:38 — forked from stevehenty/gist:79364b0e2e029b995ef6
Add Gravity Forms to the WordPress Dashboard
add_action( 'wp_dashboard_setup', 'wp_dashboard_setup' );
function sh_dashboard_setup() {
wp_add_dashboard_widget( 'wp_gf_dashboard', 'My Gravity Form', 'wp_gf_dashboard' );
}
function wp_gf_dashboard() {
// Make sure the scripts are loaded
// https://docs.gravityforms.com/gravity_form_enqueue_scripts/
@lukecav
lukecav / jilt-for-wc-recovery-link-redirect-to-cart.php
Created December 23, 2017 03:43 — forked from maxrice/jilt-for-wc-recovery-link-redirect-to-cart.php
Jilt for WooCommerce - Recovery link redirect to cart
@lukecav
lukecav / jilt-for-wc-disable-email-field-move.php
Created December 23, 2017 03:43 — forked from maxrice/jilt-for-wc-disable-email-field-move.php
Jilt for WooCommerce - Disable moving the email field at checkout
<?php
add_action( 'init', function() {
if ( is_callable( 'wc_jilt' ) ) {
remove_filter( 'woocommerce_checkout_fields', array( wc_jilt()->get_checkout_handler_instance(), 'move_checkout_email_field' ), 1 );
}
}, 20 );
@lukecav
lukecav / change-products-per-page-storefront.php
Created January 5, 2018 17:23 — forked from stuartduff/change-products-per-page-storefront.php
Change WooCommerce products per page in Storefront
function alter_sf_products_per_page() {
// Return the number of products per page ( default: 12 ).
return 8;
}
add_filter('storefront_products_per_page', 'alter_sf_products_per_page' );
@lukecav
lukecav / sf-add-text-after-featured-products
Created January 5, 2018 17:23 — forked from stuartduff/sf-add-text-after-featured-products
Storefront add text to after featured products area
@lukecav
lukecav / wc-custom-login-redirect.php
Created January 5, 2018 17:23 — forked from stuartduff/wc-custom-login-redirect.php
This will redirect the customer the referring url on login to WooCommerce.
function wc_custom_login_redirect() {
// This will redirect the customer the referring url on login to WooCommerce..
$location = $_SERVER['HTTP_REFERER'];
wp_safe_redirect($location);
exit();
}
add_filter('woocommerce_login_redirect', 'wc_custom_login_redirect');
@lukecav
lukecav / wc-exclude-product-category-from-shop-page.php
Created January 5, 2018 17:24 — forked from stuartduff/wc-exclude-product-category-from-shop-page.php
This snippet will exclude all products from any categories which you choose from displaying on the WooCommerce Shop page.
function custom_pre_get_posts_query( $q ) {
$tax_query = (array) $q->get( 'tax_query' );
$tax_query[] = array(
'taxonomy' => 'product_cat',
'field' => 'slug',
'terms' => array( 'clothing' ), // Don't display products in the clothing category on the shop page.
'operator' => 'NOT IN'
);
@lukecav
lukecav / remove-woocommerce-product-sales-badge.php
Created January 5, 2018 17:24 — forked from stuartduff/remove-woocommerce-product-sales-badge.php
Remove the WooCommerce sales badge from products using a filter
function sd_custom_hide_sales_flash() {
return false;
}
add_filter( 'woocommerce_sale_flash', 'sd_custom_hide_sales_flash' );
@lukecav
lukecav / woocommerce-change-gravity-forms-product-addons-select-options-text.php Change the product archive Select Options text in GravityForms Product Addons for WooCommerce using the filter woocommerce_gforms_add_to_cart_text
function change_gravity_add_to_cart() {
return 'Changed Text';
}
add_filter( 'woocommerce_gforms_add_to_cart_text', 'change_gravity_add_to_cart' );
@lukecav
lukecav / functions.php
Created January 11, 2018 03:14 — forked from eduwass/functions.php
WooCommerce Product Bundles - Check if cart contains a Product Bundle Container
<?php
/**
* Checks if the cart contains a product bundle
* @return [bool]
*/
function cart_contains_product_bundle(){
global $woocommerce;
$contains_product_bundle = false;
if ( sizeof( WC()->cart->get_cart() ) > 0 ) {
// if cart has items