Skip to content

Instantly share code, notes, and snippets.

View xlplugins's full-sized avatar

XLPlugins xlplugins

View GitHub Profile
@xlplugins
xlplugins / custom checkbox for offer page
Last active February 27, 2026 14:02
custom checkbox for offer page
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
$allowed_offer_ids = array( 123 , 2487 );
add_action( 'wfocu_add_custom_html_above_accept_button', function( $product_id, $product_key ) use ( $allowed_offer_ids ) {
$offer_id = WFOCU_Core()->data ? WFOCU_Core()->data->get( 'current_offer' ) : 0;
$offer_id = $offer_id ?: get_the_ID();
if ( ! in_array( (int) $offer_id, $allowed_offer_ids, true ) ) {
@xlplugins
xlplugins / FKCart + woo discount rules - Coupon 0.00 Fix
Last active February 24, 2026 13:14
FKCart + Discount Rules for WooCommerce - Coupon 0.00 Fix
if ( ! defined( 'ABSPATH' ) ) exit;
add_filter( 'woocommerce_coupon_discount_amount_html', function( $h, $c ) {
if ( ! $c || ! WC()->cart || (float) WC()->cart->get_coupon_discount_amount( $c->get_code(), WC()->cart->display_cart_ex_tax ) > 0 ) return $h;
$code = strtolower( $c->get_code() ); $m = \Wdr\App\Controllers\ManageDiscount::class;
$v = $m::$apply_as_coupon_values[ $code ]['value'] ?? null;
if ( $v === null ) foreach ( $m::$applied_cart_coupon_discounts ?? [] as $x ) { if ( strtolower( $x['name'] ?? '' ) === $code ) { $v = $x['value']; break; } }
if ( $v === null && count( WC()->cart->get_applied_coupons() ) === 1 ) {
$v = 0;
@xlplugins
xlplugins / fKCart Rewards - Total Fallback
Created February 24, 2026 09:53
fKCart Rewards - Total Fallback
add_filter( 'fkcart_reward_total', 'fkcart_rewards_total_fallback', 999, 3 );
function fkcart_rewards_total_fallback( $total, $calculation_mode, $front ) {
if ( 'total' !== $calculation_mode ) {
return $total;
}
if ( is_null( WC()->cart ) || WC()->cart->is_empty() ) {
return $total;
}
// Only fallback when total is 0 or negative but cart has items
@xlplugins
xlplugins / fKCart Rewards - Total Fallback
Created February 24, 2026 09:53
fKCart Rewards - Total Fallback
add_filter( 'fkcart_reward_total', 'fkcart_rewards_total_fallback', 999, 3 );
function fkcart_rewards_total_fallback( $total, $calculation_mode, $front ) {
if ( 'total' !== $calculation_mode ) {
return $total;
}
if ( is_null( WC()->cart ) || WC()->cart->is_empty() ) {
return $total;
}
// Only fallback when total is 0 or negative but cart has items
@xlplugins
xlplugins / WPC Product Bundles for WooCommerce by wpclever cart variation support
Created February 24, 2026 06:32
WPC Product Bundles for WooCommerce by wpclever cart variation support
/**
* Product Addons + FKCart: Fix duplicate checkbox/switch IDs in quick view.
* Uses: prad_block_rendered (Product Addons), fkcart_cart_quick_view_open (FKCart).
*/
add_filter( 'prad_block_rendered', function ( $html, $block, $product_id ) {
if ( ! ( wp_doing_ajax() && ( ( isset( $_GET['wc-ajax'] ) && 'fkcart_quick_view' === $_GET['wc-ajax'] ) || ( isset( $_REQUEST['action'] ) && 'fkcart_quick_view' === $_REQUEST['action'] ) ) ) ) {
return $html;
}
if ( ! preg_match( '/data-bid=["\']([^"\']+)["\']/', $html, $m ) ) {
return $html;
@xlplugins
xlplugins / cart upsell product short description
Created February 23, 2026 13:22
cart upsell product short description
/**
* Upsell short description: show below product name (no layout changes)
*/
add_action( 'fkcart_before_upsell_price', function( $product_id, $cart_item ) {
if ( isset( $cart_item['product'] ) && $cart_item['product'] instanceof WC_Product ) {
$short_desc = $cart_item['product']->get_short_description();
if ( ! empty( $short_desc ) ) {
echo '<div class="fkcart-upsell-short-description">' . wp_kses_post( $short_desc ) . '</div>';
}
@xlplugins
xlplugins / FKWCS Upsell Stripe Intent Update
Created February 20, 2026 12:30
FKWCS Upsell Stripe Intent Update
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
add_action( 'wfocu_offer_new_order_created', 'fkwcs_update_stripe_intent_for_upsell_order', 20, 2 );
function fkwcs_update_stripe_intent_for_upsell_order( $new_order, $txn_id ) {
try {
if ( ! $new_order instanceof WC_Order ) {
return;
@xlplugins
xlplugins / shipping layout one by one
Created February 20, 2026 11:05
shipping layout one by one
/**
* Plugin Name: WFACP Shipping Layout - One by One
* Description: Snippet-only. Block-style shipping (name, est, price on separate lines). No core edits.
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
add_filter( 'woocommerce_cart_shipping_method_full_label', 'wfacp_shipping_label_split', 10, 2 );
@xlplugins
xlplugins / shipping layout one by one
Created February 20, 2026 11:05
shipping layout one by one
/**
* Plugin Name: WFACP Shipping Layout - One by One
* Description: Snippet-only. Block-style shipping (name, est, price on separate lines). No core edits.
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
add_filter( 'woocommerce_cart_shipping_method_full_label', 'wfacp_shipping_label_split', 10, 2 );
@xlplugins
xlplugins / Trigger Choose Option WHen Click on Add Button
Last active February 25, 2026 08:24
Trigger Choose Option WHen Click on Add Button
jQuery(function($){
$('body').on('click','.wfob_choose_variation',function(e){
e.preventDefault();
e.stopPropagation();
$(this)
.closest('.wfob_wrapper')
.find('.wfob_qv-button.var_product')
.trigger('click');