Skip to content

Instantly share code, notes, and snippets.

@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();
}
}
@lucasstark
lucasstark / woocommerce-dynamic-pricing-output-json-variation-rules.php
Created Mar 28, 2019
Output Dynamic Pricing rules in JSON format for Variation Specific Rules.
View woocommerce-dynamic-pricing-output-json-variation-rules.php
add_action( 'wp_footer', function () {
if ( ! class_exists( 'WC_Dynamic_Pricing_Table' ) ) {
return;
}
$instance = WC_Dynamic_Pricing_Table::instance();
$array_rule_sets = $instance->get_pricing_array_rule_sets();
$json_prices = array();