Skip to content

Instantly share code, notes, and snippets.

add_filter( 'register_post_type_args', 'dlm_change_cpt_args', 10, 2 );
function dlm_change_cpt_args( $args, $cpt_name ) {
//error_log( "CPT Name: $cpt_name" );
if ( 'dlm_download' == $cpt_name ) {
$args['public'] = true;
//error_log( $cpt_name . ': ' . var_export( $args, true ) );
}
return $args;
}
@wmacmill
wmacmill / Query
Last active September 15, 2020 20:29 — forked from lukecav/Query
MySQL script to get all WooCommerce orders including metadata
select
p.ID as order_id,
p.post_date,
max( CASE WHEN pm.meta_key = '_billing_email' and p.ID = pm.post_id THEN pm.meta_value END ) as billing_email,
max( CASE WHEN pm.meta_key = '_billing_first_name' and p.ID = pm.post_id THEN pm.meta_value END ) as _billing_first_name,
max( CASE WHEN pm.meta_key = '_billing_last_name' and p.ID = pm.post_id THEN pm.meta_value END ) as _billing_last_name,
max( CASE WHEN pm.meta_key = '_billing_address_1' and p.ID = pm.post_id THEN pm.meta_value END ) as _billing_address_1,
max( CASE WHEN pm.meta_key = '_billing_address_2' and p.ID = pm.post_id THEN pm.meta_value END ) as _billing_address_2,
max( CASE WHEN pm.meta_key = '_billing_city' and p.ID = pm.post_id THEN pm.meta_value END ) as _billing_city,
max( CASE WHEN pm.meta_key = '_billing_state' and p.ID = pm.post_id THEN pm.meta_value END ) as _billing_state,
@wmacmill
wmacmill / gist:39eea2e8fc80b4e01aa734763fe61f68
Created November 1, 2017 17:43 — forked from kloon/gist:4541017
WooCommerce Clear Cart via URL
// check for clear-cart get param to clear the cart, append ?clear-cart to any site url to trigger this
add_action( 'init', 'woocommerce_clear_cart_url' );
function woocommerce_clear_cart_url() {
if ( isset( $_GET['clear-cart'] ) ) {
global $woocommerce;
$woocommerce->cart->empty_cart();
}
}