Skip to content

Instantly share code, notes, and snippets.

View xlplugins's full-sized avatar

XLPlugins xlplugins

View GitHub Profile
@xlplugins
xlplugins / gist:361ce7ca3f0328903fffad32686dfe96
Last active April 14, 2025 07:27
Funnelkit Checkout: WooCommerce Conditional Checkout Fields Based on Product Type and Payment Method
class WFACP_Conditional_field_Based_On_Payment_Method {
// Payment method that requires address fields
public $address_required_payment = 'mollie_wc_gateway_klarna';
// Minimal fields that will always be shown
public $minimal_fields = [
'billing_email',
'billing_first_name',
'billing_last_name',
@xlplugins
xlplugins / update_order_meta_on_failure.php
Last active April 14, 2025 11:27
Update order meta based on order note for stripe failures & remove when order moved to completed stasuses
/** * Add a note to the order when the order status changes to failed
*
* @param int $order_id The ID of the order.
* @param WC_Order $order The order object.
* @param array $status_transition The status transition data.
*/
add_action( 'woocommerce_order_status_failed', function ( $order_id, $order, $status_transition ) {
if ( $order->get_payment_method() !== 'fkwcs_stripe' ) {
return;
}
@xlplugins
xlplugins / exclude CARD.js from defer in SiteGround optimizer
Created April 9, 2025 08:01
exclude CARD.js from defer in SiteGround optimizer
add_filter( 'sgo_js_async_exclude', function ( $exclude_list ) {
$exclude_list[] = 'jCard_js';
return $exclude_list;
} );
@xlplugins
xlplugins / gist:6af25d77540d35d88a5515bd31c9f1b0
Created April 8, 2025 13:26
Funnelkit Cart: Update Quanitity count when add or update in the cart item
class FunnelKitCartJsCookie_Quantity {
public function __construct() {
add_action( 'wp_head', [ $this, 'js' ] );
add_filter( 'fkcart_re_run_slide_cart', '__return_true' );
add_filter( 'fkcart_fragments', [ $this, 'send_fragments' ] );
}
public function send_fragments( $fragments ) {
$instance = FKCart\Includes\Front::get_instance();
$fragments['fkcart_qty'] = $instance->get_cart_content_count();
@xlplugins
xlplugins / amazon-pay
Created April 8, 2025 11:44
amazon-pay
add_action( 'woocommerce_after_checkout_form', function () {
echo '<div id="classic_pay_with_amazon"></div>';
} );
add_action( 'wp_footer', function () {
?>
<script>
(function ($) {
@xlplugins
xlplugins / gist:0c9ed7f98299bf5d0b2d0551f6196cd6
Created April 8, 2025 07:35
Funnelkit Checkout: Radio button conditional field
class WFACP_Conditional_field_tmp {
private $conditional_field = [];
public function __construct() {
/* Conditional fields */
$this->conditional_field = [
'tax_exempt_yn' => [ /* tax_exempt_yn*/
@xlplugins
xlplugins / Funnelkit Cart: Change the text of view details and rest to default
Last active April 8, 2025 06:53
Funnelkit Cart: Change the text of view details and rest to default
add_filter('fkcart_reset_to_variations',function(){
return "Reset to Default 1";
});
add_filter('fkcart_view_details',function(){
return "View Details 1";
});
@xlplugins
xlplugins / gist:110b8c71145082703a415b35d23a8286
Created April 7, 2025 14:23
Funnelkit Checkout: Compatability with Ecomus Addons by Drfuri
class WFACP_Ecomus_Addons {
public function __construct() {
add_action( 'wfacp_after_checkout_page_found', [ $this, 'remove_action' ] );
add_action( 'wfacp_before_process_checkout_template_loader', [ $this, 'remove_action' ] );
add_action( 'wfacp_internal_css', [ $this, 'add_css' ] );
}
public function remove_action() {
@xlplugins
xlplugins / gist:723bafaece93aee43db782ee6794bd8c
Created April 7, 2025 13:37
Funnelkit Checkout: Unset Shipping Address 2 field on the checkout page
class WFACP_WooCommerce_Field_Modifier {
private $unset_fields = [ 'shipping_address_2' ];
public function __construct() {
// Remove 'shipping_address_2' field
add_filter( 'wfacp_forms_field', [ $this, 'remove_required_fields' ], 9999, 10, 2 );
}
// Method to remove required fields
@xlplugins
xlplugins / gist:cac2be4a5b18964007ca7860bf74f8ff
Last active April 8, 2025 10:44
Funnelkit Checkout: WooCommerce Checkout Field Special Character Validator
class WFACP_Field_Validator {
/**
* Disallowed characters in checkout fields
*/
private $disallowed_chars = array( '-', '#', '/', '\\', '=', '<', '>', '(', ')' );
/**
* Fields to validate against disallowed characters
*/