Skip to content

Instantly share code, notes, and snippets.

View xlplugins's full-sized avatar

XLPlugins xlplugins

View GitHub Profile
@xlplugins
xlplugins / Theme lite Compatiblity
Created September 20, 2024 14:56
Theme lite Compatiblity
class WFACP_theme_high_lite {
private $fields = [];
public function __construct() {
//add_filter( 'woocommerce_checkout_fields', [ $this, 'fetch_field' ], - 10 );
add_filter( 'wfacp_checkout_fields', [ $this, 'push_field' ], 100,2 );
}
public function fetch_field( $fields ) {
@xlplugins
xlplugins / apply_coupon_even_when_cart_empty.php
Created September 20, 2024 13:26
Apply coupon even when cart empty
// Function to store the coupon in the session on the homepage
function store_coupon_in_session() {
if ( ! is_checkout() && class_exists( 'WooCommerce' ) ) {
// Replace 'your-coupon-code' with your actual coupon code
$coupon_code = 'test';
// Save the coupon code in WooCommerce session
WC()->session->set( 'stored_coupon_code', $coupon_code );
// Apply coupon immediately if the cart is initialized
@xlplugins
xlplugins / gist:73bae05c1f9fcb546d19eb49b17d2fef
Created September 20, 2024 12:05
Funnelkit Cart: compatbility with Discount Rules Core by Flycart 2.6.6
class FKCART_Woo_Discount_Rule {
public function __construct() {
add_filter( 'fkcart_enable_item_link', [ $this, 'add_item_meta' ] );
}
public function add_item_meta( $status ) {
@xlplugins
xlplugins / HIde free shipping for Recurring cart At funnelkit checkout
Created September 20, 2024 08:01
HIde free shipping for Recurring cart At funnelkit checkout
add_filter('woocommerce_package_rates', 'remove_free_shipping_for_recurring_cart', 10, 2);
function remove_free_shipping_for_recurring_cart($rates, $package) {
// Check if it's a recurring cart
if (isset($package['recurring_cart_key'])) {
// Loop through the rates
foreach ($rates as $rate_id => $rate) {
// Check if the rate is for free shipping
if ('free_shipping' === $rate->method_id) {
// Unset the free shipping rate
unset($rates[$rate_id]);
@xlplugins
xlplugins / Add_script_on_second_step_of_checkout.js
Created September 17, 2024 11:03
Add script on second step of checkout
<script>
jQuery(document).ready(function($) {
$(document.body).on('wfacp_step_switching', function(e, v) {
console.log(e, v); // This will log the event and the step object
if (v.current_step === 'two_step') {
// Your custom jQuery code for the second step goes here
console.log("User has reached the second step!");
// Example: Change the background color of the body
@xlplugins
xlplugins / Enable country and zip code field in Funnelkit Stripe
Last active September 17, 2024 14:31
Enable country and zip code field in Funnelkit Stripe
/**
* add address fields auto for the Credit card fields
*/
add_filter( 'fkwcs_stripe_payment_element_data', function ( $element_config ) {
$element_config['element_options']['fields']['billingDetails'] = [];
$element_config['element_options']['fields']['billingDetails']['address'] = 'auto';
return $element_config;
} );
@xlplugins
xlplugins / gist:dff0af185e018bf280a3c8dec68adb36
Last active September 17, 2024 13:22
Funnelkit: Compatibility with FastCredit for WooCommerce (Premium)
class FKCART_FastCredit_For_WC {
private $subtotal_price = null;
private $text_find = 'Credit';
public function __construct() {
add_filter( 'fkcart_enable_item_link', [ $this, 'add_item_meta' ] );
add_action( 'wfacp_after_template_found', [ $this, 'actions' ] );
}
@xlplugins
xlplugins / script_with_order_variables.php
Created September 16, 2024 12:38
Generic tracking script with order variables
function render_custom_script_tracking( $general_data ) {
if ( ! is_array( $general_data ) || 0 === count( $general_data ) ) {
return;
}
$order_id = isset( $general_data['order_id'] ) ? $general_data['order_id'] : 0;
if ( 0 === $order_id && isset( $_GET['order_id'] ) ) {
$order_id = $_GET['order_id'];
}
@xlplugins
xlplugins / gist:b9788e545b2c3276a6ad172509aa2d1a
Created September 13, 2024 12:43
Funnelkit Checkout: Add custom fee based on the checkbox selected
class Add_Custom_Fee_On_Change_Checkbox {
private $field_lable = 'Shipping Way Fee';
private $checkout_fields = [
'shipping_way_0' => [
'label' => 'Fast shipping',
'price' => 10
],
'shipping_way_1' => [
'label' => 'Deliver in evening',
@xlplugins
xlplugins / Landing page Variable product to Dedicated checkout page
Created September 13, 2024 11:13
Landing page Variable product to Dedicated checkout page
// Note - Do not add any product here https://i.imgur.com/mcVGiNP.png
class WFFN_Change_Action_Of_Add_To_Cart {
public $checkout_url = 'http://funnellocal1.local/checkouts/checkout-copy-4/'; // redirect to this link
public function __construct() {
add_action( 'wfacp_after_checkout_page_found', [ $this, 'remove_notice' ] );
add_filter( 'woocommerce_add_to_cart_form_action', [ $this, 'change_form_action' ] );
}