Skip to content

Instantly share code, notes, and snippets.

<?php
/**
* Enable text values from calculation lookup tables
*/
add_filter( 'pewc_allow_text_calcs', '__return_true' );
<?php
/**
* Array of discount rates
*/
function prefix_discount_rates( $rates, $product_id ) {
$excluded_ids = array( 1234 );
if( in_array( $product_id, $excluded_ids ) ) {
return $rates;
}
$rates = array(
<?php
/**
* Ensure tax isn't added to options with 'value only'
*/
function prefix_check_tax_for_option_price( $check, $option_price, $item ) {
if( ! empty( $item['option_price_visibility'] && $item['option_price_visibility'] == 'value' ) ) {
return false;
}
return $check;
}
<?php
/**
* Filter Bookings discount rates
* This snippet allows you to set fixed prices for multiple tiers
* In the array below:
* rate refers to the fixed price per unit
* after refers to the number of units where the rate kicks in
* from set to 'all' to apply the rate to the entire booking price
*/
function prefix_discount_rates( $rates, $product_id ) {
/* Disable checkboxes */
.pewc-group-checkbox .pewc-item-field-wrapper {
pointer-events: none;
}
<?php
/**
* Display remaining quantity on Bookings page
*/
function prefix_display_remaining_quantity() {
$remaining = bfwc_get_max_bookings( get_the_ID() );
printf(
'Places remaining: %s',
$remaining
);
/* Display field labels and values in columns */
span.pewc-summary-panel-product-name {
width: 60%;
display: inline-block;
}
span.pewc-summary-panel-product-value {
display: inline-block;
width: 30%;
}
td.pewc-summary-panel-price {
<?php
/**
* Bypass all transients
*/
add_filter( 'pewc_disable_all_transients', '__return_true' );
<?php
add_filter( 'unzip_file_use_ziparchive', '__return_false' );
<html>
<head>
<title>Product Add-Ons Ultimate REST API Tester</title>
</head>
<body>
<script src='wp-includes/js/jquery/jquery.min.js'></script>
<p>API Key: <input type="text" id="wc_api_key" value="" size="50"></p>
<p>API Secret: <input type="text" id="wc_api_secret" value="" size="50"></p>
<p>API Method: