Skip to content

Instantly share code, notes, and snippets.

View SiR-DanieL's full-sized avatar

Nicola Mustone SiR-DanieL

View GitHub Profile
@SiR-DanieL
SiR-DanieL / base64 sh.txt
Last active August 29, 2015 13:56
Generate crypted passwords in base64
/bin/echo "{md5}"`/bin/echo -n "password" | openssl dgst -binary -md5 | openssl enc -base64`
@SiR-DanieL
SiR-DanieL / gist:8ca1b1b33ab791836a59
Created August 12, 2014 07:03
Change post types to exclude from WP/WC searches by post content
function wc_filter_search_add_post_type( $array ) {
array_push( $array, 'your_post_type' );
array_push( $array, 'another_post_type' );
array_push( $array, 'etc' );
return array;
}
add_filter( 'wc_filter_search_not_allowed_array', 'wc_filter_search_add_post_type' );
add_action( 'woocommerce_product_thumbnails'. 'your_custom_function' );
function your_custom_function() {
?>
<img src="http://domain.com/image.jpg" title="Your title" alt="Your alt" />
<?php
}
@SiR-DanieL
SiR-DanieL / gist:3659c323e25d50d135c7
Last active August 29, 2015 14:06
Add checkout VAT and SSN fields
// Add VAT and SSN fields to the checkout form
add_filter( 'woocommerce_checkout_fields' , 'custom_add_vat_ssn_fields' );
function custom_add_vat_ssn_fields( $fields ) {
if ( ! isset( $fields['billing']['billing_vat'] ) ) {
$fields['billing']['billing_vat'] = array(
'label' => __( 'VAT', 'your-domain' ),
'placeholder' => _x( 'VAT', 'placeholder', 'your-domain' ),
'required' => true, //change to false if you do not need this field to be required
'class' => array( 'form-row-first' )
);
@SiR-DanieL
SiR-DanieL / gist:b87314a6267b45c41302
Created September 29, 2014 07:37
add woocommerce customer vat and ssn fields
add_filter( 'woocommerce_my_account_my_address_formatted_address', 'custom_my_account_my_address_formatted_address', 10, 3 );
function custom_my_account_my_address_formatted_address( $fields, $customer_id, $type ) {
if ( $type == 'billing' ) {
$fields['vat'] = get_user_meta( $customer_id, 'billing_vat', true );
$fields['ssn'] = get_user_meta( $customer_id, 'billing_ssn', true );
}
return $fields;
}
@SiR-DanieL
SiR-DanieL / gist:21899c057aad33fd9fdd
Last active August 29, 2015 14:07
add woocommerce admin order vat and ssn fields
// Add VAT and SSN fields in billing address display
add_filter( 'woocommerce_order_formatted_billing_address', 'custom_add_vat_ssn_formatted_billing_address', 10, 2 );
function custom_add_vat_ssn_formatted_billing_address( $fields, $order ) {
$fields['vat'] = $order->billing_vat;
$fields['ssn'] = $order->billing_ssn;
return $fields;
}
add_filter( 'woocommerce_admin_billing_fields', 'custom_admin_billing_fields' );
@SiR-DanieL
SiR-DanieL / jquery.wc-custom.js
Last active April 27, 2021 05:05
woocommerce ajax load billing address
jQuery(document).ready(function ( $ ) {
$( 'button.load_customer_billing' ).off( 'click' );
$( 'button.load_customer_billing' ).on( 'click', function() {
if ( window.confirm( woocommerce_admin_meta_boxes.load_billing ) ) {
// Get user ID to load data for
var user_id = $( '#customer_user' ).val();
if ( ! user_id ) {
window.alert( woocommerce_admin_meta_boxes.no_customer_selected );
@SiR-DanieL
SiR-DanieL / gist:896fd11690b7d6597460
Last active August 29, 2015 14:07
woocommerce load JS file for admin order page async loading
add_action( 'admin_enqueue_scripts', 'enqueue_custom_wc_load_address_js' );
function enqueue_custom_wc_load_address_js() {
wp_enqueue_script( 'custom-wc-load-address', untrailingslashit( get_template_directory_uri() ) . '/jquery.wc-custom.js', array( 'wc-admin-order-meta-boxes' ) );
}
@SiR-DanieL
SiR-DanieL / functions.php
Last active August 17, 2017 13:29
Adds VAT and SSN fields in WooCommerce workflow
// Add VAT and SSN fields in billing address display
add_filter( 'woocommerce_order_formatted_billing_address', 'custom_add_vat_ssn_formatted_billing_address', 10, 2 );
function custom_add_vat_ssn_formatted_billing_address( $fields, $order ) {
$fields['vat'] = $order->billing_vat;
$fields['ssn'] = $order->billing_ssn;
return $fields;
}
add_filter( 'woocommerce_my_account_my_address_formatted_address', 'custom_my_account_my_address_formatted_address', 10, 3 );
if ( is_numeric( $download['downloads_remaining'] ) )
echo apply_filters( 'woocommerce_available_download_count', '' . sprintf( _n( '%s download remaining', '%s downloads remaining', $download['downloads_remaining'], 'woocommerce' ), $download['downloads_remaining'] ) . ' ', $download );