Skip to content

Instantly share code, notes, and snippets.

add_filter( 'woocommerce_cart_shipping_packages', 'split_shipping_packages_shipping_class' );
function split_shipping_packages_shipping_class( $packages ) {
// Reset the packages.
$packages = array();
// Special items.
$special_items = array();
$regular_items = array();
<?php
/**
* Plugin Name: Simple Google Analytics Plugin
* Plugin URI: http://dianewallace.com
* Description: Adds a Google analytics tracking code to the <head> of your theme, by hooking to wp_head.
* Author: Diane wallace
* Version: 1.0
*/
add_action( 'wp_head', 'sga_google_analytics', 10 );
@dianewallace
dianewallace / woo-no-shipping-available-message.php
Last active November 17, 2020 17:42
Update the Woocommerce No Shipping message to include contact details.
add_filter( 'woocommerce_cart_no_shipping_available_html', 'myplugin_no_shipping_available_message' );
add_filter( 'woocommerce_no_shipping_available_html', 'myplugin_no_shipping_available_message' );
/**
* Update the Woocommerce No Shipping message to include contact details.
*/
function myplugin_no_shipping_available_message( $message ) {
$country = WC()->customer->get_shipping_country();
$mailto = 'mailto:' . get_option( 'admin_email' ); // Could also be 'woocommerce_stock_email_recipient'.
$link = sprintf( wp_kses( __( '<a href="%s">contact us</a>', 'my-plugin' ), array( 'a' => array( 'href' => array() ) ) ), esc_url( $mailto ) );
add_filter( 'woocommerce_product_get_stock_status', 'my_plugin_set_stock_status', 10, 2 );
add_filter( 'woocommerce_product_variation_get_stock_status', 'my_plugin_set_stock_status', 10, 2 );
/**
* Set maximum back orders.
*
* @param $stock_status string product stock status.
* @param $product integer product.
*
* @return mixed|string