Skip to content

Instantly share code, notes, and snippets.

<?php
/**
* Update the maximum discount rate in the Bookings for WooCommerce plugin
*/
funcion prefix_bfwc_discount_rate_max( $max, $product_id ) {
return 1000;
}
add_filter( 'bfwc_discount_rate_max', 'prefix_bfwc_discount_rate_max', 10, 2 );
@plugin-republic
plugin-republic / last-image-woodmart.php
Created March 16, 2026 14:45
Go to the last carousel image when a file is updloaded
<?php
add_action( 'wp_footer', function () { ?>
<script>
jQuery(document).ready(function($) {
setTimeout(function() {
$('.woocommerce-product-gallery .wd-carousel-item:not( :last-child ) img').click(function() {
$('.aipaou-image-layer').hide();
});
$('.woocommerce-product-gallery .wd-carousel-item:last-child img').click(function() {
$('.aipaou-image-layer').show();
<?php
// Update shipping class if any of the specified fields has any value.
// Uncomment the marked line below if you want to check fields for a specific value.
add_action( 'woocommerce_before_calculate_totals', function( $cart ) {
if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
return;
}
$target_field_ids = [ 1642, 1643, 1644 ]; // the field IDs
$shipping_class = 'easy'; // the shipping class slug
<?php
remove_action( 'pewc_after_group_wrap', 'pewc_display_clear_all_button', 21 );
// Place Clear All Options above totals summary
add_action( 'pewc_after_group_wrap', 'pewc_display_clear_all_button', 0, 3 );
// Place Clear All Options above all fields
// add_action( 'pewc_start_groups', function( $args ) {
// pewc_display_clear_all_button( $args[0], null, array() );
// } );
<?php
/**
* Flat rate with daily overage for Bookings for WooCommerce
*
* When a product has the "Flat rate" option enabled, charges the flat rate
* for bookings up to $min_days, then adds $daily_rate
* for each additional day beyond that.
*
* Add to your theme's functions.php or a site-specific plugin.
*
<?php
/**
* Set migration to done for Dynamic Pricing and Discount Rules
*/
add_filter( 'wcfad_assume_migration_done', '__return_true' );
<?php
/**
* Subtract last day's cost from daily booking
* Requires bookings to be a minimum of 2 days
*/
function demo_dont_charge_last_day( $booking_cost, $product_id ) {
$std_cost = bfwc_get_standard_cost( $product_id );
$booking_cost = $booking_cost - $std_cost;
return $booking_cost;
}
<?php
add_action( 'wp_footer', function(){
?>
<script>
jQuery( document ).ready( function(){
jQuery( document.body ).on( 'woosq_loaded', function( event, id ){
jQuery( 'body' ).trigger( 'pewc_check_conditions' ).trigger('pewc_trigger_calculations');
jQuery( 'body' ).trigger( 'pewc_reinitiate_js_validation' );
jQuery( 'body' ).trigger( 'pewc_attach_form_cart_input_change' );
jQuery( 'body' ).trigger( 'pewc_trigger_initial_check' );
<?php
/**
* If a product has an alternative featured image, display that on the archive page
*/
function pr_demo_product_get_image( $image, $product, $size, $attr, $placeholder ) {
if( is_product() ) {
// We're on a product page so just return the image
return $image;
}
$product_id = $product->get_id();
.pewc-has-hex .pewc-radio-images-wrapper img {
visibility: visible;
height: auto;
}
.pewc-hex {
display: none;
}