Skip to content

Instantly share code, notes, and snippets.

Avatar

Lucas Stark lucasstark

View GitHub Profile
@lucasstark
lucasstark / ES_GFPA_CartItemWeight.php
Created Jun 29, 2022
Use Gravity Forms to set a WooCommerce cart item's weight.
View ES_GFPA_CartItemWeight.php
<?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 Sep 30, 2021
Add sortable Has Pricing Rules Admin Column for Dynamic Pricing.
View class-wc-dynamic-pricing-admin-product-column.php
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 Aug 25, 2021
Organize swatches into groups based on the attribute name after a dash.
View swatches-organizer.php
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;
@lucasstark
lucasstark / wc-wishlists-account-endpoint.php
Last active Sep 2, 2021
Modify WooCommece Wishlist's Endpoint Slug
View wc-wishlists-account-endpoint.php
class WC_Wishlists_Account_Endpoint {
private static $instance;
public static function register($endpoint_slug, $endpoint_name) {
if ( self::$instance == null ) {
self::$instance = new WC_Wishlists_Account_Endpoint($endpoint_slug, $endpoint_name);
}
}
protected $endpoint_slug;
View gravity-forms-product-addons-signature-helper
add_filter( 'gform_delete_lead', function ( $lead_id ) {
if ( function_exists( 'gf_signature' ) ) {
$lead = RGFormsModel::get_lead( $lead_id );
$form = RGFormsModel::get_form_meta( $lead['form_id'] );
if ( !is_array( $form['fields'] ) ) {
return;
}
@lucasstark
lucasstark / swatches-on-archive.php
Created Dec 1, 2020
Add WooCommerce Variation Swatches and Photos to the Archive Page
View swatches-on-archive.php
function wc_swatches_shop_loop_item_href( $product, $attribute_name, $attribute_value ) {
$url = add_query_arg( array(
$attribute_name => $attribute_value
), $product->get_permalink() );
return $url;
}
View custom-dynamic-pricing
class WC_Custom_Dynamic_Pricing_Context {
/**
* @var WC_Custom_Dynamic_Pricing_Context
*/
private static $instance;
/**
* Helper to bootstrap the class.
*/
public static function register() {
@lucasstark
lucasstark / dynamic-pricing-product-attribute-adjustments.php
Created Jun 21, 2019
Custom Product Attribute Advanced Rules for Dynamic Pricing
View dynamic-pricing-product-attribute-adjustments.php
class WC_Dynamic_Pricing_Product_Attribute_Adjustments {
private static $instance;
public static function register( $product_attribute, $label ) {
if ( self::$instance == null ) {
self::$instance = [];
}
if ( ! isset( self::$instance[ $product_attribute ] ) ) {
@lucasstark
lucasstark / gravityforms-product-addons-enable-signature-field.php
Created Apr 29, 2019
Enable Gravity Forms Signature for WooCommerce Gravity Forms Product Addons
View gravityforms-product-addons-enable-signature-field.php
add_filter( 'gform_delete_lead', function ( $lead_id ) {
if ( function_exists( 'gf_signature' ) ) {
$lead = RGFormsModel::get_lead( $lead_id );
$form = RGFormsModel::get_form_meta( $lead['form_id'] );
if ( ! is_array( $form['fields'] ) ) {
return;
@lucasstark
lucasstark / ES_GravityForms_Grouped_Product_Add_To_Cart_Handler.php
Created Apr 24, 2019
Support Grouped Products for Gravity Forms Product Addons
View ES_GravityForms_Grouped_Product_Add_To_Cart_Handler.php
class ES_GravityForms_Grouped_Product_Add_To_Cart_Handler {
private static $instance;
public static function register() {
if ( self::$instance == null ) {
self::$instance = new ES_GravityForms_Grouped_Product_Add_To_Cart_Handler();
}
}