Skip to content

Instantly share code, notes, and snippets.

View Jon007's full-sized avatar

Jonathan Moore Jon007

View GitHub Profile
@Jon007
Jon007 / functions.php
Last active December 4, 2023 08:17
Add default Product Attributes to all WooCommerce products
/*
* Example adds certain named Product Attribute fields to the product Edit screen ready for completion.
* (Pre-requisite )
* This saves the Shop Admin having to add them manually.
*
* Why might you want to do this instead of adding Custom fields? There's plenty of nice documentation on adding custom fields
* for example: http://www.remicorson.com/mastering-woocommerce-products-custom-fields/
*
* Well a Product Attributes are a built in WooCommerce feature, using Terms which are a built in Wordpress feature.
* - no add-ons required
@Jon007
Jon007 / gist:911dba9e4b24d72413e11f3e0ef79922
Created December 3, 2017 09:41
user_alert shortcode sample
function user_alert($atts = array()){
$a = shortcode_atts( array(
'name' => 'saleflash',
), $atts );
$translation = pll__($a['name']);
$output='';
/* don't output visible message if no translation available */
if ($translation == '' || $translation == $a['name']){
//on non-production environments script debug should be enabled
@Jon007
Jon007 / woo-poly-additional-email.php
Created March 31, 2019 11:48
Add additional email handling to woo-poly-integration
<?php
/*
* when switching language for order email, unload these additional text domains
*/
function ii_unload_email_textdomains() {
unload_textdomain( 'inkston-integration' );
unload_textdomain( 'woo-advanced-shipment-tracking' );
}
add_action( 'woo-poly.Emails.switchLanguage', 'ii_unload_email_textdomains' );
/*