Skip to content

Instantly share code, notes, and snippets.

View stevenhoney's full-sized avatar

Steve stevenhoney

  • New Zealand
  • 17:16 (UTC +12:00)
View GitHub Profile
<?php
/**
* Email Addresses
*
* This template can be overridden by copying it to yourtheme/woocommerce/emails/email-addresses.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and
$args = array(
'post_type' => 'post',
'tax_query' => array(
array(
'taxonomy' => 'your_taxonomy_slug'
),
),
);
$query = new WP_Query( $args );
if ( $query->have_posts() ) {
$args = array(
'post_type' => 'post',
'tax_query' => array(
array(
'taxonomy' => 'your_taxonomy_slug'
),
),
);
$query = new WP_Query( $args );
if ( $query->have_posts() ) {
@stevenhoney
stevenhoney / woocommerce_delivery_time_frame.php
Created September 29, 2016 04:06
Simple plugin in to display a custom field from a woocommerce product named delivery_time_frame on product pages
<?php
/*
Plugin Name: WooCommerce Delivery Time Frame.
Plugin URI: http://stevenhoney.com
Description: Proof of concept not tested beyond a single localhost install, copy at your own risk.
Version: 1.0
Author: Steve Honey
Author URI: http://stevenhoney.com
*/
@stevenhoney
stevenhoney / class-metabox.php
Last active October 12, 2016 13:52
Set Yoast metabox priority default to low when WooCommerce is active
<?php
/**
* @package WPSEO\Admin
*/
/**
* This class generates the metabox on the edit post / page as well as contains all page analysis functionality.
*/
class WPSEO_Metabox extends WPSEO_Meta {
<?php
function olivier_customer_bought_product( $customer_email, $user_id, $product_id ) {
global $wpdb;
$transient_name = 'wc_cbp_' . md5( $customer_email . $user_id . WC_Cache_Helper::get_transient_version( 'orders' ) );
if ( false === ( $result = get_transient( $transient_name ) ) ) {
$customer_data = array( $user_id );
if ( $user_id ) {
add_filter( 'woocommerce_get_price_html', 'sale_ends_banner', 100, 2 );
function sale_ends_banner( $price_html, $product ){
$sales_price_to = get_post_meta( $product->id, '_sale_price_dates_to', true );
if( $sales_price_to ){
$date_less_day = date_sub( $date, date_interval_create_from_date_string( "1 day") );
$formatted_date = date( 'l jS F', $date_less_day );
return $price_html."<p>Hurry! Sale Ends ".$formatted_date."</p>" ;
} else {
return $price_html;
@stevenhoney
stevenhoney / include-pre-release-check.liquid
Created October 28, 2020 22:38
Surface shopify product tag for on page JS
//Add this file to /snippets
{% assign is_presale_product = false %}
{% if product.tags contains 'pre-release' %}
{% assign is_presale_product = true %}
{% endif %}
<script>
var is_prerelease_product = "{{is_presale_product | json}}";
</script>
@stevenhoney
stevenhoney / Flag_Adjacent_Variants.flow
Created October 25, 2024 02:22
Shopify Flow Template - demonstrates sending an internal email when an order contains 'adjacent' variants of the same product, e.g. Large and XL of the same apparel product.
a042788e508239644175e7d0ad51b8fcfc9da71f506e9c40401cd0f3d2fe68ac:{"__metadata":{"version":0.1},"root":{"steps":[{"step_id":"b2a99540-9272-11ef-92ca-3fbe2773e2e8","step_position":[900,1100],"config_field_values":[],"task_id":"shopify::admin::order_created","task_version":"0.1","task_type":"TRIGGER","description":null,"note":null,"name":null},{"step_id":"ff8d44b0-9272-11ef-92ca-3fbe2773e2e8","step_position":[1220,1280],"config_field_values":[{"config_field_id":"input","value":"query{\n order {\n lineItems {\n product {\n handle\n }\n variant {\n position\n }\n }\n }\n}"},{"config_field_id":"script","value":"export default function main(input) {\n // Function to check adjacent variant positions\n let hasAdjacentVariants = false;\n // Group line items by product handle\n const groupedItems = input.order.lineItems.reduce((acc, item) => {\n const handle = item.product.handle;\n if (!acc[handle]) {\n acc[handle] = [];\n }\n acc[handle].push(item.variant.