Skip to content

Instantly share code, notes, and snippets.

View xlplugins's full-sized avatar

XLPlugins xlplugins

View GitHub Profile
@xlplugins
xlplugins / gist:cc03eadd5afae86a2e90828d94cb0364
Created July 1, 2025 11:48
Funnelkit Checkout: Disabled Zoom and autofill update for billing email field
class WFACP_Billing_Email_Autofill_Disabled_zoom{
public function __construct() {
add_filter( 'wfacp_forms_field', [ $this, 'add_css_class' ], 99, 2 );
add_filter('wfacp_intial_scale_default','__return_true');
}
function add_css_class( $field, $key ) {
if ( $key !== 'billing_email' || !isset($field['autocomplete'])) {
return $field;
@xlplugins
xlplugins / snippet.php
Created June 30, 2025 10:28
Remove the frontend script a& metabox based on tracking settings
/**
* Conditionally removes the FunnelKit (WooFunnels) frontend tracking scripts.
*
* This function checks if the "Track UTMs" setting in FunnelKit's general settings
* is disabled. If it is, it removes the action responsible for enqueuing the
* e-commerce tracking scripts, preventing them from being loaded on the site's frontend.
*
* It hooks into 'wp_enqueue_scripts' with a very early priority (-1) to ensure
* it runs before the target action is executed.
*
@xlplugins
xlplugins / re include google pay js if google.payment is deleted by some js
Created June 27, 2025 14:15
re include google pay js if google.payment is deleted by some js
add_action( 'wfacp_meta_added', function () {
?>
<script>
(function watchAllScriptLoads() {
function loadScript(src, callback) {
var script = document.createElement('script');
script.src = src;
script.onload = callback;
@xlplugins
xlplugins / disable or fadeout checkout button in funnelkit cart when cart total is less than 50
Last active June 25, 2025 14:37
disable or fadeout checkout button in funnelkit cart when cart total is less than 50
add_action( 'fkcart_before_checkout_button', function () {
$min = 50;
$max = 100;
if ( null === WC()->cart ) {
return;
}
$total = WC()->cart->get_total( 'edit' );
if ( $total < $min || $total <=$max ) {
?>
@xlplugins
xlplugins / display Tax and vat conditionally
Created June 25, 2025 07:53
display Tax and vat conditionally
add_filter( 'woocommerce_countries_tax_or_vat', function( $label ) {
$country = '';
// Try to get customer's country from session
if ( WC()->customer ) {
$country = WC()->customer->get_taxable_address()[0];
}
// Fallback to store base country if no customer country yet (e.g., first visit)
if ( empty( $country ) ) {
@xlplugins
xlplugins / Shipping Method validtions
Created June 24, 2025 11:54
Shipping Method validtions
add_action( 'woocommerce_checkout_process', 'force_choose_shipping_method' );
function force_choose_shipping_method() {
if ( WC()->cart->needs_shipping() ) {
$chosen_method = WC()->session->get( 'chosen_shipping_methods' );
if ( empty( $chosen_method ) || empty( $chosen_method[0] ) ) {
wc_add_notice( __( 'Please select a shipping method to proceed.', 'woocommerce' ), 'error' );
}
}
@xlplugins
xlplugins / Print Attribute under the product name in product switcher
Created June 24, 2025 11:22
Print Attribute under the product name in product switcher
// Custom function to get variation data for cart or non-cart products
function wc_get_flexible_item_data( $cart_item_or_product, $flat = false ) {
$item_data = array();
$product = null;
$variation_data = array();
// Determine if we're working with a cart item or just a product
if ( is_array( $cart_item_or_product ) && isset( $cart_item_or_product['data'] ) ) {
// Cart item
$product = $cart_item_or_product['data'];
@xlplugins
xlplugins / gist:26b2d9af2075f4bd59522440992bf1c9
Created June 24, 2025 10:43
Funnelkit Cart: Change the reward total using filter hook
class FKCART_Change_Reward_Total{
public function __construct(){
add_filter('fkcart_reward_total',[$this,'change_reward_total'],10,2);
}
public function change_reward_total($total,$calculation_mode){
@xlplugins
xlplugins / Hide autoship option for non subscription product
Created June 23, 2025 14:37
Hide autoship option for non subscription product
add_filter( 'fkcart_select_options_label', function ( $text, $cart_item ) {
if ( ! ( isset( $cart_item['cart_item']['bos4w_data'] ) && ! empty( $cart_item['cart_item']['bos4w_data']['selected_subscription'] ) ) ) {
$text = '';
}
return $text;
} ,11,2);
@xlplugins
xlplugins / Checkout: compatability with HFD ePost Integration by HFD
Created June 18, 2025 14:52
Checkout: compatability with HFD ePost Integration by HFD
add_action( 'wfacp_internal_css', function () {
if(!class_exists('\Hfd\Woocommerce\Container')){
return;
}
$helper = \Hfd\Woocommerce\Container::get('Hfd\Woocommerce\Helper\Spot');
?>
<script>
window.addEventListener('load', function () {
(function ($) {