Skip to content

Instantly share code, notes, and snippets.

@noellesteegs
noellesteegs / storefront-footer-text.php
Last active August 26, 2019 12:33
Add test text @ Storefront footer
@noellesteegs
noellesteegs / sale-badge-text.php
Last active August 23, 2019 12:52
Change text of WooCommerce sale badge
add_filter( 'woocommerce_sale_flash', 'edit_sale_badge_text' );
function edit_sale_badge_text() {
return '<span class="onsale">Buy me!</span>';
}
@noellesteegs
noellesteegs / single-product-category-notice.php
Last active August 26, 2019 12:34
Add text above cart form @ WooCommerce single product if in particular category
add_action( 'woocommerce_before_add_to_cart_form', 'category_notice' );
function category_notice() {
if (has_term('accessories', 'product_cat')) { // Replace 'accessories' with your category
echo '<div class="category_notice"><p>This is a notice.</p></div>';
}
}
@noellesteegs
noellesteegs / content-below-product-price.php
Created August 26, 2019 12:32
Add content below price @ WooCommerce single product
add_action( 'woocommerce_single_product_summary', 'content_below_price', 15 );
function content_below_price() {
echo 'TEST';
}
@noellesteegs
noellesteegs / styled-checkboxes.css
Created September 13, 2019 09:15
Replace default HTML checkboxes with Font Awesome icons
input, input::before {
margin: 0px !important;
top: 0px;
}
label {
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
@noellesteegs
noellesteegs / 12-point-star.css
Created December 10, 2019 09:33
Style WooCommerce price on single product pages into a star burst shape
body.single-product p.price {
color: #FFFFFF;
line-height: 80px; /* vertically aligns the price within the star */
font-size: 1.375rem;
}
#burst-12 {
background: #FA7268;
width: 80px;
height: 80px;
text-align: center;
@noellesteegs
noellesteegs / remove-img-p-tags.php
Created April 10, 2020 12:30
Remove auto p tags around images
function filter_ptags_on_images($content){
return preg_replace('/<p>\s*(<a .*>)?\s*(<img .* \/>)\s*(<\/a>)?\s*<\/p>/iU', '\1\2\3', $content);
}
add_filter('the_content', 'filter_ptags_on_images');
/* Originally posted @ https://css-tricks.com/snippets/wordpress/remove-paragraph-tags-from-around-images/ */
@noellesteegs
noellesteegs / cf7-radio-check.css
Created April 21, 2020 14:42
Replace Contact Form 7's checkboxes and radio buttons with Divi's icon font
.wpcf7-checkbox .wpcf7-list-item input[type=checkbox],
.wpcf7-radio .wpcf7-list-item input[type=radio] {
visibility: hidden;
margin: 0;
width: 0!important;
}
input[type=checkbox] + .wpcf7-list-item-label,
input[type=radio] + .wpcf7-list-item-label {
font-size: initial;
font-weight: initial;
@noellesteegs
noellesteegs / wc-cart-button-text.php
Created August 3, 2020 12:52
Edit WooCommerce add to cart button text
add_filter( 'woocommerce_product_add_to_cart_text', 'edit_add_to_cart_button_text' );
function edit_add_to_cart_button_text() {
return 'Buy now';
}
@noellesteegs
noellesteegs / wc-skip-cart.php
Created August 3, 2020 13:04
Skip cart and go straight to checkout when clicking add to cart button in WooCommerce
add_filter('woocommerce_add_to_cart_redirect', 'skip_cart');
function skip_cart() {
global $woocommerce;
$checkout_url = wc_get_checkout_url();
return $checkout_url;
}