Skip to content

Instantly share code, notes, and snippets.

Avatar
🤓
Busy ... Always busy

Mitchell Krog mitchellkrogza

🤓
Busy ... Always busy
View GitHub Profile
@mitchellkrogza
mitchellkrogza / flatsome-change-sale-button
Created May 15, 2022
Flatsome theme Change Sale Button Text
View flatsome-change-sale-button
add_filter( 'flatsome_product_labels', function ( $text, $post, $product, $badge_style ) {
if ( $product->is_on_sale() ) {
$text = '<div class="badgeonsale callout badge-label"><div class="badge-inneronsale callout-onsale-bg is-small onsale-bubble">ON SALE</div></div>' . $text;
}
return $text;
}, 10, 4 );
@mitchellkrogza
mitchellkrogza / woocommerce-change-add-to-cart-button-text
Created Mar 21, 2022
Woocommerce Change "Add to Cart" button text
View woocommerce-change-add-to-cart-button-text
// To change add to cart text on single product page
add_filter( 'woocommerce_product_single_add_to_cart_text', 'woocommerce_custom_single_add_to_cart_text' );
function woocommerce_custom_single_add_to_cart_text() {
return __( 'Buy Now', 'woocommerce' );
}
// To change add to cart text on product archives(Collection) page
add_filter( 'woocommerce_product_add_to_cart_text', 'woocommerce_custom_product_add_to_cart_text' );
function woocommerce_custom_product_add_to_cart_text() {
return __( 'Buy Now', 'woocommerce' );
@mitchellkrogza
mitchellkrogza / woocommerce-wcfm-marketplace-notify-user-product-deletion
Created Mar 5, 2022
Woocommerce WCFM Marketplace Notify User of Product Deletion
View woocommerce-wcfm-marketplace-notify-user-product-deletion
// ======================================================================================
// Notify user of product deletion
// Applies to any Woocommerce product but was written specifically for WCFM Marketplace
// Copyright Bjorn Patje & Mitchell Krog (thank you Bjorn)
// ======================================================================================
// This sends an email to the owner (user) of a product when it is deleted / trashed
// The email uses simple html formatting and php variables
// Modify the contents of the $body varaible and $subject variable to your liking
// ======================================================================================
add_action( 'delete_post', 'notification_for_product', 99 );
@mitchellkrogza
mitchellkrogza / flatsome-theme-change-product-titles-to-h2
Last active Mar 5, 2022
Flatsome Theme Change Shop & Category Loop Product Title from <p> to <h2>
View flatsome-theme-change-product-titles-to-h2
/**
* Flatsome Theme
* Change Shop & Catalog Product Titles from <p> to <h2>
* Adjust to <h3> <h4> <h5> <h6> as you require.
*/
if ( ! function_exists( 'woocommerce_template_loop_product_title' ) ) {
function woocommerce_template_loop_product_title() {
echo '<h2 class="name product-title ' . esc_attr( apply_filters( 'woocommerce_product_loop_title_classes', 'woocommerce-loop-product__title' ) ) . '">';
woocommerce_template_loop_product_link_open();
@mitchellkrogza
mitchellkrogza / woocommerce-change-backorder-message
Last active Feb 23, 2022
Woocommerce Change Backorder Message
View woocommerce-change-backorder-message
// CHANGE WOOCOMMERCE BACKORDER TEXT
// Here I have used a 3 line message with inline styles to change the color and add line breaks
// Adapt this as you see fit
// Use Code Snippets Plugin to add this function or add yourself to functions.php of your child theme
// https://wordpress.org/plugins/code-snippets/
function mywoo_backorder_message( $text, $product ){
if ( $product->managing_stock() && $product->is_on_backorder( 1 ) ) {
$text = __( '<strong><p style="color:green">New Stock is on its way !!!!<br>Backorder now - first come first served<br>Please allow 1 – 3 weeks for delivery of this item</p></strong><br>', 'your-textdomain' );
}
@mitchellkrogza
mitchellkrogza / flatsome-disable-navigation-thumbnails
Created Feb 21, 2022
Flatsome Theme - Disable Product Navigation Thumbnails
View flatsome-disable-navigation-thumbnails
if(!function_exists('flatsome_next_post_link_product')) {
function flatsome_next_post_link_product() {
global $post;
$next_post = get_next_post(true,'','product_cat');
if ( is_a( $next_post , 'WP_Post' ) ) { ?>
<li class="prod-dropdown has-dropdown">
<a href="<?php echo get_the_permalink( $next_post->ID ); ?>" title="View Previous Product" rel="next" class="button icon is-outline circle">
<?php echo get_flatsome_icon('icon-angle-left'); ?>
</a>
</li>
@mitchellkrogza
mitchellkrogza / flatsome-accordion-icon
Last active Feb 21, 2022
Flatsome Change Accordion Arrow to + sign
View flatsome-accordion-icon
/*ACCORDIAN*/
/* Change the Flatsome default accordion Arrow Icon to a + symbol*/
.accordion-title.active{background-color:#006587!important;color:white!important}
.accordion-inner{background-color:#eeeeee!important}
.accordion-title{font-size:100%}
.accordion-inner{padding:10px;font-size:.85em}
.accordion .toggle{top:3px!important;transform-origin: 50% 50%!important;}
.accordion .active .toggle{top:3px!important;}
.accordion-item {margin-bottom: 8px;}
.accordion .icon-angle-down:before{content:"+";}
@mitchellkrogza
mitchellkrogza / Remove-unnecessary-wordpress-image-sizes
Last active Oct 6, 2021
Remove unnecessary wordpress image sizes
View Remove-unnecessary-wordpress-image-sizes
/*
* WordPress: Remove unwanted image sizes.
* Remove the three sizes medium_large, 1536x1536, 2048x2048
* Not needed for 99% of Woocommerce stores
*/
add_filter('intermediate_image_sizes', function($sizes) {
return array_diff($sizes, ['medium_large']); // Medium Large (768 x 0)
});
View Fix-slow-wordpress-editor
// A fix for the horribly slow WordPress post and product editor
// With many thanks to Jon Brown
// Read about it at https://9seeds.com/wordpress-admin-post-editor-performance/
/**
* Remove Ancient Custom Fields metabox from post editor
* because it uses a very slow query meta_key sort query
* so on sites with large postmeta tables it is super slow
* and is rarely useful anymore on any site
*/
@mitchellkrogza
mitchellkrogza / flatsome-fix-gallery-thumbnail-sizes
Created Sep 26, 2021
Flatsome Theme - FIX Google Properly Size Images Warning for Gallery Thumbnails
View flatsome-fix-gallery-thumbnail-sizes