Skip to content

Instantly share code, notes, and snippets.

View lucasstark's full-sized avatar

Lucas Stark lucasstark

View GitHub Profile
#!/bin/bash
# Get the Homebrew installation prefix
BREW_PREFIX=$(brew --prefix)
# Homebrew MySQL client tools path
MYSQL_CLIENT_PATH="${BREW_PREFIX}/bin"
echo "MySQL Client Tools: $MYSQL_CLIENT_PATH"
@lucasstark
lucasstark / dump-woocommerce-order-information.php
Created December 20, 2023 12:58
dump-woocommerce-order-information
<?php
function dump_wc_order(): void {
$order_id = null;
// Check if there's a $_GET parameter for the order ID
if (isset($_GET['debug_order_id'])) {
$order_id = intval($_GET['debug_order_id']);
} else {
return;
}
@lucasstark
lucasstark / woocommerce-gravityforms-product-addons-modify-store-cart-edit.php
Last active November 7, 2023 13:07
Set Gravity Forms Product Addons to always edit a product in the cart, regardless of where that item was navigated from.
/**
* Attempts to retrieve the cart item key for a product that is enabled for cart editing.
*
* @param int $product_id The ID of the product to check.
*
* @return false|string The cart item key if found, false otherwise.
*/
function wc_gfpa_get_cart_edit_key( $product_id ) {
if ( is_admin() || ! WC()->cart ) {
return false;
@lucasstark
lucasstark / Sample Custom Field
Created May 25, 2023 11:17
Add Sample Custom Product Field for Testing
class Product_Custom_Field {
public function __construct() {
add_action( 'woocommerce_before_add_to_cart_button', array( $this, 'display_custom_field' ) );
add_filter( 'woocommerce_add_cart_item_data', array( $this, 'add_cart_item_data' ), 10, 2 );
add_filter( 'woocommerce_get_item_data', array( $this, 'get_item_data' ), 10, 2 );
add_action( 'woocommerce_checkout_create_order_line_item', array( $this, 'checkout_create_order_line_item' ), 10, 4 );
}
public function display_custom_field() {
echo '<div class="custom-field-wrapper">';
SELECT ssbsect.ssbsect_term_code AS term_code,
scbcrse.scbcrse_subj_code AS subject_code,
scbcrse.scbcrse_crse_numb AS course_number,
ssbsect_seq_numb AS section_number,
scbcrse.scbcrse_title AS course_title,
COALESCE (ssbsect_crse_title, scbcrse_title) as section_title,
scbcrse.scbcrse_credit_hr_low AS credit_hours_min,
scbcrse.scbcrse_credit_hr_high AS credit_hours_max,
scbcrse.scbcrse_lec_hr_low AS lecture_hours_min,
scbcrse.scbcrse_lec_hr_high AS lecture_hours_max,
#
# SQL Export
# Created by Querious (303012)
# Created: May 3, 2023 at 11:04:47 AM EDT
# Encoding: Unicode (UTF-8)
#
SET @ORIG_TIME_ZONE = @@TIME_ZONE;
SET TIME_ZONE = '+00:00';
/*! For license information please see path_design_system_icons.js.LICENSE.txt */
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["React"],t):"object"==typeof exports?exports.PathDesignSystemIcons=t(require("react")):e.PathDesignSystemIcons=t(e.React)}(this,(function(e){return(()=>{var t={2432:(e,t,r)=>{"use strict";t.__esModule=!0,t.default=void 0;var n=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=a(t);if(r&&r.has(e))return r.get(e);var n={},c=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var l=c?Object.getOwnPropertyDescriptor(e,o):null;l&&(l.get||l.set)?Object.defineProperty(n,o,l):n[o]=e[o]}return n.default=e,r&&r.set(e,n),n}(r(4639));function a(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(a=function(e){return e?r
@lucasstark
lucasstark / ES_GFPA_CartItemWeight.php
Created June 29, 2022 08:59
Use Gravity Forms to set a WooCommerce cart item's weight.
<?php
/**
* Class ES_GFPA_CartItemWeight
*
* Allows for a product to use a set of Gravity Forms fields to set the cart item's weight
*
*/
class ES_GFPA_CartItemWeight {
@lucasstark
lucasstark / class-wc-dynamic-pricing-admin-product-column.php
Created September 30, 2021 14:15
Add sortable Has Pricing Rules Admin Column for Dynamic Pricing.
class WC_Dynamic_Pricing_Admin_Product_Column {
private static $instance;
public static function register() {
if ( self::$instance == null ) {
self::$instance = new WC_Dynamic_Pricing_Admin_Product_Column();
}
}
protected function __construct() {
@lucasstark
lucasstark / swatches-organizer.php
Last active August 25, 2021 17:00
Organize swatches into groups based on the attribute name after a dash.
class Swatches_Organizer {
private static $instances = null;
public static function register( $taxonomy_slug ) {
if ( self::$instances == null ) {
self::$instances = new Swatches_Organizer( $taxonomy_slug );
}
}
protected $taxonomy_slug;