Skip to content

Instantly share code, notes, and snippets.

View CrispDev's full-sized avatar

Crisp Design Custom Dev CrispDev

  • Crisp Design Co. Custom Project Development
  • Denver, CO
View GitHub Profile
@CrispDev
CrispDev / functions.php
Created December 20, 2023 19:04
MySQL Script Batch Update Variable Products Manage Stock flag
<?php
/**
* Product Status Utility.
*/
function lm_generate_and_update_products(){
if ( !isset($_GET['xx-products'] ) )
return;
@CrispDev
CrispDev / functions.php
Created November 14, 2023 20:46
Shortcode to Insert one page into another.
<?php
/**
* Outputs A section
* @param array $atts. The shortcode params.
*/
function crb_output_content_section ( $atts = [] ) {
$atts = shortcode_atts( array(
'page' => 0,
@CrispDev
CrispDev / functions.php
Created September 8, 2023 22:13
Spam Order Handler w/ACF
<?php
/**
* Updates the currently stored Spam IPS with new ones.
*
* @param array $new_ips The new ips to add.
*/
function dcrcoffee_update_spam_ips( $new_ips = [] ) {
@CrispDev
CrispDev / debug.php
Created February 8, 2023 15:25
CrispX Development // PHP Script Execution
<?php
global $crispx_timer;
//Start Timer XDebug
$time_start = microtime(true);
/**
Run All Code Here
@CrispDev
CrispDev / style.css
Created October 12, 2022 09:35
Autoship Customization // Style Autoship Options based on Selection
.product.autoship-active div.autoship-type.autoship-yes{
border: 1px solid #9bc99b;
background-color: #9bc99b38;
border-radius: 5px;
}
.product.autoship-not-active div.autoship-type.autoship-no{
border: 1px solid #9bc99b;
background-color: #9bc99b38;
border-radius: 5px;
@CrispDev
CrispDev / functions.php
Created October 3, 2022 20:20
Autoship Customization // Disable Delete until N Cycles
<?php
/**
* Displays the Scheduled Order Display Schedule form
*
* @param array $autoship_order The autoship order array.
* @param int $customer_id The woocommerce customer id.
* @param int $autoship_customer_id The autoship customer id.
*
@CrispDev
CrispDev / functions.php
Created September 27, 2022 21:22
Autoship Example // Track Product Upsert Calls and Related Data
<?php
/**
* Tracks data sent to Qpilot from the Product Upsert
*
* @param array $args The Product & Call Data Upserted
*/
function xx_track_product_upsert_data( $args ){
xx_debug( '============ Product Upsert API Call Made ===============', true );
@CrispDev
CrispDev / functions.php
Last active August 11, 2022 18:46
Autoship Customization // Using Add To Cart function manually
<?php
/**
* Catches a custom get link, adds the item and sets the temp schedule
*/
function xx_auto_add_item(){
if ( empty( $product_id = filter_input( INPUT_GET, 'pid', FILTER_SANITIZE_NUMBER_INT ) ) )
return;
@CrispDev
CrispDev / functions.php
Created July 20, 2022 22:12
Autoship Customizations // Force Save Payment Method later in Page Load
/**
* Inserts Custom JQuery Code to Force Save Payment Information on Custom Checkout Pages
* Only gets included if the current order includes one or more autoship items
* @see autoship_cart_has_valid_autoship_items()
*/
function xx_force_save_card_for_autoship_orders_w_checkoutwc() {
if ( !autoship_cart_has_valid_autoship_items() )
return;
@CrispDev
CrispDev / functions.php
Created July 15, 2022 18:31
Autoship Customization // Gather the Next Occurrence dates for all Scheduled orders created at checkout
/**
* Gather the Next Occurrence dates for all Scheduled orders created at checkout
* and save those dates to the original WC Checkout Order
*
* @param array $scheduled_order_ids The created Scheduled Order IDs
* @param int $order_id The WC Order ID
* @param array $scheduled_orders The created Scheduled Orders in stdClass objects
*/
function xx_track_scheduled_order_next_occurrences_at_checkout( $scheduled_order_ids, $order_id, $scheduled_orders ){