Skip to content

Instantly share code, notes, and snippets.

<?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;
}
<?php
/**
* Filter the available fonts for each text preview field
* List fonts in arrays using 'abel' => 'Abel' key / value pairs
* Update the field IDs to match your own
*/
function demo_filter_all_fonts( $all_fonts, $available_fonts, $field ) {
// Update the field IDs below to match your field IDs
if( $field['field_id'] == 1209 ) {
<?php
/**
* Add a shortcode using a hook
*/
function pr_add_shortcode_after_product_summary() {
echo do_shortcode( '[product_category category="hoodies" columns="3" limit="6"]' );
}
add_action( 'woocommerce_after_single_product_summary', 'pr_add_shortcode_after_product_summary', 5 );
<?php
/**
* Reduce option and field prices by 10%
*/
function demo_discount_field_price( $price, $item, $product ) {
$price = $price * 0.9;
return $price;
}
<?php
/**
* Allow independent child product quantities to be edited in cart
*/
remove_filter( 'pewc_filter_quantity_field', 'pewc_force_quantity_field', 10, 6 );
<?php
/**
* Quickview markup adjustment for Elementor
*/
remove_action( 'wp_footer', 'pewc_display_quickview_background' );
function demo_display_quickview_background() {
if( did_action( 'woocommerce_after_add_to_cart_button' ) > 2 ) {
return;
}
if( pewc_child_product_quickview() == 'yes' ) { ?>