Skip to content

Instantly share code, notes, and snippets.

@helgatheviking
helgatheviking / class-wc-kia-class-email.php
Last active November 13, 2022 02:51
Send a WooCommerce Customer email from the Order Admin Actions
<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if ( ! class_exists( 'WC_KIA_Class_Email', false ) ) :
/**
* A custom Order WooCommerce Email class
*
* @since 0.1
* @extends \WC_Email
@helgatheviking
helgatheviking / wc-optional-redirect-to-checkout.php
Last active February 2, 2023 14:46
Woo Redirect Certain Products to Checkout- How to skip cart page on woocomerce for certain products only?
<?php
/**
* Plugin Name: WC Redirect to checkout
* Plugin URI: http://stackoverflow.com/q/32962653/383847
* Description: Redirect to checkout for certain products
* Version: 1.0.1
* Author: Kathy Darling
* Author URI: http://kathyisawesome.com
* Requires at least: 3.8
* Tested up to: 3.9
@helgatheviking
helgatheviking / entry-header.php
Created April 19, 2020 19:53
Tweny Twenty Child theme | Add Subtitle to entry-header.php
<?php
/**
* Displays the post header
*
* @package WordPress
* @subpackage Twenty_Twenty
* @since Twenty Twenty 1.0
*/
$entry_header_classes = '';
@helgatheviking
helgatheviking / wc-disable-billing-address-for-free-checkout.php
Created April 17, 2020 16:59
Hide billing address fields in checkout when cart total is free
<?php
/*
* Plugin Name: Disable billing address for free checkout
* Plugin URI: https://gist.github.com/helgatheviking/65fd213e7f13cde029b19c16a275eb3f
* Description: Hiding billing address fields when cart total is free.
* Version: 1.0.0
* Author: Kathy Darling
* Author URI: https://woocommerce.com/products/name-your-price?aff=5151&cid=4951026
* Requires at least: 5.3
* WC requires at least: 4.0
@helgatheviking
helgatheviking / wc-mnm-price-range.php
Created March 2, 2020 17:31
Change Mix and Match price string from From: $99 to range style $99 - $100
<?php
/**
* Change price string from From: $99 to range style $99 - $100
*
* @return string
*/
function kia_mnm_price_range( $price, $product ) {
if ( $product->get_max_container_size() && $product->get_mnm_price( 'max' ) && $product->get_mnm_price( 'min' ) !== $product->get_mnm_price( 'max' ) ) {
$price = sprintf( _x( '%1$s - %2$s', 'Price range', 'woocommerce-mix-and-match-products' ), $price . $product->get_price_suffix(), $product->get_mnm_price( 'max' ) . $product->get_price_suffix() );
@helgatheviking
helgatheviking / wc-mnm-disable-shipstation-compat.php
Created March 2, 2020 17:04
Mix and Match: Disable Shipstation Compat
<?php
/**
* Plugin Name: Mix and Match: Disable Shipstation Compat
* Plugin URI: https://woocommerce.com/products/woocommerce-mix-and-match-products/?aff=5151&cid=4347782
* Description: This is a short description of what the plugin does. It's displayed in the WordPress admin area.
* Version: 1.0.0
* Author: Kathy Darling
* Author URI: kathyisawesome.com
* License: GPL-2.0+
@helgatheviking
helgatheviking / custom-meta-for-woocommerce-product-variations.php
Last active January 31, 2024 23:06
Add custom fields to WooCommerce variations
<?php
/**
* Plugin Name: Example custom variation meta for WooCommerce
* Plugin URI: hhttps://www.kathyisawesome.com/add-custom-meta-fields-to-woocommerce-variations/
* Description: Add thickness and diameter fields to variations.
* Version: 6.22.5
* Author: Kathy Darling
* Author URI: https://kathyisawesome.com/
*
* Text Domain: extra-product-data
@helgatheviking
helgatheviking / wordpress-add-custom-menu-meta-fields.php
Created February 26, 2020 02:06
Add an example custom meta field to WordPress menu and display text on front-end (Requires WP5.4)
<?php
/**
* Add custom fields to menu item
*
* This will allow us to play nicely with any other plugin that is adding the same hook
*
* @param int $item_id
* @params obj $item - the menu item
* @params array $args
@helgatheviking
helgatheviking / simple.php
Last active January 27, 2022 16:42
Simple add to cart template - adds ajax add to cart support to simple products
<?php
/**
* Simple product add to cart with core ajax add to cart support
*
* This template should be saved to yourtheme/woocommerce/single-product/add-to-cart/simple.php.
*
* HOWEVER, on occasion WooCommerce 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 / readme.md
Created February 13, 2020 16:38
Add Name Your Price support to Braintree Subscription product types

Name Your Price Compatibility for Braintree Subscriptions

Contributors: Kathy Darling
Requires at least: 5.4.0
Tested up to: 5.4.0
Stable tag: 1.0.0 License: GPLv3
License URI: http://www.gnu.org/licenses/gpl-3.0.html
WC requires at least: 3.9.0
WC tested up to: 3.9.0