Skip to content

Instantly share code, notes, and snippets.

@bradleysa
bradleysa / gist:dd786d078bc0817884bec6b339227ce2
Created August 15, 2022 03:31
Jetpack Testimonials: Columns, Posts & Order
[testimonials columns=1 showposts=1 display_content=true orderby=rand]
@bradleysa
bradleysa / gist:09aba0102d729a2544d05c19eafeb898
Created April 22, 2022 08:34
WC: Force Shipping Calculator
/**
* Force the shipping calculator to display on cart, even when Local Pickup Plus is selected.
*/
function sv_force_display_of_shipping_calculator() {
?>
<script type="text/javascript">
if ( undefined !== window.jQuery ) {
jQuery(function ($) {
function show_shipping_calculator() {
$( '.woocommerce-shipping-totals' ).each(function(index, el) {
@bradleysa
bradleysa / gist:ad4363c0087a2d396ee3893930a50089
Created April 22, 2022 08:32
Display Random Posts: Recipe
function wpdean_rand_posts() {
$args = array(
'post_type' => 'recipe',
'orderby'=> 'rand',
'posts_per_page' => 3,
);
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) {
$string .= '<ul>';
@bradleysa
bradleysa / gist:db422df729cb0637fee566a2279520ce
Created April 22, 2022 08:31
Show Custom Message on Packing List for WooCommerce
add_filter( 'wc_pip_document_show_header', function ( $show_header, $type ) {
if ( $type === 'packing-list' ) {
$show_header = true;
}
return $show_header;
}, 10, 2 );
@bradleysa
bradleysa / gist:79d5b4463bb5be7284ecc03aa07f6080
Created April 22, 2022 08:30
Astra: Apply Shop Columns Settings to Shortcode
add_filter( 'astra_apply_flex_based_css', '__return_false' );
/** Supplied via Support Email on 2/26/22 **/
@bradleysa
bradleysa / gist:efc0bd4558ca161135d4aeabb7c35945
Created April 22, 2022 08:29
YIKES Custom Product Tabs - Remove Tab Title
add_filter( 'yikes_woocommerce_custom_repeatable_product_tabs_heading', '__return_false' );
/** https://wordpress.org/support/topic/tab-heading/ **/
@bradleysa
bradleysa / gist:ee22f6f2186bad361ec0d3c6b49f517c
Created April 22, 2022 08:29
WC: Remove "Additional information" Tab
// Remove the additional information tab
function quadlayers_remove_product_tabs( $tabs ) {
unset( $tabs['additional_information'] );
return $tabs;
}
add_filter( 'woocommerce_product_tabs', 'quadlayers_remove_product_tabs', 98 );
/** https://quadlayers.com/remove-additional-information-tab-in-woocommerce/ **/
@bradleysa
bradleysa / gist:4b9ac054155c1904239d9fd8e7e6e971
Created April 22, 2022 08:28
WC: Change "Out of stock" to "Sold Out" on Single Product
add_filter( 'woocommerce_get_availability', 'change_out_of_stock_text_woocommerce', 1, 2 );
function change_out_of_stock_text_woocommerce( $availability, $product_to_check ) {
// Change Out of Stock Text
if ( ! $product_to_check->is_in_stock() ) {
$availability['availability'] = __('Sold Out', 'woocommerce');
}
return $availability;
}
/** https://wpastra.com/docs/change-woocommerce-out-of-stock-text/ **/
@bradleysa
bradleysa / gist:801d91fb3ce9704044cfbc7f96ab5ccc
Created April 22, 2022 08:28
WC: Change "Out of stock" to "Sold Out" on Product Catalog
add_filter( 'astra_woo_shop_out_of_stock_string', 'out_of_stock_callback' );
function out_of_stock_callback( $title ) {
return 'Sold Out';
}
/** https://wpastra.com/docs/change-woocommerce-out-of-stock-text/ **/
@bradleysa
bradleysa / gist:ac9cfa264e9f38aa14117dd702592b66
Created April 22, 2022 08:27
Change 'add to cart' text on archive product page
// Change 'add to cart' text on archive product page
add_filter( 'woocommerce_product_add_to_cart_text', 'bryce_archive_add_to_cart_text' );
function bryce_archive_add_to_cart_text() {
return __( "That's My Jam!", 'your-slug' );
}
/** https://metorik.com/blog/change-the-add-to-cart-text-in-woocommerce **/