Skip to content

Instantly share code, notes, and snippets.

@helgatheviking
helgatheviking / billing-details-translation.php
Created Apr 12, 2022
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 Mar 8, 2022
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 Jan 18, 2022
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 Nov 9, 2021
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 Oct 23, 2021
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 Jan 6, 2021
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 Dec 11, 2020
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 Oct 23, 2020
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 Sep 9, 2020
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
*/
@helgatheviking
helgatheviking / wc-mnm-ups-bridge.php
Last active Sep 4, 2020
Add support for Mix and Match products to PluginHive UPS
View wc-mnm-ups-bridge.php
<?php
/**
* Plugin Name: WooCommerce Mix and Match - PluginHive UPS Bridge
* Plugin URI: http://www.woocommerce.com/products/woocommerce-mix-and-match-products/
* Description: Add support for Mix and Match products to UPS shipping.
* Version: 1.0.0
* Author: Kathy Darling
* Author URI: http://kathyisawesome.com/
* WC requires at least: 4.0.0
* WC tested up to: 4.4.0