Skip to content

Instantly share code, notes, and snippets.

Avatar

Stuart Duff stuartduff

View GitHub Profile
@stuartduff
stuartduff / gist:5805532
Created Jun 18, 2013
Change the word Products in the WooCommerce breadcrumb trail
View gist:5805532
add_filter( 'woo_breadcrumbs_trail', 'woo_custom_filter_breadcrumbs_trail', 10 );
function woo_custom_filter_breadcrumbs_trail ( $trail ) {
foreach ( $trail as $k => $v ) {
if ( strtolower( strip_tags( $v ) ) == 'products' ) {
$trail[$k] = 'Photos';
break;
}
}
return $trail;
} // End woo_custom_filter_breadcrumbs_trail()
@stuartduff
stuartduff / fa-box-shorcode.exmple
Created Feb 26, 2020
An example of the FA Box Shortcode WordPress Plugin
View fa-box-shorcode.exmple
[box icon="fa-wordpress" color="blue" url="https://wordpress.org"]Visit WordPress.org[/box]
@stuartduff
stuartduff / storefront-custom-homepage-shortcode-section.php
Created Dec 8, 2015
Add a custom shortcode section to the storefront themes homepage template.
View storefront-custom-homepage-shortcode-section.php
function sf_output_custom_shortcode_section() {
echo '<section class="storefront-product-section storefront-product-category">';
echo '<h2 class="section-title">' . __( 'Music Category', 'storefront' ) . '</h2>';
echo do_shortcode( '[product_category category="music" columns="4" per_page="4"]' );
echo '</section>';
@stuartduff
stuartduff / remove-storefront-cart-link-header.php
Created Apr 11, 2016
Remove the cart from the header of the WooThemes Storefront theme
View remove-storefront-cart-link-header.php
@stuartduff
stuartduff / woocommerce-bookings-change-single-add-to-cart-text.php
Created Apr 20, 2016
Change WooCommerce Bookings single add to cart text "Book Now"
View woocommerce-bookings-change-single-add-to-cart-text.php
function change_booking_single_add_to_cart_text() {
echo 'Changed Text';
}
add_filter( 'woocommerce_booking_single_add_to_cart_text','change_booking_single_add_to_cart_text' );
@stuartduff
stuartduff / woocommerce-change-gravity-forms-product-addons-select-options-text.php
Created Nov 17, 2016
Change the product archive Select Options text in GravityForms Product Addons for WooCommerce using the filter woocommerce_gforms_add_to_cart_text
View woocommerce-change-gravity-forms-product-addons-select-options-text.php
function change_gravity_add_to_cart() {
return 'Changed Text';
}
add_filter( 'woocommerce_gforms_add_to_cart_text', 'change_gravity_add_to_cart' );
@stuartduff
stuartduff / remove-free-shipping-if-coupon-used.php
Created Jun 14, 2018
Remove free shipping in WooCommerce if a coupon is applied at checkout
View remove-free-shipping-if-coupon-used.php
add_filter( 'woocommerce_shipping_packages', function( $packages ) {
$applied_coupons = WC()->session->get( 'applied_coupons', array() );
if ( ! empty( $applied_coupons ) ) {
$free_shipping_id = 'free_shipping:2';
unset($packages[0]['rates'][ $free_shipping_id ]);
}
return $packages;
} );
@stuartduff
stuartduff / wc-remove-billing-fields-required.php
Last active Jan 23, 2019
Removes the required status for all WooCommerce Checkout Billing Fields
View wc-remove-billing-fields-required.php
/**
* Sets all WooCommerce billing fields to be unrequired.
*/
function wc_unrequire_billing_fields( $fields ) {
$fields['billing_first_name']['required'] = false;
$fields['billing_last_name']['required'] = false;
$fields['billing_company']['required'] = false;
$fields['billing_country']['required'] = false;
$fields['billing_address_1']['required'] = false;
$fields['billing_city']['required'] = false;
@stuartduff
stuartduff / sf-fw-wooslider
Last active Dec 17, 2018
Storefront Homepage Full Width WooSlider
View sf-fw-wooslider
/**
* Adds wooslider into the storefront_before_content action in the parent themes header.php file.
*/
function sd_storefront_homepage_slider() {
// if not the StoreFront Homepage Page Template return false
if ( ! is_page_template( 'template-homepage.php' ) ) {
return false;
@stuartduff
stuartduff / storefront-custom-homepage-text-section.php
Last active Dec 12, 2018
Add a custom text section to the storefront themes homepage template.
View storefront-custom-homepage-text-section.php
function sf_output_custom_text_section() {
echo '<section class="storefront-product-section storefront-product-category">';
echo '<h2 class="section-title">' . __( 'Text Title', 'storefront' ) . '</h2>';
echo '<p>This is some text blurb</p>';
echo '</section>';