Skip to content

Instantly share code, notes, and snippets.

View xlplugins's full-sized avatar

XLPlugins xlplugins

View GitHub Profile
@xlplugins
xlplugins / reload dedicated checkout page in case of cart session expire during the checkout
Created May 2, 2024 14:39
reload dedicated checkout page in case of cart session expire during the checkout
add_action( 'wc_ajax_checkout', function () {
try {
// If the cart is empty, the nonce check failed because of session expiry.
if ( isset( $_GET['wfacp_is_checkout_override'] ) && 'no' == $_GET['wfacp_is_checkout_override'] && ! is_null( WC()->cart ) && WC()->cart->is_empty() ) {
$response = array(
'result' => 'failure',
'messages' => isset( $messages ) ? $messages : '',
'refresh' => false,
'reload' => true,
@xlplugins
xlplugins / disable ajax add to cart for booking product
Created May 2, 2024 07:41
disable ajax add to cart for booking product
add_filter( 'fkcart_is_ajax_add_to_cart_enabled', function ( $status ) {
global $post;
$product=wc_get_product($post->ID);
if ( is_null( $product ) || !$product instanceof WC_Product ) {
return $status;
}
if ( 'booking' === $product->get_type() ) {
$status = 'no';
}
@xlplugins
xlplugins / do not persistant cart for aerocheckout (Rare Case)
Created May 1, 2024 07:42
do not persistant cart for aerocheckout (Rare Case)
add_filter( 'wfacp_remove_persistent_cart_after_merging', '__return_false' );
@xlplugins
xlplugins / Page open without adding any product in Funnelkit checkout
Last active April 30, 2024 13:46
Page open without adding any product in Funnelkit checkout no product selected on checkout unset uncheck
class WFACP_WorkWithout_Sesscion {
public function __construct() {
add_filter( 'wfacp_run_add_to_cart_at_load', [ $this, 'do_not_add_primary_product' ] );
add_action( 'wfacp_internal_css', [ $this, 'js' ] );
}
public function set_session() {
if ( ! is_null( WC()->session ) && false === WC()->session->has_session() ) {
WC()->session->set_customer_session_cookie( true );
WC()->session->save_data();
@xlplugins
xlplugins / Meta value replaced
Created April 30, 2024 12:00
Meta value replaced
add_action( 'admin_menu', function () {
if ( ! isset( $_GET['funnelkit_update_meta_value'] ) ) {
return;
}
$field_key = 'c_order_theme_title';
$storecheckout_id = 12572;
$fields = WFACP_Common::get_page_custom_fields( $storecheckout_id );
if ( empty( $fields['advanced'][ $field_key ] ) || empty( $fields['advanced'][ $field_key ]['options'] ) ) {
return false;
@xlplugins
xlplugins / gist:9ea8602db80e2754d1b9cc5efaed493a
Created April 30, 2024 08:50
Funnnelkit Checkout: Display the custom field of billing and shipping on the thank you page
class WFACP_Display_Billing_Shipping_Field_On_Thanku_Page {
public function __construct() {
/*
* Need to update billing format address
*
*/
add_filter( 'woocommerce_order_get_formatted_billing_address', [ $this, 'wc_order_get_formatted_billing_address' ], 10, 3 );
/*
* Need to update Shipping format address
@xlplugins
xlplugins / Checkout field Display on funnelkit checkout page - final
Last active April 29, 2024 13:14
Checkout field Display on funnelkit checkout page - final last updated 5 march 2024
class WFACP_Custom_Billing_Fields_for_WooCommerce_combine {
public $new_fields = [];
public $fields_added = [];
private $checkout_fields = [];
public $previous_keys = [];
public $default_field = [
'id' => 'wc_custom_field',
'name' => 'WC Custom Field',
];
private $woocommerce_checkout_fields = [];
@xlplugins
xlplugins / gist:2249889c5cedfe0376f572fb95e007d2
Created April 26, 2024 11:47
Funnelkit Cart: Compatibility added with WooCommerce Mix and Match Products by Kathy Darling
class FKCART_Woo_Mix_And_Match_Products {
private $cart = [];
private $print_html=false;
public $button_html='';
public function __construct() {
add_action('fkcart_after_item_meta',[$this,'action'],999,2);
@xlplugins
xlplugins / gist:3ec21e4a2ac290a486812a83fb74e352
Created April 26, 2024 11:36
Funnelkit Cart: Add or remove class when funnelkit cart open or closed
add_action('wp_footer',function (){
?>
<script>
window.addEventListener('load', function () {
jQuery(document.body).on('fkcart_cart_open',function(){
if(jQuery('body').hasClass('mm-wrapper--position-left')){
jQuery('body').removeClass('mm-wrapper--position-left')
}
$environment_funnel_id = WFOCU_Core()->rules->get_environment_var( 'funnel_id' );
$order_id = WFOCU_Core()->rules->get_environment_var( 'order' );
WFOCU_Core()->log->log( 'Order #' . $order_id . ' match rule details for skip funnel ' . print_r( array( // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r
'funnel_id' => WFOCU_Core()->data->get_funnel_id(),
'match' => ( $match ) ? 'true' : 'false',
'environment' => $environment,
'environment_funnel_id' => $environment_funnel_id
), true ) . ' rule data ' . print_r( $rule, true ) );