Skip to content

Instantly share code, notes, and snippets.

View xlplugins's full-sized avatar

XLPlugins xlplugins

View GitHub Profile
@xlplugins
xlplugins / Hide a FunnelKit Cart reward unless the cart contains a product
Last active June 4, 2026 14:46
Hide a FunnelKit Cart reward unless the cart contains a product
/**
* FKCart category based free gift rewards.
* 1876 => carnes-del-corral
* 29711 => carnes-del-mar
*/
add_filter( 'fkcart_rewards_list', 'my_fkcart_category_rewards_list', 999 );
add_filter( 'fkcart_gift_products', 'my_fkcart_category_gift_products', 999, 2 );
add_action( 'wp_footer', function () {
@xlplugins
xlplugins / download plugin snippet
Created May 26, 2026 13:13
download plugin snippet
<?php
/**
* Plugin Name: WP ZIP Downloader
* Description: Download installed plugins and themes as ZIP files without ZipArchive.
* Version: 1.0.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
@xlplugins
xlplugins / coupon discount inside the FunnelKit sliding cart
Created May 25, 2026 11:32
coupon discount inside the FunnelKit sliding cart
/**
* Show the cumulative coupon discount inside the FunnelKit sliding cart,
* just above the checkout button.
*/
add_action( 'fkcart_before_checkout_button', 'betterwood_fkcart_discount_anzeigen' );
function betterwood_fkcart_discount_anzeigen() {
if ( is_null( WC()->cart ) || WC()->cart->is_empty() ) {
return;
@xlplugins
xlplugins / override product link for fkcart
Last active May 25, 2026 11:07
override product link for fkcart
@xlplugins
xlplugins / Fix Google Map Auto Complete On Reload
Last active June 6, 2026 06:11
Fix Google Map Auto Complete On Reload
add_action('wp_footer', function () {
if ( ! function_exists('is_checkout') || ! is_checkout() ) return;
?>
<script>
(function ($) {
var attached = { billing: false, shipping: false };
function ready() {
return window.google && google.maps && google.maps.places;
}
@xlplugins
xlplugins / Apply Discount on Regular price instead of sale price. if sale price configured at product level then we not apply sublium discount on Subscribe and save
Created May 22, 2026 10:32
Apply Discount on Regular price instead of sale price. if sale price configured at product level then we not apply sublium discount on Subscribe and save
/**
* Force Sublium Subscribe & Save discount to calculate against
* the product's regular price, not the sale price.
*
* Works on product page, cart, and checkout.
* Place in your child theme's functions.php or a site-specific plugin.
*/
add_filter( 'sublium_wcs_plan_price', 'sublium_sns_discount_on_regular_price', 10, 3 );
function sublium_sns_discount_on_regular_price( $price, $product, $plan ) {
@xlplugins
xlplugins / Theme order confirmation template overrides fix by fk
Created May 20, 2026 12:30
Theme order confirmation template overrides fix by fk
add_filter( 'page_template_hierarchy', function( $templates ) {
if ( isset( $_GET['wfty_source'] ) || isset( $_GET['wfocu-si'] ) || isset( $_GET['wfacp_is_checkout_override'] ) ) {
return array_values( array_diff( $templates, array( 'order-confirmation' ) ) );
}
return $templates;
}, 99 );
@xlplugins
xlplugins / validate_phone_field_for_9_digits.php
Created May 20, 2026 07:14
Validate phone field for 9 digits
add_action( 'woocommerce_checkout_process', 'validate_billing_phone_9_digits' );
function validate_billing_phone_9_digits() {
$phone = isset( $_POST['billing_phone'] ) ? sanitize_text_field( $_POST['billing_phone'] ) : '';
// Remove all spaces and non-digit characters before checking
$phone_digits = preg_replace( '/\D/', '', $phone );
if ( strlen( $phone_digits ) !== 9 ) {
wc_add_notice(
@xlplugins
xlplugins / Tm organic by ThemeMove
Last active May 19, 2026 12:27
Tm organic by ThemeMove
add_action( 'woocommerce_login_form_end', function () {
if ( ! class_exists( 'WFACP_Common' ) || WFACP_Common::get_id() < 1 ) {
return;
}
$wfacp_id = absint( WFACP_Common::get_id() );
if ( 'wfacp_checkout' !== get_post_type( $wfacp_id ) ) {
return;
}
@xlplugins
xlplugins / Disable new user creation email during the checkout if cart contain sublium subscription
Created May 19, 2026 06:17
Disable new user creation email during the checkout if cart contain sublium subscription
add_filter( 'woocommerce_email_enabled_customer_new_account', function( $enabled, $object ) {
      // Check if we're in a checkout/order processing context with a Sublium plan in cart
      if ( WC()->cart && \Sublium_WCS\Includes\Main\Cart::get_instance()->cart_contains_plan() ) {
          return false;
      }
      return $enabled;
  }, 10, 2 );