Skip to content

Instantly share code, notes, and snippets.

View Crocoblock's full-sized avatar

Crocoblock Crocoblock

View GitHub Profile
@Crocoblock
Crocoblock / js.md
Last active January 19, 2026 20:47
JetSmartFilters API

Init event

document.addEventListener( 'jet-smart-filters/inited', function( initEvent ) {      
	console.log( 'filters init' );
} );

JetSmartFilters

@Crocoblock
Crocoblock / code.php
Created December 20, 2023 13:34
JetAppointment Exclude not full-duration slots
<?php
add_filter( 'jet-apb/time-slots/slots-html/slots-list', function( $slots, $format, $dataset, $date, $service, $provider ) {
$duration = jet_apb()->calendar->get_schedule_settings( $provider, $service, null, 'default_slot' );
foreach ( $slots as $time => $slot ) {
if ( $slot['to'] - $slot['from'] < $duration ) {
unset( $slots[ $time ] );
}
@Crocoblock
Crocoblock / code.php
Last active January 7, 2026 15:19
JetSmartFilters Split Range filter plain query
<?php
add_filter( 'jet-smart-filters/query/final-query', function( $query ) {
if ( empty( $query ) ) {
return $query;
}
foreach ( $query as $var => $value ) {
@Crocoblock
Crocoblock / custom-column-callback.php
Last active December 31, 2025 13:49
Add custom admin column callback to post type
<?php
/**
* Functions may be used as a custom post type column callback
*/
/**
* If the function name does not contain 'jet_engine_custom_cb' prefix,
* the callback takes only two arguments: column name and post ID
* You may use such callbacks if you do not need to specify any arguments
* Example: show post author in a column
@Crocoblock
Crocoblock / file1.php
Created December 18, 2025 07:24
Get min max value to range filter from query. New callback is added to the filters
<?php
use Jet_Engine\Query_Builder\Manager;
add_filter('jet-smart-filters/post-type/meta-fields-settings', 'custom_register_controls');
function custom_register_controls($fields) {
$queries = Manager::instance()->get_queries_for_options();
@Crocoblock
Crocoblock / reinit-wc-variation-form.js
Created February 10, 2023 08:45
JetSmartFilters JetEngine Reinit WC variations form on jet-filter-content-rendered and jet-engine/listing-grid/after-load-more
document.addEventListener( 'jet-smart-filters/inited', ( e ) => {
jQuery( document ).on( 'jet-filter-content-rendered', function( event, $provider ) {
$provider.find( '.variations_form' ).each( function() {
jQuery( this ).wc_variation_form();
});
} );
jQuery( document ).on( 'jet-engine/listing-grid/after-load-more', function( event, args, response ) {
if ( ! response.success ) {
return;
}
@Crocoblock
Crocoblock / code.php
Last active December 15, 2025 18:06
JetFormBuilder Bypass payment gateway actions if price is 0
<?php
add_filter(
'jet-form-builder/default-process-event/executors',
'jet_fb_custom_modify_default_executors',
11
);
/**
* Works with JetFormBuilder >= 3.2
@Crocoblock
Crocoblock / get-related.md
Last active December 12, 2025 05:02
Get JetEngine Related Items programmatically / Update related items / Get/Update relation meta
@Crocoblock
Crocoblock / jet-engine-get-query.md
Last active December 10, 2025 12:51
JetEngine Get query by ID, get items from query

Call these methods not earlier than on 'init' with the priority of 12, queries are not registered before that

Get query list

Returns an array of $id => $name

$queries = \Jet_Engine\Query_Builder\Manager::instance()->get_queries_for_options()

Get query by ID

ID is an integer, can be found in query URL in Query Builder; \

@Crocoblock
Crocoblock / data-store-api.md
Last active December 5, 2025 09:25
JetEngine Data Store API

Get store items, add items, remove items

Check if data store module active

returns true/false; call not earlier than 'init' action with the priority of 1

$module_active = jet_engine()->modules->is_module_active( 'data-stores' );
Get store factory

returns instance of \Jet_Engine\Modules\Data_Stores\Stores\Factory\