Skip to content

Instantly share code, notes, and snippets.

View devinsays's full-sized avatar

Devin Price devinsays

View GitHub Profile
@devinsays
devinsays / challenge.md
Last active August 16, 2021 12:01
WooCommerce MySQL Challenge

Here's a couple MySQL challenges. No tricks or gotchas, just straightforward MySQL queries.

We generally use TablePlus when making SQL queries, but you can also use the command line or whatever you're most comfortable with.

Here's an example query to get all orders on WooCommerce site:

SELECT
	*
FROM
<?php
/**
* Some meta data should not be copied to subscriptions or renewal orders.
*/
namespace UniversalYums\Subscriptions;
class PreventMetaCopy {
/**
@devinsays
devinsays / TagToMeta.php
Created January 27, 2021 20:47
Saves taxonomy terms to product meta in a comma separated list
<?php
namespace UniversalYums\TagToMeta;
class TagToMeta {
/**
* The single instance of the class.
*/
protected static $instance;
@devinsays
devinsays / active-subscribers.sql
Created November 5, 2020 17:20
active-subscriber-ids.sql
/*
* MySQL query to run site running WooCommerce Subscriptions.
* Selects all user ids for customers with an active subscriptions.
*/
select
meta.meta_value as user_id
from
wp_qftw_posts posts
left join wp_qftw_postmeta meta ON meta.post_ID = posts.ID
where
@devinsays
devinsays / wc-product.sql
Last active December 1, 2023 13:15
SQL: Get WooCommerce Product ID, title, SKU, and Image
SELECT
products.id,
products.post_title as title,
meta3.meta_value as sku,
meta2.meta_value as image_url
FROM
wp_qftw_posts products
LEFT JOIN
wp_qftw_postmeta meta1
ON (
@devinsays
devinsays / svg-icon-post.md
Last active May 27, 2021 10:37
How to Use an SVG for a Custom Post Type Icon

Let's use this id-card svg for the custom post type icon rather than a standard dashicon.

First, download the raw SVG file. If you open it up in a text editor, it should look something like this:

<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="id-card" class="svg-inline--fa fa-id-card fa-w-18" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><path fill="currentColor" d="M528 32H48C21.5 32 0 53.5 0 80v16h576V80c0-26.5-21.5-48-48-48zM0 432c0 26.5 21.5 48 48 48h480c26.5 0 48-21.5 48-48V128H0v304zm352-232c0-4.4 3.6-8 8-8h144c4.4 0 8 3.6 8 8v16c0 4.4-3.6 8-8 8H360c-4.4 0-8-3.6-8-8v-16zm0 64c0-4.4 3.6-8 8-8h144c4.4 0 8 3.6 8 8v16c0 4.4-3.6 8-8 8H360c-4.4 0-8-3.6-8-8v-16zm0 64c0-4.4 3.6-8 8-8h144c4.4 0 8 3.6 8 8v16c0 4.4-3.6 8-8 8H360c-4.4 0-8-3.6-8-8v-16zM176 192c35.3 0 64 28.7 64 64s-28.7 64-64 64-64-28.7-64-64 28.7-64 64-64zM67.1 396.2C75.5 370.5 99.6 352 128 352h8.2c12.3 5.1 25.7 8 39.8 8s27.6-2.9 39.8-8h8.2c28.4 0 52.5 18.5
@devinsays
devinsays / tracking.php
Created April 24, 2020 15:49
Tracking Copy
<?php
/**
* Add GTM ecommerce tracking to the Order Complete (Thank You) page.
*
* @param int $order_id
*/
public function thank_you_tracking($order_id)
{
$user_id = get_current_user_id();
$is_existing_customer = $user_id ? get_user_meta($user_id, '_existing_customer', true) : false;
@devinsays
devinsays / countries.html
Created January 11, 2020 02:02
List of WooCommerce Countries Selected
<select multiple="" name="country_restriction[]" style="width:350px" data-placeholder="Choose countries…" aria-label="Country" class="wc-enhanced-select select2-hidden-accessible enhanced" tabindex="-1" aria-hidden="true">
<option selected="selected" value="AX" selected="selected">Åland Islands</option><option selected="selected" value="AF" selected="selected">Afghanistan</option><option selected="selected" value="AL">Albania</option><option selected="selected" value="DZ" selected="selected">Algeria</option><option selected="selected" value="AS">American Samoa</option><option selected="selected" value="AD">Andorra</option><option selected="selected" value="AO">Angola</option><option selected="selected" value="AI">Anguilla</option><option selected="selected" value="AQ">Antarctica</option><option selected="selected" value="AG">Antigua and Barbuda</option><option selected="selected" value="AR">Argentina</option><option selected="selected" value="AM">Armenia</option><option selected="selected" value="AW">Aruba</o
@devinsays
devinsays / okta-testing.html
Last active November 4, 2019 21:21
Example Okta Code for Debugging
<html>
<head>
<title>Okta Test</title>
<!-- Latest CDN production Javascript and CSS -->
<script src="https://global.oktacdn.com/okta-signin-widget/3.2.0/js/okta-sign-in.min.js" type="text/javascript"></script>
<link href="https://global.oktacdn.com/okta-signin-widget/3.2.0/css/okta-sign-in.min.css" type="text/css" rel="stylesheet"/>
</head>
<body>
<h1>Okta Testing</h1>
@devinsays
devinsays / image-gallery-formats.php
Created October 6, 2019 20:50
Customized example of the Image Gallery Formats template for Portfolio Press.