Skip to content

Instantly share code, notes, and snippets.

@helgatheviking
helgatheviking / wc-bcc-emails.php
Last active January 7, 2023 22:44
Add BCC to certain store emails
View wc-bcc-emails.php
/**
* Add BCC to certain store emails.
*
* @param string $headers
* @param string $email_id
* @return string
*/
function kia_add_bcc_to_specific_emails( $headers, $email_id ) {
$bbc_these_emails = array(
@helgatheviking
helgatheviking / billing-details-translation.php
Created April 12, 2022 17:19
Change Billing Details text on free checkout
View billing-details-translation.php
function kia_translate_billing_details_when_free( $translated_text, $untranslated_text, $domain ) {
if ( function_exists( 'wc' ) && 'woocommerce' === $domain ) {
//make the changes to the text
switch( $untranslated_text ) {
case 'Billing details':
if ( ! WC()->cart->needs_shipping() && 0.0 === floatval( WC()->cart->get_total( 'edit' ) ) ) {
$translated_text = __( 'NOT billing details', 'kia_textdomain' );
@helgatheviking
helgatheviking / wc-clear-persistent-carts-daily.php
Created March 8, 2022 14:30
Schedule a task to run daily to delete WooCommerce persistent carts
View wc-clear-persistent-carts-daily.php
<?php
/**
* Plugin Name: Clear persistent carts daily
* Plugin URI: https://gist.github.com/
* Description: Schedule a task to run daily to delete WooCommerce persistent carts
* Version: 1.0.0
* Author: Kathy Darling
* Author URI: http://kathyisawesome.com/
* WC requires at least: 6.3.0
* WC tested up to: 6.3.0
@helgatheviking
helgatheviking / wc-attributes-shortcode.php
Last active January 18, 2022 15:28
Adds a [display_attributes] shortcode that will display all the terms for each attribute. Use [display_attributes attributes="some_taxonomy"] to show a particular attribute's terms.
View wc-attributes-shortcode.php
<?php
/**
* Plugin Name: Attributes shortcode
* Plugin URI: https://gist.github.com/helgatheviking/1d34f84fc93b8a08c258a37768802625
* Description: Create a shortcode to display product attribute taxonomies
* Version: 6.8.0
* Author: Kathy Darling
* Author URI: https://kathyisawesome.com/
*
* Requires PHP: 7.4
@helgatheviking
helgatheviking / mnm-product-thumbnail.php
Last active November 9, 2021 22:00
Template override for Mix and Match child thumbnails - replace with first gallery image
View mnm-product-thumbnail.php
<?php
/**
* Mix and Match Item Thumbnail
*
* This template can be overridden by copying it to yourtheme/woocommerce/single-product/mnm/mnm-product-thumbnail.php.
*
* HOWEVER, on occasion WooCommerce Mix and Match will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and
@helgatheviking
helgatheviking / give-count-unique-donors.php
Last active October 23, 2021 18:34
Shortcode to output unique donor count for specific form (needs caching)
View give-count-unique-donors.php
<?php
/**
* Give count unique donors
*
* @param array $atts [
* 'form_id' => int The form ID to count donors for
* ]
*/
function kia_give_donor_count( $atts ) {
@helgatheviking
helgatheviking / dequeue-script-example.php
Created January 6, 2021 19:50
Code snippet for dequeing a script on the single produt page
View dequeue-script-example.php
function kia_unload_script() {
if ( function_exists( 'is_product' ) && is_product() ) {
wp_dequeue_script( 'wc-single-product' );
}
}
add_action( 'wp_enqueue_scripts', 'kia_unload_script', 20 );
@helgatheviking
helgatheviking / wc-mnm-simplify-variation-names.php
Created December 11, 2020 22:38
Reduce Mix and Match variation names to only their attributes
View wc-mnm-simplify-variation-names.php
<?php
/**
* Plugin Name: WooCommerce Mix and Match Products - Simplify variation names
* Plugin URI: https://woocommerce.com/products/woocommerce-mix-and-match-products
* Description: Reduce container variation names to only their attributes
* Version: 1.0.0
* Author: Kathy Darling
* Author URI: https://kathyisawesome.com
* Requires at least: 5.5
* Requires PHP: 7.0
@helgatheviking
helgatheviking / short-description-in-loop.php
Last active October 23, 2020 00:01
Display short descriptions in WooCommerce shop loops
View short-description-in-loop.php
<?php
/**
* Display short descriptions in loop
*/
function kia_display_short_desciption_in_loop() {
global $product;
$short_description = $product->get_short_description();
@helgatheviking
helgatheviking / kia-local-dev.php
Created September 9, 2020 22:34
Snippet for local WordPress development
View kia-local-dev.php
<?php
/**
* Plugin Name: Local Dev modifications
* Plugin URI: https://kathyisawesome.com/
* Description: Custom snippets for local development
* Version: 1.0.0
* Author: Kathy Darling
* Author URI: https://kathyisawesome.com
*/